diff --git a/gen/adexchangebuyer1d3-cli/Cargo.toml b/gen/adexchangebuyer1d3-cli/Cargo.toml index f44c980913..a2a65dffb0 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+20160405" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "adexchangebuyer1d3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangebuyer1d3/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangebuyer1d3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangebuyer1d3] diff --git a/gen/adexchangebuyer1d3-cli/README.md b/gen/adexchangebuyer1d3-cli/README.md index e4b650f14c..76030a5319 100644 --- a/gen/adexchangebuyer1d3-cli/README.md +++ b/gen/adexchangebuyer1d3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Ad Exchange Buyer* API at revision *20160405*. 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 *0.3.6*. ```bash adexchangebuyer1d3 [options] diff --git a/gen/adexchangebuyer1d3-cli/mkdocs.yml b/gen/adexchangebuyer1d3-cli/mkdocs.yml index e48f867b80..91f630128f 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+20160405 +site_name: Ad Exchange Buyer v0.3.6+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 2c452a7cdb..1d7cc7d720 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+20160405") + .version("0.3.6+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/adexchangebuyer1d3/Cargo.toml b/gen/adexchangebuyer1d3/Cargo.toml index 6af1c4e4c3..ed8cab22d8 100644 --- a/gen/adexchangebuyer1d3/Cargo.toml +++ b/gen/adexchangebuyer1d3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d3" -version = "0.1.14+20160405" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/adexchangebuyer1d3/README.md b/gen/adexchangebuyer1d3/README.md index ed5927c3a0..d700f311af 100644 --- a/gen/adexchangebuyer1d3/README.md +++ b/gen/adexchangebuyer1d3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adexchangebuyer1d3` library allows access to all features of the *Google Ad Exchange Buyer* service. -This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Ad Exchange Buyer* *v1d3* API can be found at the [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). diff --git a/gen/adexchangebuyer1d3/src/lib.rs b/gen/adexchangebuyer1d3/src/lib.rs index 7f7ec01bd8..8840149080 100644 --- a/gen/adexchangebuyer1d3/src/lib.rs +++ b/gen/adexchangebuyer1d3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *adexchangebuyer:v1.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Ad Exchange Buyer* *v1d3* API can be found at the //! [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). diff --git a/gen/adexchangebuyer1d4-cli/Cargo.toml b/gen/adexchangebuyer1d4-cli/Cargo.toml index 365d2781b9..288796a820 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+20160405" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "adexchangebuyer1d4" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangebuyer1d4/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangebuyer1d4/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangebuyer1d4] diff --git a/gen/adexchangebuyer1d4-cli/README.md b/gen/adexchangebuyer1d4-cli/README.md index 54536f9380..bb5aea0456 100644 --- a/gen/adexchangebuyer1d4-cli/README.md +++ b/gen/adexchangebuyer1d4-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Ad Exchange Buyer* API at revision *20160405*. 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 *0.3.6*. ```bash adexchangebuyer1d4 [options] diff --git a/gen/adexchangebuyer1d4-cli/mkdocs.yml b/gen/adexchangebuyer1d4-cli/mkdocs.yml index 41a72fe1b4..51c2df95e9 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+20160405 +site_name: Ad Exchange Buyer v0.3.6+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 b252081c3f..592e2daa06 100644 --- a/gen/adexchangebuyer1d4-cli/src/main.rs +++ b/gen/adexchangebuyer1d4-cli/src/main.rs @@ -196,6 +196,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "confirm-unsafe-account-change" => { + call = call.confirm_unsafe_account_change(arg_from_str(value.unwrap_or("false"), err, "confirm-unsafe-account-change", "boolean")); + }, _ => { let mut found = false; for param in &self.gp { @@ -209,6 +212,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["confirm-unsafe-account-change"].iter().map(|v|*v)); v } )); } } @@ -288,6 +292,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "confirm-unsafe-account-change" => { + call = call.confirm_unsafe_account_change(arg_from_str(value.unwrap_or("false"), err, "confirm-unsafe-account-change", "boolean")); + }, _ => { let mut found = false; for param in &self.gp { @@ -301,6 +308,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["confirm-unsafe-account-change"].iter().map(|v|*v)); v } )); } } @@ -798,10 +806,12 @@ impl<'n> Engine<'n> { "html-snippet" => Some(("HTMLSnippet", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "open-auction-status" => Some(("openAuctionStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "buyer-creative-id" => Some(("buyerCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-choices-destination-url" => Some(("adChoicesDestinationUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "impression-tracking-url" => Some(("impressionTrackingUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "video-url" => Some(("videoURL", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "click-through-url" => Some(("clickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "languages" => Some(("languages", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "width" => Some(("width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "native-ad.body" => Some(("nativeAd.body", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "native-ad.advertiser" => Some(("nativeAd.advertiser", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -827,13 +837,14 @@ impl<'n> Engine<'n> { "sensitive-categories" => Some(("sensitiveCategories", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), "product-categories" => Some(("productCategories", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), "agency-id" => Some(("agencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "detected-domains" => Some(("detectedDomains", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "deals-status" => Some(("dealsStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "restricted-categories" => Some(("restrictedCategories", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), "filtering-reasons.date" => Some(("filteringReasons.date", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["html-snippet", "account-id", "advertiser", "advertiser-id", "advertiser-name", "agency-id", "api-upload-timestamp", "app-icon", "attribute", "body", "buyer-creative-id", "call-to-action", "click-through-url", "click-tracking-url", "date", "deals-status", "filtering-reasons", "headline", "height", "image", "impression-tracking-url", "kind", "logo", "native-ad", "open-auction-status", "price", "product-categories", "restricted-categories", "sensitive-categories", "star-rating", "store", "url", "vendor-type", "version", "video-url", "width"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["html-snippet", "account-id", "ad-choices-destination-url", "advertiser", "advertiser-id", "advertiser-name", "agency-id", "api-upload-timestamp", "app-icon", "attribute", "body", "buyer-creative-id", "call-to-action", "click-through-url", "click-tracking-url", "date", "deals-status", "detected-domains", "filtering-reasons", "headline", "height", "image", "impression-tracking-url", "kind", "languages", "logo", "native-ad", "open-auction-status", "price", "product-categories", "restricted-categories", "sensitive-categories", "star-rating", "store", "url", "vendor-type", "version", "video-url", "width"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1188,6 +1199,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "pql-query" => { + call = call.pql_query(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1201,6 +1215,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["pql-query"].iter().map(|v|*v)); v } )); } } @@ -1262,7 +1277,6 @@ impl<'n> Engine<'n> { "proposal.name" => Some(("proposal.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.revision-time-ms" => Some(("proposal.revisionTimeMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.private-auction-id" => Some(("proposal.privateAuctionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "proposal.buyer.account-id" => Some(("proposal.buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.buyer-private-data.reference-id" => Some(("proposal.buyerPrivateData.referenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.buyer-private-data.reference-payload" => Some(("proposal.buyerPrivateData.referencePayload", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.billed-buyer.account-id" => Some(("proposal.billedBuyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1275,14 +1289,14 @@ impl<'n> Engine<'n> { "proposal.last-updater-or-commentor-role" => Some(("proposal.lastUpdaterOrCommentorRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.has-seller-signed-off" => Some(("proposal.hasSellerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "proposal.is-renegotiating" => Some(("proposal.isRenegotiating", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "proposal.last-updater-role" => Some(("proposal.lastUpdaterRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "proposal.buyer.account-id" => Some(("proposal.buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal.has-buyer-signed-off" => Some(("proposal.hasBuyerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "proposal.is-setup-complete" => Some(("proposal.isSetupComplete", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "proposal.revision-number" => Some(("proposal.revisionNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "proposal-revision-number" => Some(("proposalRevisionNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "update-action" => Some(("updateAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "last-updater-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal", "proposal-id", "proposal-revision-number", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id", "update-action"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal", "proposal-id", "proposal-revision-number", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id", "update-action"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1432,6 +1446,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "pql-query" => { + call = call.pql_query(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1445,6 +1462,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["pql-query"].iter().map(|v|*v)); v } )); } } @@ -2357,7 +2375,6 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "revision-time-ms" => Some(("revisionTimeMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "private-auction-id" => Some(("privateAuctionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "buyer.account-id" => Some(("buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "buyer-private-data.reference-id" => Some(("buyerPrivateData.referenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "buyer-private-data.reference-payload" => Some(("buyerPrivateData.referencePayload", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "billed-buyer.account-id" => Some(("billedBuyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2370,12 +2387,12 @@ impl<'n> Engine<'n> { "last-updater-or-commentor-role" => Some(("lastUpdaterOrCommentorRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "has-seller-signed-off" => Some(("hasSellerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "is-renegotiating" => Some(("isRenegotiating", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "last-updater-role" => Some(("lastUpdaterRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "buyer.account-id" => Some(("buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "has-buyer-signed-off" => Some(("hasBuyerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "is-setup-complete" => Some(("isSetupComplete", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "revision-number" => Some(("revisionNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "last-updater-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal-id", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal-id", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2563,7 +2580,6 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "revision-time-ms" => Some(("revisionTimeMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "private-auction-id" => Some(("privateAuctionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "buyer.account-id" => Some(("buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "buyer-private-data.reference-id" => Some(("buyerPrivateData.referenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "buyer-private-data.reference-payload" => Some(("buyerPrivateData.referencePayload", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "billed-buyer.account-id" => Some(("billedBuyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2576,12 +2592,12 @@ impl<'n> Engine<'n> { "last-updater-or-commentor-role" => Some(("lastUpdaterOrCommentorRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "has-seller-signed-off" => Some(("hasSellerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "is-renegotiating" => Some(("isRenegotiating", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "last-updater-role" => Some(("lastUpdaterRole", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "buyer.account-id" => Some(("buyer.accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "has-buyer-signed-off" => Some(("hasBuyerSignedOff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "is-setup-complete" => Some(("isSetupComplete", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "revision-number" => Some(("revisionNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "last-updater-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal-id", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "billed-buyer", "buyer", "buyer-private-data", "has-buyer-signed-off", "has-seller-signed-off", "inventory-source", "is-renegotiating", "is-setup-complete", "kind", "last-updater-or-commentor-role", "name", "negotiation-id", "originator-role", "private-auction-id", "proposal-id", "proposal-state", "reference-id", "reference-payload", "revision-number", "revision-time-ms", "seller", "sub-account-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3413,7 +3429,7 @@ fn main() { vec![ (Some(r##"proposal-id"##), None, - Some(r##"The proposalId to get deals for."##), + Some(r##"The proposalId to get deals for. To search across all proposals specify order_id = '-' as part of the URL."##), Some(true), Some(false)), @@ -3494,7 +3510,7 @@ fn main() { vec![ (Some(r##"proposal-id"##), None, - Some(r##"The proposalId to get notes for."##), + Some(r##"The proposalId to get notes for. To search across all proposals specify order_id = '-' as part of the URL."##), Some(true), Some(false)), @@ -3849,7 +3865,7 @@ fn main() { (Some(r##"update-action"##), None, - Some(r##"The proposed action to take on the proposal."##), + Some(r##"The proposed action to take on the proposal. This field is required and it must be set when updating a proposal."##), Some(true), Some(false)), @@ -3921,7 +3937,7 @@ fn main() { (Some(r##"update-action"##), None, - Some(r##"The proposed action to take on the proposal."##), + Some(r##"The proposed action to take on the proposal. This field is required and it must be set when updating a proposal."##), Some(true), Some(false)), @@ -3974,7 +3990,7 @@ fn main() { let mut app = App::new("adexchangebuyer1d4") .author("Sebastian Thiel ") - .version("0.3.6+20160405") + .version("0.3.6+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/adexchangebuyer1d4/Cargo.toml b/gen/adexchangebuyer1d4/Cargo.toml index b03b1816e1..4ba040f942 100644 --- a/gen/adexchangebuyer1d4/Cargo.toml +++ b/gen/adexchangebuyer1d4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangebuyer1d4" -version = "0.1.14+20160405" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/adexchangebuyer1d4/README.md b/gen/adexchangebuyer1d4/README.md index faa0aad88d..6bd5fae0cb 100644 --- a/gen/adexchangebuyer1d4/README.md +++ b/gen/adexchangebuyer1d4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adexchangebuyer1d4` library allows access to all features of the *Google Ad Exchange Buyer* service. -This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adexchangebuyer:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *adexchangebuyer:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Ad Exchange Buyer* *v1d4* API can be found at the [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). diff --git a/gen/adexchangebuyer1d4/src/lib.rs b/gen/adexchangebuyer1d4/src/lib.rs index eb56df488b..2a96bf263f 100644 --- a/gen/adexchangebuyer1d4/src/lib.rs +++ b/gen/adexchangebuyer1d4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adexchangebuyer:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Ad Exchange Buyer* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *adexchangebuyer:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Ad Exchange Buyer* *v1d4* API can be found at the //! [official documentation site](https://developers.google.com/ad-exchange/buyer-rest). diff --git a/gen/adexchangebuyer1d4/src/lib.rs.in b/gen/adexchangebuyer1d4/src/lib.rs.in index 55a035c2aa..c64df741d7 100644 --- a/gen/adexchangebuyer1d4/src/lib.rs.in +++ b/gen/adexchangebuyer1d4/src/lib.rs.in @@ -189,6 +189,29 @@ impl<'a, C, A> AdExchangeBuyer // ############ // SCHEMAS ### // ########## +/// All known serving contexts containing serving status information. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeCorrectionsContexts { + /// Only set when contextType=PLATFORM. Represents the platforms this correction applies to. + pub platform: Option>, + /// The type of context (e.g., location, platform, auction type, SSL-ness). + #[serde(rename="contextType")] + pub context_type: Option, + /// Only set when contextType=AUCTION_TYPE. Represents the auction types this correction applies to. + #[serde(rename="auctionType")] + pub auction_type: Option>, + /// Only set when contextType=LOCATION. Represents the geo criterias this correction applies to. + #[serde(rename="geoCriteriaId")] + pub geo_criteria_id: Option>, +} + +impl NestedType for CreativeCorrectionsContexts {} +impl Part for CreativeCorrectionsContexts {} + + /// There is no detailed description. /// /// # Activities @@ -315,6 +338,9 @@ pub struct Creative { /// All restricted categories for the ads that may be shown from this snippet. #[serde(rename="restrictedCategories")] pub restricted_categories: Option>, + /// Detected domains for this creative. Read-only. This field should not be set in requests. + #[serde(rename="detectedDomains")] + pub detected_domains: Option>, /// Ad height. pub height: Option, /// Detected advertiser id, if any. Read-only. This field should not be set in requests. @@ -332,6 +358,9 @@ pub struct Creative { /// Top-level deals status. Read-only. This field should not be set in requests. If disapproved, an entry for auctionType=DIRECT_DEALS (or ALL) in servingRestrictions will also exist. Note that this may be nuanced with other contextual restrictions, in which case it may be preferable to read from servingRestrictions directly. #[serde(rename="dealsStatus")] pub deals_status: Option, + /// The link to the Ad Preferences page. This is only supported for native ads. + #[serde(rename="adChoicesDestinationUrl")] + pub ad_choices_destination_url: Option, /// The set of urls to be called to record an impression. #[serde(rename="impressionTrackingUrl")] pub impression_tracking_url: Option>, @@ -354,6 +383,8 @@ pub struct Creative { pub serving_restrictions: Option>, /// Shows any corrections that were applied to this creative. Read-only. This field should not be set in requests. pub corrections: Option>, + /// Detected languages for this creative. Read-only. This field should not be set in requests. + pub languages: Option>, /// Ad width. pub width: Option, /// If nativeAd is set, HTMLSnippet and videoURL should not be set. @@ -394,7 +425,7 @@ pub struct DeleteOrderDealsRequest { /// The last known proposal revision number. #[serde(rename="proposalRevisionNumber")] pub proposal_revision_number: Option, - /// no description provided + /// Indicates an optional action to take on the proposal #[serde(rename="updateAction")] pub update_action: Option, /// List of deals to delete for a given proposal @@ -405,7 +436,7 @@ pub struct DeleteOrderDealsRequest { impl RequestValue for DeleteOrderDealsRequest {} -/// Tracks which parties (if any) have paused a deal. The deal is considered paused if has_buyer_paused || has_seller_paused. +/// Tracks which parties (if any) have paused a deal. The deal is considered paused if has_buyer_paused || has_seller_paused. Each of the has_buyer_paused or the has_seller_paused bits can be set independently. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -415,8 +446,17 @@ pub struct DealServingMetadataDealPauseStatus { #[serde(rename="hasSellerPaused")] pub has_seller_paused: Option, /// no description provided + #[serde(rename="buyerPauseReason")] + pub buyer_pause_reason: Option, + /// no description provided + #[serde(rename="sellerPauseReason")] + pub seller_pause_reason: Option, + /// no description provided #[serde(rename="hasBuyerPaused")] pub has_buyer_paused: Option, + /// If the deal is paused, records which party paused the deal first. + #[serde(rename="firstPausedBy")] + pub first_paused_by: Option, } impl Part for DealServingMetadataDealPauseStatus {} @@ -531,7 +571,7 @@ pub struct Proposal { /// Indicates whether the buyer/seller created the proposal.(readonly) #[serde(rename="originatorRole")] pub originator_role: Option, - /// Optional contact information for the seller (buyer-readonly). + /// Optional contact information of the seller (buyer-readonly). #[serde(rename="sellerContacts")] pub seller_contacts: Option>, /// Optional negotiation id if this proposal is a preferred deal proposal. @@ -543,10 +583,9 @@ pub struct Proposal { /// When an proposal is in an accepted state, indicates whether the buyer has signed off Once both sides have signed off on a deal, the proposal can be finalized by the seller. (buyer-readonly) #[serde(rename="hasSellerSignedOff")] pub has_seller_signed_off: Option, - /// no description provided - #[serde(rename="lastUpdaterRole")] - pub last_updater_role: Option, - /// When an proposal is in an accepted state, indicates whether the buyer has signed off Once both sides have signed off on a deal, the proposal can be finalized by the seller. (seller-readonly) + /// Reference to the buyer on the proposal. (readonly, except on create) + pub buyer: Option, + /// When an proposal is in an accepted state, indicates whether the buyer has signed off. Once both sides have signed off on a deal, the proposal can be finalized by the seller. (seller-readonly) #[serde(rename="hasBuyerSignedOff")] pub has_buyer_signed_off: Option, /// The revision number for the proposal (readonly). @@ -576,15 +615,13 @@ pub struct Proposal { /// True if the proposal is being renegotiated (readonly). #[serde(rename="isRenegotiating")] pub is_renegotiating: Option, - /// Reference to the buyer on the proposal. (readonly, except on create) - pub buyer: Option, /// True, if the buyside inventory setup is complete for this proposal. (readonly, except via OrderSetupCompleted action) #[serde(rename="isSetupComplete")] pub is_setup_complete: Option, /// The role of the last user that either updated the proposal or left a comment. (readonly) #[serde(rename="lastUpdaterOrCommentorRole")] pub last_updater_or_commentor_role: Option, - /// Optional contact information fort the buyer. (seller-readonly) + /// Optional contact information of the buyer. (seller-readonly) #[serde(rename="buyerContacts")] pub buyer_contacts: Option>, } @@ -637,9 +674,9 @@ pub struct Product { pub shared_targetings: Option>, /// The negotiable terms of the deal (buyer-readonly) pub terms: Option, - /// Optional private auction id if this offer is a private auction offer. - #[serde(rename="privateAuctionId")] - pub private_auction_id: Option, + /// Publisher self-provided forecast information. + #[serde(rename="publisherProvidedForecast")] + pub publisher_provided_forecast: Option, /// The proposed end time for the deal (ms since epoch) (buyer-readonly) #[serde(rename="flightEndTimeMs")] pub flight_end_time_ms: Option, @@ -667,6 +704,9 @@ pub struct Product { /// The syndication product associated with the deal. (readonly, except on create) #[serde(rename="syndicationProduct")] pub syndication_product: Option, + /// Optional private auction id if this offer is a private auction offer. + #[serde(rename="privateAuctionId")] + pub private_auction_id: Option, /// Information about the seller that created this product (readonly, except on create) pub seller: Option, /// The web property code for the seller. This field is meant to be copied over as is when creating deals. @@ -703,7 +743,7 @@ impl ResponseResult for Product {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GetOrderNotesResponse { - /// The list of matching notes. + /// The list of matching notes. The notes for a proposal are ordered from oldest to newest. If the notes span multiple proposals, they will be grouped by proposal, with the notes for the most recently modified proposal appearing first. pub notes: Option>, } @@ -828,6 +868,9 @@ pub struct Price { /// The currency code for the price. #[serde(rename="currencyCode")] pub currency_code: Option, + /// In case of CPD deals, the expected CPM in micros. + #[serde(rename="expectedCpmMicros")] + pub expected_cpm_micros: Option, /// The price value in micros. #[serde(rename="amountMicros")] pub amount_micros: Option, @@ -882,23 +925,24 @@ impl ResponseResult for EditAllOrderDealsResponse {} /// 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*). -/// -/// * [insert proposals](struct.ProposalInsertCall.html) (request) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CreateOrdersRequest { - /// no description provided - #[serde(rename="webPropertyCode")] - pub web_property_code: Option, - /// The list of proposals to create. - pub proposals: Option>, +pub struct DealTermsGuaranteedFixedPriceTermsBillingInfo { + /// The original reservation price for the deal, if the currency code is different from the one used in negotiation. + pub price: Option, + /// The DFP line item id associated with this deal. For features like CPD, buyers can retrieve the DFP line item for billing reconciliation. + #[serde(rename="dfpLineItemId")] + pub dfp_line_item_id: Option, + /// The original contracted quantity (# impressions) for this deal. To ensure delivery, sometimes the publisher will book the deal with a impression buffer, such that guaranteed_looks is greater than the contracted quantity. However clients are billed using the original contracted quantity. + #[serde(rename="originalContractedQuantity")] + pub original_contracted_quantity: Option, + /// The timestamp (in ms since epoch) when the original reservation price for the deal was first converted to DFP currency. This is used to convert the contracted price into advertiser's currency without discrepancy. + #[serde(rename="currencyConversionTimeMs")] + pub currency_conversion_time_ms: Option, } -impl RequestValue for CreateOrdersRequest {} +impl Part for DealTermsGuaranteedFixedPriceTermsBillingInfo {} /// There is no detailed description. @@ -1055,9 +1099,11 @@ impl ResponseResult for GetPublisherProfilesByAccountIdResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DimensionDimensionValue { + /// Percent of total impressions for a dimension type. e.g. {dimension_type: 'GENDER', [{dimension_value: {id: 1, name: 'MALE', percentage: 60}}]} Gender MALE is 60% of all impressions which have gender. + pub percentage: Option, /// Id of the dimension. pub id: Option, - /// Name of the dimension mainly for debugging purposes. + /// Name of the dimension mainly for debugging purposes, except for the case of CREATIVE_SIZE. For CREATIVE_SIZE, strings are used instead of ids. pub name: Option, } @@ -1427,7 +1473,7 @@ pub struct PublisherProfileApiProto { pub kind: Option, /// Programmatic contact for the publisher profile. #[serde(rename="programmaticContact")] - pub programmatic_contact: Option, + pub programmatic_contact: Option, /// The list of domains represented in this publisher profile. Empty if this is a parent profile. #[serde(rename="publisherDomains")] pub publisher_domains: Option>, @@ -1443,7 +1489,7 @@ pub struct PublisherProfileApiProto { pub seller: Option, /// Direct contact for the publisher profile. #[serde(rename="directContact")] - pub direct_contact: Option, + pub direct_contact: Option, /// Link for a sample content page. #[serde(rename="samplePageLink")] pub sample_page_link: Option, @@ -1552,7 +1598,7 @@ pub struct MarketplaceDeal { /// The shared targeting visible to buyers and sellers. Each shared targeting entity is AND'd together. (updatable) #[serde(rename="sharedTargetings")] pub shared_targetings: Option>, - /// A unique deal=id for the deal (readonly). + /// A unique deal-id for the deal (readonly). #[serde(rename="dealId")] pub deal_id: Option, /// Specifies the creative source for programmatic deals, PUBLISHER means creative is provided by seller and ADVERTISR means creative is provided by buyer. (buyer-readonly) @@ -1735,21 +1781,25 @@ impl RequestValue for PretargetingConfig {} impl ResponseResult for PretargetingConfig {} -/// This message carries publisher provided breakdown. E.g. {dimension_type: 'COUNTRY', [{dimension_value: {id: 1, name: 'US'}}, {dimension_value: {id: 2, name: 'UK'}}]} +/// There is no detailed description. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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 proposals](struct.ProposalInsertCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Dimension { - /// no description provided - #[serde(rename="dimensionType")] - pub dimension_type: Option, - /// no description provided - #[serde(rename="dimensionValues")] - pub dimension_values: Option>, +pub struct CreateOrdersRequest { + /// Web property id of the seller creating these orders + #[serde(rename="webPropertyCode")] + pub web_property_code: Option, + /// The list of proposals to create. + pub proposals: Option>, } -impl Part for Dimension {} +impl RequestValue for CreateOrdersRequest {} /// There is no detailed description. @@ -1809,12 +1859,39 @@ impl NestedType for PretargetingConfigDimensions {} impl Part for PretargetingConfigDimensions {} +/// 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*). +/// +/// * [insert marketplacedeals](struct.MarketplacedealInsertCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AddOrderDealsRequest { + /// The list of deals to add + pub deals: Option>, + /// The last known proposal revision number. + #[serde(rename="proposalRevisionNumber")] + pub proposal_revision_number: Option, + /// Indicates an optional action to take on the proposal + #[serde(rename="updateAction")] + pub update_action: Option, +} + +impl RequestValue for AddOrderDealsRequest {} + + /// Used to specify pricing rules for buyers/advertisers. Each PricePerBuyer in an product can become [0,1] deals. To check if there is a PricePerBuyer for a particular buyer or buyer/advertiser pair, we look for the most specific matching rule - we first look for a rule matching the buyer and advertiser, next a rule with the buyer but an empty advertiser list, and otherwise look for a matching rule where no buyer is set. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PricePerBuyer { + /// Optional access type for this buyer. + #[serde(rename="auctionTier")] + pub auction_tier: Option, /// The buyer who will pay this price. If unset, all buyers can pay this price (if the advertisers match, and there's no more specific rule matching the buyer). pub buyer: Option, /// The specified price @@ -1895,9 +1972,15 @@ pub struct DealTermsGuaranteedFixedPriceTerms { /// Fixed price for the specified buyer. #[serde(rename="fixedPrices")] pub fixed_prices: Option>, - /// Count of guaranteed looks. Required for deal, optional for product. + /// Count of minimum daily looks for a CPD deal. For CPD deals, buyer should negotiate on this field instead of guaranteed_looks. + #[serde(rename="minimumDailyLooks")] + pub minimum_daily_looks: Option, + /// Count of guaranteed looks. Required for deal, optional for product. For CPD deals, buyer changes to guaranteed_looks will be ignored. #[serde(rename="guaranteedLooks")] pub guaranteed_looks: Option, + /// External billing info for this Deal. This field is relevant when external billing info such as price has a different currency code than DFP/AdX. + #[serde(rename="billingInfo")] + pub billing_info: Option, } impl Part for DealTermsGuaranteedFixedPriceTerms {} @@ -1937,6 +2020,23 @@ impl NestedType for CreativeServingRestrictionsDisapprovalReasons {} impl Part for CreativeServingRestrictionsDisapprovalReasons {} +/// This message carries publisher provided breakdown. E.g. {dimension_type: 'COUNTRY', [{dimension_value: {id: 1, name: 'US'}}, {dimension_value: {id: 2, name: 'UK'}}]} +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Dimension { + /// no description provided + #[serde(rename="dimensionType")] + pub dimension_type: Option, + /// no description provided + #[serde(rename="dimensionValues")] + pub dimension_values: Option>, +} + +impl Part for Dimension {} + + /// If nativeAd is set, HTMLSnippet and videoURL should not be set. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1984,6 +2084,8 @@ impl Part for CreativeNativeAd {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeCorrections { + /// All known serving contexts containing serving status information. + pub contexts: Option>, /// The type of correction that was applied to the creative. pub reason: Option, /// Additional details about the correction. @@ -2000,14 +2102,17 @@ impl Part for CreativeCorrections {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetingValueCreativeSize { + /// For regular or video creative size type, specifies the size of the creative. + pub size: Option, /// The Creative size type. #[serde(rename="creativeSizeType")] pub creative_size_type: Option, /// For video size type, the list of companion sizes. #[serde(rename="companionSizes")] pub companion_sizes: Option>, - /// For regular or video creative size type, specifies the size of the creative. - pub size: Option, + /// The skippable ad type for video size. + #[serde(rename="skippableAdType")] + pub skippable_ad_type: Option, } impl Part for TargetingValueCreativeSize {} @@ -2015,26 +2120,19 @@ impl Part for TargetingValueCreativeSize {} /// 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*). -/// -/// * [insert marketplacedeals](struct.MarketplacedealInsertCall.html) (request) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddOrderDealsRequest { - /// The list of deals to add - pub deals: Option>, - /// The last known proposal revision number. - #[serde(rename="proposalRevisionNumber")] - pub proposal_revision_number: Option, - /// Indicates an optional action to take on the proposal - #[serde(rename="updateAction")] - pub update_action: Option, +pub struct DealTermsRubiconNonGuaranteedTerms { + /// Optional price for Rubicon priority access in the auction. + #[serde(rename="priorityPrice")] + pub priority_price: Option, + /// Optional price for Rubicon standard access in the auction. + #[serde(rename="standardPrice")] + pub standard_price: Option, } -impl RequestValue for AddOrderDealsRequest {} +impl Part for DealTermsRubiconNonGuaranteedTerms {} /// There is no detailed description. @@ -2069,9 +2167,12 @@ pub struct DealTerms { /// Visibilty of the URL in bid requests. #[serde(rename="brandingType")] pub branding_type: Option, - /// Non-binding estimate of the estimated gross spend for this deal Can be set by buyer or seller. - #[serde(rename="estimatedGrossSpend")] - pub estimated_gross_spend: Option, + /// Indicates that this ExternalDealId exists under at least two different AdxInventoryDeals. Currently, the only case that the same ExternalDealId will exist is programmatic cross sell case. + #[serde(rename="crossListedExternalDealIdType")] + pub cross_listed_external_deal_id_type: Option, + /// The terms for guaranteed fixed price deals. + #[serde(rename="guaranteedFixedPriceTerms")] + pub guaranteed_fixed_price_terms: Option, /// For deals with Cost Per Day billing, defines the timezone used to mark the boundaries of a day (buyer-readonly) #[serde(rename="sellerTimeZone")] pub seller_time_zone: Option, @@ -2081,9 +2182,12 @@ pub struct DealTerms { /// The terms for non-guaranteed fixed price deals. #[serde(rename="nonGuaranteedFixedPriceTerms")] pub non_guaranteed_fixed_price_terms: Option, - /// The terms for guaranteed fixed price deals. - #[serde(rename="guaranteedFixedPriceTerms")] - pub guaranteed_fixed_price_terms: Option, + /// Non-binding estimate of the estimated gross spend for this deal Can be set by buyer or seller. + #[serde(rename="estimatedGrossSpend")] + pub estimated_gross_spend: Option, + /// The terms for rubicon non-guaranteed deals. + #[serde(rename="rubiconNonGuaranteedTerms")] + pub rubicon_non_guaranteed_terms: Option, /// The terms for non-guaranteed auction deals. #[serde(rename="nonGuaranteedAuctionTerms")] pub non_guaranteed_auction_terms: Option, @@ -2328,11 +2432,12 @@ impl<'a, C, A> MarketplacedealMethods<'a, C, A> { /// /// # Arguments /// - /// * `proposalId` - The proposalId to get deals for. + /// * `proposalId` - The proposalId to get deals for. To search across all proposals specify order_id = '-' as part of the URL. pub fn list(&self, proposal_id: &str) -> MarketplacedealListCall<'a, C, A> { MarketplacedealListCall { hub: self.hub, _proposal_id: proposal_id.to_string(), + _pql_query: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2479,7 +2584,7 @@ impl<'a, C, A> ProposalMethods<'a, C, A> { /// * `request` - No description provided. /// * `proposalId` - The proposal id to update. /// * `revisionNumber` - The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision. - /// * `updateAction` - The proposed action to take on the proposal. + /// * `updateAction` - The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. pub fn update(&self, request: Proposal, proposal_id: &str, revision_number: &str, update_action: &str) -> ProposalUpdateCall<'a, C, A> { ProposalUpdateCall { hub: self.hub, @@ -2519,7 +2624,7 @@ impl<'a, C, A> ProposalMethods<'a, C, A> { /// * `request` - No description provided. /// * `proposalId` - The proposal id to update. /// * `revisionNumber` - The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision. - /// * `updateAction` - The proposed action to take on the proposal. + /// * `updateAction` - The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. pub fn patch(&self, request: Proposal, proposal_id: &str, revision_number: &str, update_action: &str) -> ProposalPatchCall<'a, C, A> { ProposalPatchCall { hub: self.hub, @@ -2834,11 +2939,12 @@ impl<'a, C, A> MarketplacenoteMethods<'a, C, A> { /// /// # Arguments /// - /// * `proposalId` - The proposalId to get notes for. + /// * `proposalId` - The proposalId to get notes for. To search across all proposals specify order_id = '-' as part of the URL. pub fn list(&self, proposal_id: &str) -> MarketplacenoteListCall<'a, C, A> { MarketplacenoteListCall { hub: self.hub, _proposal_id: proposal_id.to_string(), + _pql_query: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2918,6 +3024,7 @@ impl<'a, C, A> AccountMethods<'a, C, A> { hub: self.hub, _request: request, _id: id, + _confirm_unsafe_account_change: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2966,6 +3073,7 @@ impl<'a, C, A> AccountMethods<'a, C, A> { hub: self.hub, _request: request, _id: id, + _confirm_unsafe_account_change: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4772,6 +4880,7 @@ impl<'a, C, A> MarketplacedealUpdateCall<'a, C, A> where C: BorrowMut hub: &'a AdExchangeBuyer, _proposal_id: String, + _pql_query: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -4801,9 +4911,12 @@ impl<'a, C, A> MarketplacedealListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("proposalId", self._proposal_id.to_string())); - for &field in ["alt", "proposalId"].iter() { + if let Some(value) = self._pql_query { + params.push(("pqlQuery", value.to_string())); + } + for &field in ["alt", "proposalId", "pqlQuery"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4918,7 +5031,7 @@ impl<'a, C, A> MarketplacedealListCall<'a, C, A> where C: BorrowMut MarketplacedealListCall<'a, C, A> where C: BorrowMut MarketplacedealListCall<'a, C, A> { + self._pql_query = 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. /// @@ -5262,7 +5382,7 @@ impl<'a, C, A> MarketplaceprivateauctionUpdateproposalCall<'a, C, A> where C: Bo /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.proposals().search() -/// .pql_query("sea") +/// .pql_query("nonumy") /// .doit(); /// # } /// ``` @@ -5910,7 +6030,7 @@ impl<'a, C, A> ProposalUpdateCall<'a, C, A> where C: BorrowMut, A self._revision_number = new_value.to_string(); self } - /// The proposed action to take on the proposal. + /// The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. /// /// Sets the *update action* path property to the given value. /// @@ -6424,7 +6544,7 @@ impl<'a, C, A> ProposalPatchCall<'a, C, A> where C: BorrowMut, A: self._revision_number = new_value.to_string(); self } - /// The proposed action to take on the proposal. + /// The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. /// /// Sets the *update action* path property to the given value. /// @@ -7551,8 +7671,8 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.performance_report().list("accountId", "endDateTime", "startDateTime") -/// .page_token("sea") -/// .max_results(46) +/// .page_token("Lorem") +/// .max_results(26) /// .doit(); /// # } /// ``` @@ -7813,7 +7933,7 @@ impl<'a, C, A> PerformanceReportListCall<'a, C, A> where C: BorrowMut ProductGetCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.marketplacenotes().list("proposalId") +/// .pql_query("eirmod") /// .doit(); /// # } /// ``` @@ -8270,6 +8391,7 @@ pub struct MarketplacenoteListCall<'a, C, A> hub: &'a AdExchangeBuyer, _proposal_id: String, + _pql_query: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8291,9 +8413,12 @@ impl<'a, C, A> MarketplacenoteListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("proposalId", self._proposal_id.to_string())); - for &field in ["alt", "proposalId"].iter() { + if let Some(value) = self._pql_query { + params.push(("pqlQuery", value.to_string())); + } + for &field in ["alt", "proposalId", "pqlQuery"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8408,7 +8533,7 @@ impl<'a, C, A> MarketplacenoteListCall<'a, C, A> where C: BorrowMut MarketplacenoteListCall<'a, C, A> where C: BorrowMut MarketplacenoteListCall<'a, C, A> { + self._pql_query = 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. /// @@ -8768,7 +8900,8 @@ impl<'a, C, A> MarketplacenoteInsertCall<'a, C, A> where C: BorrowMut hub: &'a AdExchangeBuyer, _request: Account, _id: i32, + _confirm_unsafe_account_change: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8799,9 +8933,12 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "adexchangebuyer.accounts.patch", http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("id", self._id.to_string())); - for &field in ["alt", "id"].iter() { + if let Some(value) = self._confirm_unsafe_account_change { + params.push(("confirmUnsafeAccountChange", value.to_string())); + } + for &field in ["alt", "id", "confirmUnsafeAccountChange"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8950,6 +9087,13 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: self._id = new_value; self } + /// Confirmation for erasing bidder and cookie matching urls. + /// + /// Sets the *confirm unsafe account change* query property to the given value. + pub fn confirm_unsafe_account_change(mut self, new_value: bool) -> AccountPatchCall<'a, C, A> { + self._confirm_unsafe_account_change = 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. /// @@ -9230,7 +9374,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().get(-43) +/// let result = hub.accounts().get(-36) /// .doit(); /// # } /// ``` @@ -9471,7 +9615,8 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accounts().update(req, -97) +/// let result = hub.accounts().update(req, -39) +/// .confirm_unsafe_account_change(true) /// .doit(); /// # } /// ``` @@ -9481,6 +9626,7 @@ pub struct AccountUpdateCall<'a, C, A> hub: &'a AdExchangeBuyer, _request: Account, _id: i32, + _confirm_unsafe_account_change: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -9502,9 +9648,12 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "adexchangebuyer.accounts.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("id", self._id.to_string())); - for &field in ["alt", "id"].iter() { + if let Some(value) = self._confirm_unsafe_account_change { + params.push(("confirmUnsafeAccountChange", value.to_string())); + } + for &field in ["alt", "id", "confirmUnsafeAccountChange"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9653,6 +9802,13 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: self._id = new_value; self } + /// Confirmation for erasing bidder and cookie matching urls. + /// + /// Sets the *confirm unsafe account change* query property to the given value. + pub fn confirm_unsafe_account_change(mut self, new_value: bool) -> AccountUpdateCall<'a, C, A> { + self._confirm_unsafe_account_change = 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. /// @@ -9732,12 +9888,12 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().list() -/// .page_token("no") -/// .open_auction_status_filter("labore") -/// .max_results(62) -/// .deals_status_filter("dolore") -/// .add_buyer_creative_id("invidunt") -/// .add_account_id(-82) +/// .page_token("invidunt") +/// .open_auction_status_filter("aliquyam") +/// .max_results(28) +/// .deals_status_filter("Lorem") +/// .add_buyer_creative_id("sea") +/// .add_account_id(-21) /// .doit(); /// # } /// ``` @@ -10011,7 +10167,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().remove_deal(-73, "buyerCreativeId", "dealId") +/// let result = hub.creatives().remove_deal(-70, "buyerCreativeId", "dealId") /// .doit(); /// # } /// ``` @@ -10259,7 +10415,7 @@ impl<'a, C, A> CreativeRemoveDealCall<'a, C, A> where C: BorrowMut CreativeAddDealCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creatives().get(-40, "buyerCreativeId") +/// let result = hub.creatives().get(-23, "buyerCreativeId") /// .doit(); /// # } /// ``` diff --git a/gen/adexchangeseller2-cli/Cargo.toml b/gen/adexchangeseller2-cli/Cargo.toml index a9bcaddfa4..501c8e9cdb 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+20151127" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "adexchangeseller2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-adexchangeseller2/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adexchangeseller2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adexchangeseller2] diff --git a/gen/adexchangeseller2-cli/README.md b/gen/adexchangeseller2-cli/README.md index 66d8dc0311..a4fc75050a 100644 --- a/gen/adexchangeseller2-cli/README.md +++ b/gen/adexchangeseller2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Ad Exchange Seller* API at revision *20151127*. 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 *0.3.6*. ```bash adexchangeseller2 [options] diff --git a/gen/adexchangeseller2-cli/mkdocs.yml b/gen/adexchangeseller2-cli/mkdocs.yml index 5d963e4677..918e4b1008 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+20151127 +site_name: Ad Exchange Seller v0.3.6+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 d4c0f419f6..f3ad3b5453 100644 --- a/gen/adexchangeseller2-cli/src/main.rs +++ b/gen/adexchangeseller2-cli/src/main.rs @@ -1347,8 +1347,8 @@ fn main() { let mut app = App::new("adexchangeseller2") .author("Sebastian Thiel ") - .version("0.3.6+20151127") - .about("Gives Ad Exchange seller users access to their inventory and the ability to generate reports") + .version("0.3.6+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") .long("scope") diff --git a/gen/adexchangeseller2/Cargo.toml b/gen/adexchangeseller2/Cargo.toml index 7a71b9afef..dad6638f1c 100644 --- a/gen/adexchangeseller2/Cargo.toml +++ b/gen/adexchangeseller2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adexchangeseller2" -version = "0.1.14+20151127" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/adexchangeseller2/README.md b/gen/adexchangeseller2/README.md index 067271b8df..bbd3ab82cb 100644 --- a/gen/adexchangeseller2/README.md +++ b/gen/adexchangeseller2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adexchangeseller2` library allows access to all features of the *Google Ad Exchange Seller* service. -This documentation was generated from *Ad Exchange Seller* crate version *0.1.14+20151127*, where *20151127* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Ad Exchange Seller* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Ad Exchange Seller* *v2* API can be found at the [official documentation site](https://developers.google.com/ad-exchange/seller-rest/). diff --git a/gen/adexchangeseller2/src/lib.rs b/gen/adexchangeseller2/src/lib.rs index f2f0438e69..4ab00c04f4 100644 --- a/gen/adexchangeseller2/src/lib.rs +++ b/gen/adexchangeseller2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Ad Exchange Seller* crate version *0.1.14+20151127*, where *20151127* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Ad Exchange Seller* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *adexchangeseller:v2.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Ad Exchange Seller* *v2* API can be found at the //! [official documentation site](https://developers.google.com/ad-exchange/seller-rest/). diff --git a/gen/admin1_directory-cli/Cargo.toml b/gen/admin1_directory-cli/Cargo.toml index 16790b4fe3..27d939ed6a 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+20160323" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "admin1-directory" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-admin1_directory] diff --git a/gen/admin1_directory-cli/README.md b/gen/admin1_directory-cli/README.md index f5ab0c3866..5f9832ab84 100644 --- a/gen/admin1_directory-cli/README.md +++ b/gen/admin1_directory-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *directory* API at revision *20160323*. The CLI is at version *0.3.6*. +This documentation was generated from the *directory* API at revision *20160824*. The CLI is at version *0.3.6*. ```bash admin1-directory [options] diff --git a/gen/admin1_directory-cli/mkdocs.yml b/gen/admin1_directory-cli/mkdocs.yml index e114dc4ec9..86e1a58f55 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+20160323 +site_name: directory v0.3.6+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 4b4547263c..8ad2c60589 100644 --- a/gen/admin1_directory-cli/src/main.rs +++ b/gen/admin1_directory-cli/src/main.rs @@ -2114,6 +2114,7 @@ impl<'n> Engine<'n> { 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 })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2121,7 +2122,7 @@ impl<'n> Engine<'n> { "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "status", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2266,6 +2267,7 @@ impl<'n> Engine<'n> { 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 })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2273,7 +2275,7 @@ impl<'n> Engine<'n> { "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "status", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2356,6 +2358,7 @@ impl<'n> Engine<'n> { 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 })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2363,7 +2366,7 @@ impl<'n> Engine<'n> { "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "etag", "id", "kind", "role", "status", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -7428,7 +7431,7 @@ fn main() { ("customers", "methods: 'get', 'patch' and 'update'", vec![ ("get", - Some(r##"Retrives a customer."##), + Some(r##"Retrieves a customer."##), "Details at http://byron.github.io/google-apis-rs/google_admin1_directory_cli/customers_get", vec![ (Some(r##"customer-key"##), @@ -7634,7 +7637,7 @@ fn main() { Some(true)), ]), ("get", - Some(r##"Retrives a domain of the customer."##), + Some(r##"Retrieves a domain of the customer."##), "Details at http://byron.github.io/google-apis-rs/google_admin1_directory_cli/domains_get", vec![ (Some(r##"customer"##), @@ -9680,7 +9683,7 @@ fn main() { let mut app = App::new("admin1-directory") .author("Sebastian Thiel ") - .version("0.3.6+20160323") + .version("0.3.6+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_directory/Cargo.toml b/gen/admin1_directory/Cargo.toml index 42027a8e21..f60cda28a8 100644 --- a/gen/admin1_directory/Cargo.toml +++ b/gen/admin1_directory/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_directory" -version = "0.1.14+20160323" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/admin1_directory/README.md b/gen/admin1_directory/README.md index 7d8a82593b..9078e3c28e 100644 --- a/gen/admin1_directory/README.md +++ b/gen/admin1_directory/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-admin1_directory` library allows access to all features of the *Google directory* service. -This documentation was generated from *directory* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *directory* crate version *0.1.14+20160824*, where *20160824* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *directory* *v1_directory* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/directory/). diff --git a/gen/admin1_directory/src/lib.rs b/gen/admin1_directory/src/lib.rs index 5d8351d22e..7a8a4da88e 100644 --- a/gen/admin1_directory/src/lib.rs +++ b/gen/admin1_directory/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *directory* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *directory* crate version *0.1.14+20160824*, where *20160824* is the exact revision of the *admin:directory_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *directory* *v1_directory* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/directory/). diff --git a/gen/admin1_directory/src/lib.rs.in b/gen/admin1_directory/src/lib.rs.in index 5238dfed5c..e2d9dfe11e 100644 --- a/gen/admin1_directory/src/lib.rs.in +++ b/gen/admin1_directory/src/lib.rs.in @@ -518,6 +518,8 @@ impl ResponseResult for Privileges {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Member { + /// Status of member (Immutable) + pub status: Option, /// Kind of resource this is. pub kind: Option, /// ETag of the resource. @@ -1962,7 +1964,7 @@ pub struct Aliases { /// ETag of the resource. pub etag: Option, /// List of alias objects. - pub aliases: Option>, + pub aliases: Option>, } impl ResponseResult for Aliases {} @@ -2171,7 +2173,7 @@ impl<'a, C, A> CustomerMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrives a customer. + /// Retrieves a customer. /// /// # Arguments /// @@ -3765,7 +3767,7 @@ impl<'a, C, A> DomainMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrives a domain of the customer. + /// Retrieves a domain of the customer. /// /// # Arguments /// @@ -5582,7 +5584,7 @@ impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut, A: } -/// Retrives a customer. +/// Retrieves a customer. /// /// A builder for the *get* method supported by a *customer* resource. /// It is not used directly, but through a `CustomerMethods` instance. @@ -19715,7 +19717,7 @@ impl<'a, C, A> DomainListCall<'a, C, A> where C: BorrowMut, A: oa } -/// Retrives a domain of the customer. +/// Retrieves a domain of the customer. /// /// A builder for the *get* method supported by a *domain* resource. /// It is not used directly, but through a `DomainMethods` instance. diff --git a/gen/admin1_reports-cli/Cargo.toml b/gen/admin1_reports-cli/Cargo.toml index 9f3bf82900..f29c021d46 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+20151113" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "admin1-reports" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-admin1_reports] diff --git a/gen/admin1_reports-cli/README.md b/gen/admin1_reports-cli/README.md index 4545f07da2..e3111971cf 100644 --- a/gen/admin1_reports-cli/README.md +++ b/gen/admin1_reports-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *reports* API at revision *20151113*. The CLI is at version *0.3.6*. +This documentation was generated from the *reports* API at revision *20160704*. The CLI is at version *0.3.6*. ```bash admin1-reports [options] diff --git a/gen/admin1_reports-cli/mkdocs.yml b/gen/admin1_reports-cli/mkdocs.yml index a5aa17f55c..5977a6d002 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+20151113 +site_name: reports v0.3.6+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 f67dcc724e..5efde40353 100644 --- a/gen/admin1_reports-cli/src/main.rs +++ b/gen/admin1_reports-cli/src/main.rs @@ -735,8 +735,8 @@ fn main() { let mut app = App::new("admin1-reports") .author("Sebastian Thiel ") - .version("0.3.6+20151113") - .about("Allows the administrators of Google Apps customers to fetch reports about the usage, collaboration, security and risk for their users.") + .version("0.3.6+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") .long("scope") diff --git a/gen/admin1_reports/Cargo.toml b/gen/admin1_reports/Cargo.toml index 664c802ef1..a59cea7daf 100644 --- a/gen/admin1_reports/Cargo.toml +++ b/gen/admin1_reports/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-admin1_reports" -version = "0.1.14+20151113" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/admin1_reports/README.md b/gen/admin1_reports/README.md index dba376b04c..dfacd26d1e 100644 --- a/gen/admin1_reports/README.md +++ b/gen/admin1_reports/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-admin1_reports` library allows access to all features of the *Google reports* service. -This documentation was generated from *reports* crate version *0.1.14+20151113*, where *20151113* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *reports* crate version *0.1.14+20160704*, where *20160704* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *reports* *v1_reports* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/reports/). diff --git a/gen/admin1_reports/src/lib.rs b/gen/admin1_reports/src/lib.rs index 3f35c406b1..5d9e8ccd8e 100644 --- a/gen/admin1_reports/src/lib.rs +++ b/gen/admin1_reports/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *reports* crate version *0.1.14+20151113*, where *20151113* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *reports* crate version *0.1.14+20160704*, where *20160704* is the exact revision of the *admin:reports_v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *reports* *v1_reports* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/reports/). diff --git a/gen/adsense1d4-cli/Cargo.toml b/gen/adsense1d4-cli/Cargo.toml index a1edb4571e..8f5c266196 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+20160405" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "adsense1d4" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-adsense1d4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adsense1d4/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adsense1d4] diff --git a/gen/adsense1d4-cli/README.md b/gen/adsense1d4-cli/README.md index 5837ac200d..dceda8a8a3 100644 --- a/gen/adsense1d4-cli/README.md +++ b/gen/adsense1d4-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *AdSense* API at revision *20160405*. The CLI is at version *0.3.6*. +This documentation was generated from the *AdSense* API at revision *20160907*. The CLI is at version *0.3.6*. ```bash adsense1d4 [options] diff --git a/gen/adsense1d4-cli/mkdocs.yml b/gen/adsense1d4-cli/mkdocs.yml index c4e3a0b6b0..84c730de81 100644 --- a/gen/adsense1d4-cli/mkdocs.yml +++ b/gen/adsense1d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense v0.3.6+20160405 +site_name: AdSense v0.3.6+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 48bd086510..d25b909428 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+20160405") + .version("0.3.6+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/adsense1d4/Cargo.toml b/gen/adsense1d4/Cargo.toml index a848030cdb..cadf9794e1 100644 --- a/gen/adsense1d4/Cargo.toml +++ b/gen/adsense1d4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsense1d4" -version = "0.1.14+20160405" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/adsense1d4/README.md b/gen/adsense1d4/README.md index e3c0854a1b..e6edc25c18 100644 --- a/gen/adsense1d4/README.md +++ b/gen/adsense1d4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adsense1d4` library allows access to all features of the *Google AdSense* service. -This documentation was generated from *AdSense* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *AdSense* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *AdSense* *v1d4* API can be found at the [official documentation site](https://developers.google.com/adsense/management/). diff --git a/gen/adsense1d4/src/lib.rs b/gen/adsense1d4/src/lib.rs index f15f67ae79..76b4e9b363 100644 --- a/gen/adsense1d4/src/lib.rs +++ b/gen/adsense1d4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *AdSense* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *AdSense* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *adsense:v1.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *AdSense* *v1d4* API can be found at the //! [official documentation site](https://developers.google.com/adsense/management/). diff --git a/gen/adsensehost4d1-cli/Cargo.toml b/gen/adsensehost4d1-cli/Cargo.toml index 02ef37d1a9..97dbf28a25 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+20160405" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "adsensehost4d1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-adsensehost4d1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-adsensehost4d1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-adsensehost4d1] diff --git a/gen/adsensehost4d1-cli/README.md b/gen/adsensehost4d1-cli/README.md index 1bba3b7c5e..225d1e601d 100644 --- a/gen/adsensehost4d1-cli/README.md +++ b/gen/adsensehost4d1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *AdSense Host* API at revision *20160405*. 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 *0.3.6*. ```bash adsensehost4d1 [options] diff --git a/gen/adsensehost4d1-cli/mkdocs.yml b/gen/adsensehost4d1-cli/mkdocs.yml index e93a4fad7c..78a0807f6b 100644 --- a/gen/adsensehost4d1-cli/mkdocs.yml +++ b/gen/adsensehost4d1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: AdSense Host v0.3.6+20160405 +site_name: AdSense Host v0.3.6+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 c569c8092a..9360dc3cba 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+20160405") + .version("0.3.6+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/adsensehost4d1/Cargo.toml b/gen/adsensehost4d1/Cargo.toml index 10d2e12a75..56e5ea021c 100644 --- a/gen/adsensehost4d1/Cargo.toml +++ b/gen/adsensehost4d1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-adsensehost4d1" -version = "0.1.14+20160405" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/adsensehost4d1/README.md b/gen/adsensehost4d1/README.md index 60d7b5c3f3..d248429d7b 100644 --- a/gen/adsensehost4d1/README.md +++ b/gen/adsensehost4d1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-adsensehost4d1` library allows access to all features of the *Google AdSense Host* service. -This documentation was generated from *AdSense Host* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *AdSense Host* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *AdSense Host* *v4d1* API can be found at the [official documentation site](https://developers.google.com/adsense/host/). diff --git a/gen/adsensehost4d1/src/lib.rs b/gen/adsensehost4d1/src/lib.rs index e4b046a133..f3aea69f56 100644 --- a/gen/adsensehost4d1/src/lib.rs +++ b/gen/adsensehost4d1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *AdSense Host* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *AdSense Host* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *AdSense Host* *v4d1* API can be found at the //! [official documentation site](https://developers.google.com/adsense/host/). diff --git a/gen/analytics3-cli/Cargo.toml b/gen/analytics3-cli/Cargo.toml index 2e85c35f6a..604a1d783c 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+20160308" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "analytics3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-analytics3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-analytics3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-analytics3] diff --git a/gen/analytics3-cli/README.md b/gen/analytics3-cli/README.md index c657cc38b9..faa48f3cb0 100644 --- a/gen/analytics3-cli/README.md +++ b/gen/analytics3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *analytics* API at revision *20160308*. The CLI is at version *0.3.6*. +This documentation was generated from the *analytics* API at revision *20160805*. The CLI is at version *0.3.6*. ```bash analytics3 [options] @@ -83,6 +83,11 @@ analytics3 [options] profiles-list [-p ]... [-o ] profiles-patch (-r )... [-p ]... [-o ] profiles-update (-r )... [-p ]... [-o ] + remarketing-audience-get [-p ]... [-o ] + remarketing-audience-insert (-r )... [-p ]... [-o ] + remarketing-audience-list [-p ]... [-o ] + remarketing-audience-patch (-r )... [-p ]... [-o ] + remarketing-audience-update (-r )... [-p ]... [-o ] segments-list [-p ]... [-o ] unsampled-reports-delete [-p ]... unsampled-reports-get [-p ]... [-o ] diff --git a/gen/analytics3-cli/mkdocs.yml b/gen/analytics3-cli/mkdocs.yml index 3b705bccbf..cba0132e25 100644 --- a/gen/analytics3-cli/mkdocs.yml +++ b/gen/analytics3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: analytics v0.3.6+20160308 +site_name: analytics v0.3.6+20160805 site_url: http://byron.github.io/google-apis-rs/google-analytics3-cli site_description: Write integrating applications with bcore @@ -62,6 +62,11 @@ pages: - ['management_profiles-list.md', 'Management', 'Profiles List'] - ['management_profiles-patch.md', 'Management', 'Profiles Patch'] - ['management_profiles-update.md', 'Management', 'Profiles Update'] +- ['management_remarketing-audience-get.md', 'Management', 'Remarketing Audience Get'] +- ['management_remarketing-audience-insert.md', 'Management', 'Remarketing Audience Insert'] +- ['management_remarketing-audience-list.md', 'Management', 'Remarketing Audience List'] +- ['management_remarketing-audience-patch.md', 'Management', 'Remarketing Audience Patch'] +- ['management_remarketing-audience-update.md', 'Management', 'Remarketing Audience Update'] - ['management_segments-list.md', 'Management', 'Segments List'] - ['management_unsampled-reports-delete.md', 'Management', 'Unsampled Reports Delete'] - ['management_unsampled-reports-get.md', 'Management', 'Unsampled Reports Get'] diff --git a/gen/analytics3-cli/src/main.rs b/gen/analytics3-cli/src/main.rs index 5d7201e59e..b4d83cae08 100644 --- a/gen/analytics3-cli/src/main.rs +++ b/gen/analytics3-cli/src/main.rs @@ -4328,6 +4328,441 @@ impl<'n> Engine<'n> { } } + fn _management_remarketing_audience_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.management().remarketing_audience_get(opt.value_of("account-id").unwrap_or(""), opt.value_of("web-property-id").unwrap_or(""), opt.value_of("remarketing-audience-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 _management_remarketing_audience_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 })), + "created" => Some(("created", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "updated" => Some(("updated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "internal-web-property-id" => Some(("internalWebPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "linked-views" => Some(("linkedViews", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "state-based-audience-definition.include-conditions.days-to-look-back" => Some(("stateBasedAudienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.segment" => Some(("stateBasedAudienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.kind" => Some(("stateBasedAudienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.is-smart-list" => Some(("stateBasedAudienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.membership-duration-days" => Some(("stateBasedAudienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.segment" => Some(("stateBasedAudienceDefinition.excludeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.exclusion-duration" => Some(("stateBasedAudienceDefinition.excludeConditions.exclusionDuration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-type" => Some(("audienceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "web-property-id" => Some(("webPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.days-to-look-back" => Some(("audienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.segment" => Some(("audienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.kind" => Some(("audienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.is-smart-list" => Some(("audienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.membership-duration-days" => Some(("audienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "audience-definition", "audience-type", "created", "days-to-look-back", "description", "exclude-conditions", "exclusion-duration", "id", "include-conditions", "internal-web-property-id", "is-smart-list", "kind", "linked-views", "membership-duration-days", "name", "segment", "state-based-audience-definition", "updated", "web-property-id"]); + 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::RemarketingAudience = json::value::from_value(object).unwrap(); + let mut call = self.hub.management().remarketing_audience_insert(request, opt.value_of("account-id").unwrap_or(""), opt.value_of("web-property-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 _management_remarketing_audience_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.management().remarketing_audience_list(opt.value_of("account-id").unwrap_or(""), opt.value_of("web-property-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 { + "type" => { + call = call.type_(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(["start-index", "max-results", "type"].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 _management_remarketing_audience_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 })), + "created" => Some(("created", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "updated" => Some(("updated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "internal-web-property-id" => Some(("internalWebPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "linked-views" => Some(("linkedViews", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "state-based-audience-definition.include-conditions.days-to-look-back" => Some(("stateBasedAudienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.segment" => Some(("stateBasedAudienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.kind" => Some(("stateBasedAudienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.is-smart-list" => Some(("stateBasedAudienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.membership-duration-days" => Some(("stateBasedAudienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.segment" => Some(("stateBasedAudienceDefinition.excludeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.exclusion-duration" => Some(("stateBasedAudienceDefinition.excludeConditions.exclusionDuration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-type" => Some(("audienceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "web-property-id" => Some(("webPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.days-to-look-back" => Some(("audienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.segment" => Some(("audienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.kind" => Some(("audienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.is-smart-list" => Some(("audienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.membership-duration-days" => Some(("audienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "audience-definition", "audience-type", "created", "days-to-look-back", "description", "exclude-conditions", "exclusion-duration", "id", "include-conditions", "internal-web-property-id", "is-smart-list", "kind", "linked-views", "membership-duration-days", "name", "segment", "state-based-audience-definition", "updated", "web-property-id"]); + 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::RemarketingAudience = json::value::from_value(object).unwrap(); + let mut call = self.hub.management().remarketing_audience_patch(request, opt.value_of("account-id").unwrap_or(""), opt.value_of("web-property-id").unwrap_or(""), opt.value_of("remarketing-audience-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 _management_remarketing_audience_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 })), + "created" => Some(("created", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "updated" => Some(("updated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "internal-web-property-id" => Some(("internalWebPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "linked-views" => Some(("linkedViews", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "state-based-audience-definition.include-conditions.days-to-look-back" => Some(("stateBasedAudienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.segment" => Some(("stateBasedAudienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.kind" => Some(("stateBasedAudienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.is-smart-list" => Some(("stateBasedAudienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "state-based-audience-definition.include-conditions.membership-duration-days" => Some(("stateBasedAudienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.segment" => Some(("stateBasedAudienceDefinition.excludeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state-based-audience-definition.exclude-conditions.exclusion-duration" => Some(("stateBasedAudienceDefinition.excludeConditions.exclusionDuration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-type" => Some(("audienceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "web-property-id" => Some(("webPropertyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.days-to-look-back" => Some(("audienceDefinition.includeConditions.daysToLookBack", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.segment" => Some(("audienceDefinition.includeConditions.segment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.kind" => Some(("audienceDefinition.includeConditions.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.is-smart-list" => Some(("audienceDefinition.includeConditions.isSmartList", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-definition.include-conditions.membership-duration-days" => Some(("audienceDefinition.includeConditions.membershipDurationDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "audience-definition", "audience-type", "created", "days-to-look-back", "description", "exclude-conditions", "exclusion-duration", "id", "include-conditions", "internal-web-property-id", "is-smart-list", "kind", "linked-views", "membership-duration-days", "name", "segment", "state-based-audience-definition", "updated", "web-property-id"]); + 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::RemarketingAudience = json::value::from_value(object).unwrap(); + let mut call = self.hub.management().remarketing_audience_update(request, opt.value_of("account-id").unwrap_or(""), opt.value_of("web-property-id").unwrap_or(""), opt.value_of("remarketing-audience-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 _management_segments_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.management().segments_list(); @@ -6441,6 +6876,21 @@ impl<'n> Engine<'n> { ("profiles-update", Some(opt)) => { call_result = self._management_profiles_update(opt, dry_run, &mut err); }, + ("remarketing-audience-get", Some(opt)) => { + call_result = self._management_remarketing_audience_get(opt, dry_run, &mut err); + }, + ("remarketing-audience-insert", Some(opt)) => { + call_result = self._management_remarketing_audience_insert(opt, dry_run, &mut err); + }, + ("remarketing-audience-list", Some(opt)) => { + call_result = self._management_remarketing_audience_list(opt, dry_run, &mut err); + }, + ("remarketing-audience-patch", Some(opt)) => { + call_result = self._management_remarketing_audience_patch(opt, dry_run, &mut err); + }, + ("remarketing-audience-update", Some(opt)) => { + call_result = self._management_remarketing_audience_update(opt, dry_run, &mut err); + }, ("segments-list", Some(opt)) => { call_result = self._management_segments_list(opt, dry_run, &mut err); }, @@ -6735,7 +7185,7 @@ fn main() { ]), ]), - ("management", "methods: 'account-summaries-list', 'account-user-links-delete', 'account-user-links-insert', 'account-user-links-list', 'account-user-links-update', 'accounts-list', 'custom-data-sources-list', 'custom-dimensions-get', 'custom-dimensions-insert', 'custom-dimensions-list', 'custom-dimensions-patch', 'custom-dimensions-update', 'custom-metrics-get', 'custom-metrics-insert', 'custom-metrics-list', 'custom-metrics-patch', 'custom-metrics-update', 'experiments-delete', 'experiments-get', 'experiments-insert', 'experiments-list', 'experiments-patch', 'experiments-update', 'filters-delete', 'filters-get', 'filters-insert', 'filters-list', 'filters-patch', 'filters-update', 'goals-get', 'goals-insert', 'goals-list', 'goals-patch', 'goals-update', 'profile-filter-links-delete', 'profile-filter-links-get', 'profile-filter-links-insert', 'profile-filter-links-list', 'profile-filter-links-patch', 'profile-filter-links-update', 'profile-user-links-delete', 'profile-user-links-insert', 'profile-user-links-list', 'profile-user-links-update', 'profiles-delete', 'profiles-get', 'profiles-insert', 'profiles-list', 'profiles-patch', 'profiles-update', 'segments-list', 'unsampled-reports-delete', 'unsampled-reports-get', 'unsampled-reports-insert', 'unsampled-reports-list', 'uploads-delete-upload-data', 'uploads-get', 'uploads-list', 'uploads-upload-data', 'web-property-ad-words-links-delete', 'web-property-ad-words-links-get', 'web-property-ad-words-links-insert', 'web-property-ad-words-links-list', 'web-property-ad-words-links-patch', 'web-property-ad-words-links-update', 'webproperties-get', 'webproperties-insert', 'webproperties-list', 'webproperties-patch', 'webproperties-update', 'webproperty-user-links-delete', 'webproperty-user-links-insert', 'webproperty-user-links-list' and 'webproperty-user-links-update'", vec![ + ("management", "methods: 'account-summaries-list', 'account-user-links-delete', 'account-user-links-insert', 'account-user-links-list', 'account-user-links-update', 'accounts-list', 'custom-data-sources-list', 'custom-dimensions-get', 'custom-dimensions-insert', 'custom-dimensions-list', 'custom-dimensions-patch', 'custom-dimensions-update', 'custom-metrics-get', 'custom-metrics-insert', 'custom-metrics-list', 'custom-metrics-patch', 'custom-metrics-update', 'experiments-delete', 'experiments-get', 'experiments-insert', 'experiments-list', 'experiments-patch', 'experiments-update', 'filters-delete', 'filters-get', 'filters-insert', 'filters-list', 'filters-patch', 'filters-update', 'goals-get', 'goals-insert', 'goals-list', 'goals-patch', 'goals-update', 'profile-filter-links-delete', 'profile-filter-links-get', 'profile-filter-links-insert', 'profile-filter-links-list', 'profile-filter-links-patch', 'profile-filter-links-update', 'profile-user-links-delete', 'profile-user-links-insert', 'profile-user-links-list', 'profile-user-links-update', 'profiles-delete', 'profiles-get', 'profiles-insert', 'profiles-list', 'profiles-patch', 'profiles-update', 'remarketing-audience-get', 'remarketing-audience-insert', 'remarketing-audience-list', 'remarketing-audience-patch', 'remarketing-audience-update', 'segments-list', 'unsampled-reports-delete', 'unsampled-reports-get', 'unsampled-reports-insert', 'unsampled-reports-list', 'uploads-delete-upload-data', 'uploads-get', 'uploads-list', 'uploads-upload-data', 'web-property-ad-words-links-delete', 'web-property-ad-words-links-get', 'web-property-ad-words-links-insert', 'web-property-ad-words-links-list', 'web-property-ad-words-links-patch', 'web-property-ad-words-links-update', 'webproperties-get', 'webproperties-insert', 'webproperties-list', 'webproperties-patch', 'webproperties-update', 'webproperty-user-links-delete', 'webproperty-user-links-insert', 'webproperty-user-links-list' and 'webproperty-user-links-update'", vec![ ("account-summaries-list", Some(r##"Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access."##), "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_account-summaries-list", @@ -8466,6 +8916,182 @@ fn main() { 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)), + ]), + ("remarketing-audience-get", + Some(r##"Gets remarketing audiences to which the user has access."##), + "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_remarketing-audience-get", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"Account ID for the remarketing audience to retrieve."##), + Some(true), + Some(false)), + + (Some(r##"web-property-id"##), + None, + Some(r##"Web property ID for the remarketing audience to retrieve."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-audience-id"##), + None, + Some(r##"The ID to retrieve the Remarketing Audience 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)), + ]), + ("remarketing-audience-insert", + Some(r##"Creates a new remarketing audiences."##), + "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_remarketing-audience-insert", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"Account ID to create the remarketing audience for."##), + Some(true), + Some(false)), + + (Some(r##"web-property-id"##), + None, + Some(r##"Web property ID to create the remarketing audience 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)), + ]), + ("remarketing-audience-list", + Some(r##"Lists remarketing audiences to which the user has access."##), + "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_remarketing-audience-list", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"Account ID for the remarketing audience to retrieve."##), + Some(true), + Some(false)), + + (Some(r##"web-property-id"##), + None, + Some(r##"Web property ID for the remarketing audience to retrieve."##), + 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)), + ]), + ("remarketing-audience-patch", + Some(r##"Updates an existing remarketing audiences. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_remarketing-audience-patch", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"Account ID for the remarketing audience to update."##), + Some(true), + Some(false)), + + (Some(r##"web-property-id"##), + None, + Some(r##"Web property ID for the remarketing audience to update."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-audience-id"##), + None, + Some(r##"Remarketing audience ID of the remarketing audience 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)), + ]), + ("remarketing-audience-update", + Some(r##"Updates an existing remarketing audiences."##), + "Details at http://byron.github.io/google-apis-rs/google_analytics3_cli/management_remarketing-audience-update", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"Account ID for the remarketing audience to update."##), + Some(true), + Some(false)), + + (Some(r##"web-property-id"##), + None, + Some(r##"Web property ID for the remarketing audience to update."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-audience-id"##), + None, + Some(r##"Remarketing audience ID of the remarketing audience 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"##), @@ -9320,7 +9946,7 @@ fn main() { let mut app = App::new("analytics3") .author("Sebastian Thiel ") - .version("0.3.6+20160308") + .version("0.3.6+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/analytics3/Cargo.toml b/gen/analytics3/Cargo.toml index fc817d185e..87115208d7 100644 --- a/gen/analytics3/Cargo.toml +++ b/gen/analytics3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-analytics3" -version = "0.1.14+20160308" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/analytics3/README.md b/gen/analytics3/README.md index d4cc93186b..18b3391a9e 100644 --- a/gen/analytics3/README.md +++ b/gen/analytics3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-analytics3` library allows access to all features of the *Google analytics* service. -This documentation was generated from *analytics* crate version *0.1.14+20160308*, where *20160308* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *analytics* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *analytics* *v3* API can be found at the [official documentation site](https://developers.google.com/analytics/). @@ -16,7 +16,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * data * [*ga get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.DataGaGetCall.html), [*mcf get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.DataMcfGetCall.html) and [*realtime get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.DataRealtimeGetCall.html) * management - * [*account summaries list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountSummaryListCall.html), [*account user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkDeleteCall.html), [*account user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkInsertCall.html), [*account user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkListCall.html), [*account user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkUpdateCall.html), [*accounts list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountListCall.html), [*custom data sources list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDataSourceListCall.html), [*custom dimensions get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionGetCall.html), [*custom dimensions insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionInsertCall.html), [*custom dimensions list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionListCall.html), [*custom dimensions patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionPatchCall.html), [*custom dimensions update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionUpdateCall.html), [*custom metrics get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricGetCall.html), [*custom metrics insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricInsertCall.html), [*custom metrics list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricListCall.html), [*custom metrics patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricPatchCall.html), [*custom metrics update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricUpdateCall.html), [*experiments delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentDeleteCall.html), [*experiments get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentGetCall.html), [*experiments insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentInsertCall.html), [*experiments list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentListCall.html), [*experiments patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentPatchCall.html), [*experiments update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentUpdateCall.html), [*filters delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterDeleteCall.html), [*filters get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterGetCall.html), [*filters insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterInsertCall.html), [*filters list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterListCall.html), [*filters patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterPatchCall.html), [*filters update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterUpdateCall.html), [*goals get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalGetCall.html), [*goals insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalInsertCall.html), [*goals list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalListCall.html), [*goals patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalPatchCall.html), [*goals update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalUpdateCall.html), [*profile filter links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkDeleteCall.html), [*profile filter links get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkGetCall.html), [*profile filter links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkInsertCall.html), [*profile filter links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkListCall.html), [*profile filter links patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkPatchCall.html), [*profile filter links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkUpdateCall.html), [*profile user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkDeleteCall.html), [*profile user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkInsertCall.html), [*profile user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkListCall.html), [*profile user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkUpdateCall.html), [*profiles delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileDeleteCall.html), [*profiles get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileGetCall.html), [*profiles insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileInsertCall.html), [*profiles list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileListCall.html), [*profiles patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfilePatchCall.html), [*profiles update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUpdateCall.html), [*segments list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementSegmentListCall.html), [*unsampled reports delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportDeleteCall.html), [*unsampled reports get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportGetCall.html), [*unsampled reports insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportInsertCall.html), [*unsampled reports list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportListCall.html), [*uploads delete upload data*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadDeleteUploadDataCall.html), [*uploads get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadGetCall.html), [*uploads list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadListCall.html), [*uploads upload data*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadUploadDataCall.html), [*web property ad words links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkDeleteCall.html), [*web property ad words links get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkGetCall.html), [*web property ad words links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkInsertCall.html), [*web property ad words links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkListCall.html), [*web property ad words links patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkPatchCall.html), [*web property ad words links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkUpdateCall.html), [*webproperties get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyGetCall.html), [*webproperties insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyInsertCall.html), [*webproperties list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyListCall.html), [*webproperties patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyPatchCall.html), [*webproperties update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUpdateCall.html), [*webproperty user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkDeleteCall.html), [*webproperty user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkInsertCall.html), [*webproperty user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkListCall.html) and [*webproperty user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkUpdateCall.html) + * [*account summaries list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountSummaryListCall.html), [*account user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkDeleteCall.html), [*account user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkInsertCall.html), [*account user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkListCall.html), [*account user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountUserLinkUpdateCall.html), [*accounts list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementAccountListCall.html), [*custom data sources list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDataSourceListCall.html), [*custom dimensions get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionGetCall.html), [*custom dimensions insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionInsertCall.html), [*custom dimensions list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionListCall.html), [*custom dimensions patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionPatchCall.html), [*custom dimensions update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomDimensionUpdateCall.html), [*custom metrics get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricGetCall.html), [*custom metrics insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricInsertCall.html), [*custom metrics list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricListCall.html), [*custom metrics patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricPatchCall.html), [*custom metrics update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementCustomMetricUpdateCall.html), [*experiments delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentDeleteCall.html), [*experiments get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentGetCall.html), [*experiments insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentInsertCall.html), [*experiments list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentListCall.html), [*experiments patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentPatchCall.html), [*experiments update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementExperimentUpdateCall.html), [*filters delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterDeleteCall.html), [*filters get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterGetCall.html), [*filters insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterInsertCall.html), [*filters list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterListCall.html), [*filters patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterPatchCall.html), [*filters update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementFilterUpdateCall.html), [*goals get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalGetCall.html), [*goals insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalInsertCall.html), [*goals list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalListCall.html), [*goals patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalPatchCall.html), [*goals update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementGoalUpdateCall.html), [*profile filter links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkDeleteCall.html), [*profile filter links get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkGetCall.html), [*profile filter links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkInsertCall.html), [*profile filter links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkListCall.html), [*profile filter links patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkPatchCall.html), [*profile filter links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileFilterLinkUpdateCall.html), [*profile user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkDeleteCall.html), [*profile user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkInsertCall.html), [*profile user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkListCall.html), [*profile user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUserLinkUpdateCall.html), [*profiles delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileDeleteCall.html), [*profiles get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileGetCall.html), [*profiles insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileInsertCall.html), [*profiles list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileListCall.html), [*profiles patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfilePatchCall.html), [*profiles update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementProfileUpdateCall.html), [*remarketing audience get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementRemarketingAudienceGetCall.html), [*remarketing audience insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementRemarketingAudienceInsertCall.html), [*remarketing audience list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementRemarketingAudienceListCall.html), [*remarketing audience patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementRemarketingAudiencePatchCall.html), [*remarketing audience update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementRemarketingAudienceUpdateCall.html), [*segments list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementSegmentListCall.html), [*unsampled reports delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportDeleteCall.html), [*unsampled reports get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportGetCall.html), [*unsampled reports insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportInsertCall.html), [*unsampled reports list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUnsampledReportListCall.html), [*uploads delete upload data*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadDeleteUploadDataCall.html), [*uploads get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadGetCall.html), [*uploads list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadListCall.html), [*uploads upload data*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementUploadUploadDataCall.html), [*web property ad words links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkDeleteCall.html), [*web property ad words links get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkGetCall.html), [*web property ad words links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkInsertCall.html), [*web property ad words links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkListCall.html), [*web property ad words links patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkPatchCall.html), [*web property ad words links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebPropertyAdWordsLinkUpdateCall.html), [*webproperties get*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyGetCall.html), [*webproperties insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyInsertCall.html), [*webproperties list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyListCall.html), [*webproperties patch*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyPatchCall.html), [*webproperties update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUpdateCall.html), [*webproperty user links delete*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkDeleteCall.html), [*webproperty user links insert*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkInsertCall.html), [*webproperty user links list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkListCall.html) and [*webproperty user links update*](http://byron.github.io/google-apis-rs/google_analytics3/struct.ManagementWebpropertyUserLinkUpdateCall.html) * metadata * [*columns list*](http://byron.github.io/google-apis-rs/google_analytics3/struct.MetadataColumnListCall.html) * provisioning diff --git a/gen/analytics3/src/lib.rs b/gen/analytics3/src/lib.rs index 81ae83fa03..b917d4451b 100644 --- a/gen/analytics3/src/lib.rs +++ b/gen/analytics3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *analytics* crate version *0.1.14+20160308*, where *20160308* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *analytics* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *analytics:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *analytics* *v3* API can be found at the //! [official documentation site](https://developers.google.com/analytics/). @@ -14,7 +14,7 @@ //! * data //! * [*ga get*](struct.DataGaGetCall.html), [*mcf get*](struct.DataMcfGetCall.html) and [*realtime get*](struct.DataRealtimeGetCall.html) //! * management -//! * [*account summaries list*](struct.ManagementAccountSummaryListCall.html), [*account user links delete*](struct.ManagementAccountUserLinkDeleteCall.html), [*account user links insert*](struct.ManagementAccountUserLinkInsertCall.html), [*account user links list*](struct.ManagementAccountUserLinkListCall.html), [*account user links update*](struct.ManagementAccountUserLinkUpdateCall.html), [*accounts list*](struct.ManagementAccountListCall.html), [*custom data sources list*](struct.ManagementCustomDataSourceListCall.html), [*custom dimensions get*](struct.ManagementCustomDimensionGetCall.html), [*custom dimensions insert*](struct.ManagementCustomDimensionInsertCall.html), [*custom dimensions list*](struct.ManagementCustomDimensionListCall.html), [*custom dimensions patch*](struct.ManagementCustomDimensionPatchCall.html), [*custom dimensions update*](struct.ManagementCustomDimensionUpdateCall.html), [*custom metrics get*](struct.ManagementCustomMetricGetCall.html), [*custom metrics insert*](struct.ManagementCustomMetricInsertCall.html), [*custom metrics list*](struct.ManagementCustomMetricListCall.html), [*custom metrics patch*](struct.ManagementCustomMetricPatchCall.html), [*custom metrics update*](struct.ManagementCustomMetricUpdateCall.html), [*experiments delete*](struct.ManagementExperimentDeleteCall.html), [*experiments get*](struct.ManagementExperimentGetCall.html), [*experiments insert*](struct.ManagementExperimentInsertCall.html), [*experiments list*](struct.ManagementExperimentListCall.html), [*experiments patch*](struct.ManagementExperimentPatchCall.html), [*experiments update*](struct.ManagementExperimentUpdateCall.html), [*filters delete*](struct.ManagementFilterDeleteCall.html), [*filters get*](struct.ManagementFilterGetCall.html), [*filters insert*](struct.ManagementFilterInsertCall.html), [*filters list*](struct.ManagementFilterListCall.html), [*filters patch*](struct.ManagementFilterPatchCall.html), [*filters update*](struct.ManagementFilterUpdateCall.html), [*goals get*](struct.ManagementGoalGetCall.html), [*goals insert*](struct.ManagementGoalInsertCall.html), [*goals list*](struct.ManagementGoalListCall.html), [*goals patch*](struct.ManagementGoalPatchCall.html), [*goals update*](struct.ManagementGoalUpdateCall.html), [*profile filter links delete*](struct.ManagementProfileFilterLinkDeleteCall.html), [*profile filter links get*](struct.ManagementProfileFilterLinkGetCall.html), [*profile filter links insert*](struct.ManagementProfileFilterLinkInsertCall.html), [*profile filter links list*](struct.ManagementProfileFilterLinkListCall.html), [*profile filter links patch*](struct.ManagementProfileFilterLinkPatchCall.html), [*profile filter links update*](struct.ManagementProfileFilterLinkUpdateCall.html), [*profile user links delete*](struct.ManagementProfileUserLinkDeleteCall.html), [*profile user links insert*](struct.ManagementProfileUserLinkInsertCall.html), [*profile user links list*](struct.ManagementProfileUserLinkListCall.html), [*profile user links update*](struct.ManagementProfileUserLinkUpdateCall.html), [*profiles delete*](struct.ManagementProfileDeleteCall.html), [*profiles get*](struct.ManagementProfileGetCall.html), [*profiles insert*](struct.ManagementProfileInsertCall.html), [*profiles list*](struct.ManagementProfileListCall.html), [*profiles patch*](struct.ManagementProfilePatchCall.html), [*profiles update*](struct.ManagementProfileUpdateCall.html), [*segments list*](struct.ManagementSegmentListCall.html), [*unsampled reports delete*](struct.ManagementUnsampledReportDeleteCall.html), [*unsampled reports get*](struct.ManagementUnsampledReportGetCall.html), [*unsampled reports insert*](struct.ManagementUnsampledReportInsertCall.html), [*unsampled reports list*](struct.ManagementUnsampledReportListCall.html), [*uploads delete upload data*](struct.ManagementUploadDeleteUploadDataCall.html), [*uploads get*](struct.ManagementUploadGetCall.html), [*uploads list*](struct.ManagementUploadListCall.html), [*uploads upload data*](struct.ManagementUploadUploadDataCall.html), [*web property ad words links delete*](struct.ManagementWebPropertyAdWordsLinkDeleteCall.html), [*web property ad words links get*](struct.ManagementWebPropertyAdWordsLinkGetCall.html), [*web property ad words links insert*](struct.ManagementWebPropertyAdWordsLinkInsertCall.html), [*web property ad words links list*](struct.ManagementWebPropertyAdWordsLinkListCall.html), [*web property ad words links patch*](struct.ManagementWebPropertyAdWordsLinkPatchCall.html), [*web property ad words links update*](struct.ManagementWebPropertyAdWordsLinkUpdateCall.html), [*webproperties get*](struct.ManagementWebpropertyGetCall.html), [*webproperties insert*](struct.ManagementWebpropertyInsertCall.html), [*webproperties list*](struct.ManagementWebpropertyListCall.html), [*webproperties patch*](struct.ManagementWebpropertyPatchCall.html), [*webproperties update*](struct.ManagementWebpropertyUpdateCall.html), [*webproperty user links delete*](struct.ManagementWebpropertyUserLinkDeleteCall.html), [*webproperty user links insert*](struct.ManagementWebpropertyUserLinkInsertCall.html), [*webproperty user links list*](struct.ManagementWebpropertyUserLinkListCall.html) and [*webproperty user links update*](struct.ManagementWebpropertyUserLinkUpdateCall.html) +//! * [*account summaries list*](struct.ManagementAccountSummaryListCall.html), [*account user links delete*](struct.ManagementAccountUserLinkDeleteCall.html), [*account user links insert*](struct.ManagementAccountUserLinkInsertCall.html), [*account user links list*](struct.ManagementAccountUserLinkListCall.html), [*account user links update*](struct.ManagementAccountUserLinkUpdateCall.html), [*accounts list*](struct.ManagementAccountListCall.html), [*custom data sources list*](struct.ManagementCustomDataSourceListCall.html), [*custom dimensions get*](struct.ManagementCustomDimensionGetCall.html), [*custom dimensions insert*](struct.ManagementCustomDimensionInsertCall.html), [*custom dimensions list*](struct.ManagementCustomDimensionListCall.html), [*custom dimensions patch*](struct.ManagementCustomDimensionPatchCall.html), [*custom dimensions update*](struct.ManagementCustomDimensionUpdateCall.html), [*custom metrics get*](struct.ManagementCustomMetricGetCall.html), [*custom metrics insert*](struct.ManagementCustomMetricInsertCall.html), [*custom metrics list*](struct.ManagementCustomMetricListCall.html), [*custom metrics patch*](struct.ManagementCustomMetricPatchCall.html), [*custom metrics update*](struct.ManagementCustomMetricUpdateCall.html), [*experiments delete*](struct.ManagementExperimentDeleteCall.html), [*experiments get*](struct.ManagementExperimentGetCall.html), [*experiments insert*](struct.ManagementExperimentInsertCall.html), [*experiments list*](struct.ManagementExperimentListCall.html), [*experiments patch*](struct.ManagementExperimentPatchCall.html), [*experiments update*](struct.ManagementExperimentUpdateCall.html), [*filters delete*](struct.ManagementFilterDeleteCall.html), [*filters get*](struct.ManagementFilterGetCall.html), [*filters insert*](struct.ManagementFilterInsertCall.html), [*filters list*](struct.ManagementFilterListCall.html), [*filters patch*](struct.ManagementFilterPatchCall.html), [*filters update*](struct.ManagementFilterUpdateCall.html), [*goals get*](struct.ManagementGoalGetCall.html), [*goals insert*](struct.ManagementGoalInsertCall.html), [*goals list*](struct.ManagementGoalListCall.html), [*goals patch*](struct.ManagementGoalPatchCall.html), [*goals update*](struct.ManagementGoalUpdateCall.html), [*profile filter links delete*](struct.ManagementProfileFilterLinkDeleteCall.html), [*profile filter links get*](struct.ManagementProfileFilterLinkGetCall.html), [*profile filter links insert*](struct.ManagementProfileFilterLinkInsertCall.html), [*profile filter links list*](struct.ManagementProfileFilterLinkListCall.html), [*profile filter links patch*](struct.ManagementProfileFilterLinkPatchCall.html), [*profile filter links update*](struct.ManagementProfileFilterLinkUpdateCall.html), [*profile user links delete*](struct.ManagementProfileUserLinkDeleteCall.html), [*profile user links insert*](struct.ManagementProfileUserLinkInsertCall.html), [*profile user links list*](struct.ManagementProfileUserLinkListCall.html), [*profile user links update*](struct.ManagementProfileUserLinkUpdateCall.html), [*profiles delete*](struct.ManagementProfileDeleteCall.html), [*profiles get*](struct.ManagementProfileGetCall.html), [*profiles insert*](struct.ManagementProfileInsertCall.html), [*profiles list*](struct.ManagementProfileListCall.html), [*profiles patch*](struct.ManagementProfilePatchCall.html), [*profiles update*](struct.ManagementProfileUpdateCall.html), [*remarketing audience get*](struct.ManagementRemarketingAudienceGetCall.html), [*remarketing audience insert*](struct.ManagementRemarketingAudienceInsertCall.html), [*remarketing audience list*](struct.ManagementRemarketingAudienceListCall.html), [*remarketing audience patch*](struct.ManagementRemarketingAudiencePatchCall.html), [*remarketing audience update*](struct.ManagementRemarketingAudienceUpdateCall.html), [*segments list*](struct.ManagementSegmentListCall.html), [*unsampled reports delete*](struct.ManagementUnsampledReportDeleteCall.html), [*unsampled reports get*](struct.ManagementUnsampledReportGetCall.html), [*unsampled reports insert*](struct.ManagementUnsampledReportInsertCall.html), [*unsampled reports list*](struct.ManagementUnsampledReportListCall.html), [*uploads delete upload data*](struct.ManagementUploadDeleteUploadDataCall.html), [*uploads get*](struct.ManagementUploadGetCall.html), [*uploads list*](struct.ManagementUploadListCall.html), [*uploads upload data*](struct.ManagementUploadUploadDataCall.html), [*web property ad words links delete*](struct.ManagementWebPropertyAdWordsLinkDeleteCall.html), [*web property ad words links get*](struct.ManagementWebPropertyAdWordsLinkGetCall.html), [*web property ad words links insert*](struct.ManagementWebPropertyAdWordsLinkInsertCall.html), [*web property ad words links list*](struct.ManagementWebPropertyAdWordsLinkListCall.html), [*web property ad words links patch*](struct.ManagementWebPropertyAdWordsLinkPatchCall.html), [*web property ad words links update*](struct.ManagementWebPropertyAdWordsLinkUpdateCall.html), [*webproperties get*](struct.ManagementWebpropertyGetCall.html), [*webproperties insert*](struct.ManagementWebpropertyInsertCall.html), [*webproperties list*](struct.ManagementWebpropertyListCall.html), [*webproperties patch*](struct.ManagementWebpropertyPatchCall.html), [*webproperties update*](struct.ManagementWebpropertyUpdateCall.html), [*webproperty user links delete*](struct.ManagementWebpropertyUserLinkDeleteCall.html), [*webproperty user links insert*](struct.ManagementWebpropertyUserLinkInsertCall.html), [*webproperty user links list*](struct.ManagementWebpropertyUserLinkListCall.html) and [*webproperty user links update*](struct.ManagementWebpropertyUserLinkUpdateCall.html) //! * metadata //! * [*columns list*](struct.MetadataColumnListCall.html) //! * provisioning diff --git a/gen/analytics3/src/lib.rs.in b/gen/analytics3/src/lib.rs.in index 6dd6a3e24e..b141c25e5b 100644 --- a/gen/analytics3/src/lib.rs.in +++ b/gen/analytics3/src/lib.rs.in @@ -594,6 +594,47 @@ pub struct Goals { impl ResponseResult for Goals {} +/// The simple audience definition that will cause a user to be added to an audience. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingAudienceAudienceDefinition { + /// Defines the conditions to include users to the audience. + #[serde(rename="includeConditions")] + pub include_conditions: Option, +} + +impl NestedType for RemarketingAudienceAudienceDefinition {} +impl Part for RemarketingAudienceAudienceDefinition {} + + +/// Details for the filter of the type SEARCH_AND_REPLACE. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FilterSearchAndReplaceDetails { + /// Determines if the filter is case sensitive. + #[serde(rename="caseSensitive")] + pub case_sensitive: Option, + /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION. + #[serde(rename="fieldIndex")] + pub field_index: Option, + /// Term to search. + #[serde(rename="searchString")] + pub search_string: Option, + /// Term to replace the search term with. + #[serde(rename="replaceString")] + pub replace_string: Option, + /// Field to use in the filter. + pub field: Option, +} + +impl NestedType for FilterSearchAndReplaceDetails {} +impl Part for FilterSearchAndReplaceDetails {} + + /// JSON template for Analytics account entry. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -718,7 +759,7 @@ pub struct UnsampledReport { pub status: Option, /// Time this unsampled report was last modified. pub updated: Option, - /// The type of download you need to use for the report data file. + /// The type of download you need to use for the report data file. Possible values include `GOOGLE_DRIVE` and `GOOGLE_CLOUD_STORAGE`. If the value is `GOOGLE_DRIVE`, see the `driveDownloadDetails` field. If the value is `GOOGLE_CLOUD_STORAGE`, see the `cloudStorageDownloadDetails` field. #[serde(rename="downloadType")] pub download_type: Option, /// The start date for the unsampled report. @@ -784,6 +825,43 @@ impl NestedType for WebpropertyParentLink {} impl Part for WebpropertyParentLink {} +/// A remarketing audience collection lists Analytics remarketing audiences to which the user has access. Each resource in the collection corresponds to a single Analytics remarketing audience. +/// +/// # 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*). +/// +/// * [remarketing audience list management](struct.ManagementRemarketingAudienceListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingAudiences { + /// Email ID of the authenticated user + pub username: Option, + /// Collection type. + pub kind: Option, + /// A list of remarketing audiences. + pub items: Option>, + /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. + #[serde(rename="itemsPerPage")] + pub items_per_page: Option, + /// Link to previous page for this view (profile) collection. + #[serde(rename="previousLink")] + pub previous_link: Option, + /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. + #[serde(rename="startIndex")] + pub start_index: Option, + /// Link to next page for this remarketing audience collection. + #[serde(rename="nextLink")] + pub next_link: Option, + /// The total number of results for the query, regardless of the number of results in the response. + #[serde(rename="totalResults")] + pub total_results: Option, +} + +impl ResponseResult for RemarketingAudiences {} + + /// Parent link for this view (profile). Points to the web property to which this view (profile) belongs. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -855,6 +933,62 @@ pub struct Accounts { impl ResponseResult for Accounts {} +/// JSON template for an Analytics remarketing audience. +/// +/// # 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*). +/// +/// * [remarketing audience insert management](struct.ManagementRemarketingAudienceInsertCall.html) (request|response) +/// * [remarketing audience get management](struct.ManagementRemarketingAudienceGetCall.html) (response) +/// * [remarketing audience update management](struct.ManagementRemarketingAudienceUpdateCall.html) (request|response) +/// * [remarketing audience patch management](struct.ManagementRemarketingAudiencePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingAudience { + /// The linked ad accounts associated with this remarketing audience. A remarketing audience can have only one linkedAdAccount currently. + #[serde(rename="linkedAdAccounts")] + pub linked_ad_accounts: Option>, + /// Collection type. + pub kind: Option, + /// The simple audience definition that will cause a user to be added to an audience. + #[serde(rename="audienceDefinition")] + pub audience_definition: Option, + /// The description of this remarketing audience. + pub description: Option, + /// Time this remarketing audience was created. + pub created: Option, + /// Time this remarketing audience was last modified. + pub updated: Option, + /// Internal ID for the web property to which this remarketing audience belongs. + #[serde(rename="internalWebPropertyId")] + pub internal_web_property_id: Option, + /// The views (profiles) that this remarketing audience is linked to. + #[serde(rename="linkedViews")] + pub linked_views: Option>, + /// A state based audience definition that will cause a user to be added or removed from an audience. + #[serde(rename="stateBasedAudienceDefinition")] + pub state_based_audience_definition: Option, + /// The type of audience, either SIMPLE or STATE_BASED. + #[serde(rename="audienceType")] + pub audience_type: Option, + /// Web property ID of the form UA-XXXXX-YY to which this remarketing audience belongs. + #[serde(rename="webPropertyId")] + pub web_property_id: Option, + /// Account ID to which this remarketing audience belongs. + #[serde(rename="accountId")] + pub account_id: Option, + /// Remarketing Audience ID. + pub id: Option, + /// The name of this remarketing audience. + pub name: Option, +} + +impl RequestValue for RemarketingAudience {} +impl ResponseResult for RemarketingAudience {} + + /// Details for the filter of the type ADVANCED. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -935,6 +1069,47 @@ pub struct WebPropertySummary { impl Part for WebPropertySummary {} +/// Defines the conditions to exclude users from the audience. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions { + /// The segment condition that will cause a user to be removed from an audience. + pub segment: Option, + /// Whether to make the exclusion TEMPORARY or PERMANENT. + #[serde(rename="exclusionDuration")] + pub exclusion_duration: Option, +} + +impl NestedType for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {} +impl Part for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {} + + +/// JSON template for an Analytics Remarketing Include Conditions. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct IncludeConditions { + /// The look-back window lets you specify a time frame for evaluating the behavior that qualifies users for your audience. For example, if your filters include users from Central Asia, and Transactions Greater than 2, and you set the look-back window to 14 days, then any user from Central Asia whose cumulative transactions exceed 2 during the last 14 days is added to the audience. + #[serde(rename="daysToLookBack")] + pub days_to_look_back: Option, + /// Boolean indicating whether this segment is a smart list. https://support.google.com/analytics/answer/4628577 + #[serde(rename="isSmartList")] + pub is_smart_list: Option, + /// Resource type for include conditions. + pub kind: Option, + /// The segment condition that will cause a user to be added to an audience. + pub segment: Option, + /// Number of days a user remains in the audience. Use any integer from 1-540. In remarketing audiences for search ads, membership duration is truncated to 180 days. + #[serde(rename="membershipDurationDays")] + pub membership_duration_days: Option, +} + +impl Part for IncludeConditions {} + + /// JSON template for an Analytics account ticket. The account ticket consists of the ticket ID and the basic information for the account, property and profile. /// /// # Activities @@ -1157,6 +1332,24 @@ pub struct CustomDimensions { impl ResponseResult for CustomDimensions {} +/// A state based audience definition that will cause a user to be added or removed from an audience. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingAudienceStateBasedAudienceDefinition { + /// Defines the conditions to include users to the audience. + #[serde(rename="includeConditions")] + pub include_conditions: Option, + /// Defines the conditions to exclude users from the audience. + #[serde(rename="excludeConditions")] + pub exclude_conditions: Option, +} + +impl NestedType for RemarketingAudienceStateBasedAudienceDefinition {} +impl Part for RemarketingAudienceStateBasedAudienceDefinition {} + + /// Download details for a file stored in Google Drive. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1540,30 +1733,42 @@ pub struct RealtimeData { impl ResponseResult for RealtimeData {} -/// Details for the filter of the type SEARCH_AND_REPLACE. +/// JSON template for an Analytics Remarketing Audience Foreign Link. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FilterSearchAndReplaceDetails { - /// Determines if the filter is case sensitive. - #[serde(rename="caseSensitive")] - pub case_sensitive: Option, - /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION. - #[serde(rename="fieldIndex")] - pub field_index: Option, - /// Term to search. - #[serde(rename="searchString")] - pub search_string: Option, - /// Term to replace the search term with. - #[serde(rename="replaceString")] - pub replace_string: Option, - /// Field to use in the filter. - pub field: Option, +pub struct LinkedForeignAccount { + /// The foreign account ID. For example the an AdWords `linkedAccountId` has the following format XXX-XXX-XXXX. + #[serde(rename="linkedAccountId")] + pub linked_account_id: Option, + /// The status of this foreign account link. + pub status: Option, + /// Resource type for linked foreign account. + pub kind: Option, + /// Remarketing audience ID to which this linked foreign account belongs. + #[serde(rename="remarketingAudienceId")] + pub remarketing_audience_id: Option, + /// Entity ad account link ID. + pub id: Option, + /// Internal ID for the web property to which this linked foreign account belongs. + #[serde(rename="internalWebPropertyId")] + pub internal_web_property_id: Option, + /// Web property ID of the form UA-XXXXX-YY to which this linked foreign account belongs. + #[serde(rename="webPropertyId")] + pub web_property_id: Option, + /// The type of the foreign account. For example `ADWORDS_LINKS`. + #[serde(rename="type")] + pub type_: Option, + /// Boolean indicating whether this is eligible for search. + #[serde(rename="eligibleForSearch")] + pub eligible_for_search: Option, + /// Account ID to which this linked foreign account belongs. + #[serde(rename="accountId")] + pub account_id: Option, } -impl NestedType for FilterSearchAndReplaceDetails {} -impl Part for FilterSearchAndReplaceDetails {} +impl Part for LinkedForeignAccount {} /// JSON template for Analytics experiment resource. @@ -3107,7 +3312,7 @@ impl Part for ProfileChildLink {} /// ::default(), None); /// let mut hub = Analytics::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `account_summaries_list(...)`, `account_user_links_delete(...)`, `account_user_links_insert(...)`, `account_user_links_list(...)`, `account_user_links_update(...)`, `accounts_list(...)`, `custom_data_sources_list(...)`, `custom_dimensions_get(...)`, `custom_dimensions_insert(...)`, `custom_dimensions_list(...)`, `custom_dimensions_patch(...)`, `custom_dimensions_update(...)`, `custom_metrics_get(...)`, `custom_metrics_insert(...)`, `custom_metrics_list(...)`, `custom_metrics_patch(...)`, `custom_metrics_update(...)`, `experiments_delete(...)`, `experiments_get(...)`, `experiments_insert(...)`, `experiments_list(...)`, `experiments_patch(...)`, `experiments_update(...)`, `filters_delete(...)`, `filters_get(...)`, `filters_insert(...)`, `filters_list(...)`, `filters_patch(...)`, `filters_update(...)`, `goals_get(...)`, `goals_insert(...)`, `goals_list(...)`, `goals_patch(...)`, `goals_update(...)`, `profile_filter_links_delete(...)`, `profile_filter_links_get(...)`, `profile_filter_links_insert(...)`, `profile_filter_links_list(...)`, `profile_filter_links_patch(...)`, `profile_filter_links_update(...)`, `profile_user_links_delete(...)`, `profile_user_links_insert(...)`, `profile_user_links_list(...)`, `profile_user_links_update(...)`, `profiles_delete(...)`, `profiles_get(...)`, `profiles_insert(...)`, `profiles_list(...)`, `profiles_patch(...)`, `profiles_update(...)`, `segments_list(...)`, `unsampled_reports_delete(...)`, `unsampled_reports_get(...)`, `unsampled_reports_insert(...)`, `unsampled_reports_list(...)`, `uploads_delete_upload_data(...)`, `uploads_get(...)`, `uploads_list(...)`, `uploads_upload_data(...)`, `web_property_ad_words_links_delete(...)`, `web_property_ad_words_links_get(...)`, `web_property_ad_words_links_insert(...)`, `web_property_ad_words_links_list(...)`, `web_property_ad_words_links_patch(...)`, `web_property_ad_words_links_update(...)`, `webproperties_get(...)`, `webproperties_insert(...)`, `webproperties_list(...)`, `webproperties_patch(...)`, `webproperties_update(...)`, `webproperty_user_links_delete(...)`, `webproperty_user_links_insert(...)`, `webproperty_user_links_list(...)` and `webproperty_user_links_update(...)` +/// // like `account_summaries_list(...)`, `account_user_links_delete(...)`, `account_user_links_insert(...)`, `account_user_links_list(...)`, `account_user_links_update(...)`, `accounts_list(...)`, `custom_data_sources_list(...)`, `custom_dimensions_get(...)`, `custom_dimensions_insert(...)`, `custom_dimensions_list(...)`, `custom_dimensions_patch(...)`, `custom_dimensions_update(...)`, `custom_metrics_get(...)`, `custom_metrics_insert(...)`, `custom_metrics_list(...)`, `custom_metrics_patch(...)`, `custom_metrics_update(...)`, `experiments_delete(...)`, `experiments_get(...)`, `experiments_insert(...)`, `experiments_list(...)`, `experiments_patch(...)`, `experiments_update(...)`, `filters_delete(...)`, `filters_get(...)`, `filters_insert(...)`, `filters_list(...)`, `filters_patch(...)`, `filters_update(...)`, `goals_get(...)`, `goals_insert(...)`, `goals_list(...)`, `goals_patch(...)`, `goals_update(...)`, `profile_filter_links_delete(...)`, `profile_filter_links_get(...)`, `profile_filter_links_insert(...)`, `profile_filter_links_list(...)`, `profile_filter_links_patch(...)`, `profile_filter_links_update(...)`, `profile_user_links_delete(...)`, `profile_user_links_insert(...)`, `profile_user_links_list(...)`, `profile_user_links_update(...)`, `profiles_delete(...)`, `profiles_get(...)`, `profiles_insert(...)`, `profiles_list(...)`, `profiles_patch(...)`, `profiles_update(...)`, `remarketing_audience_get(...)`, `remarketing_audience_insert(...)`, `remarketing_audience_list(...)`, `remarketing_audience_patch(...)`, `remarketing_audience_update(...)`, `segments_list(...)`, `unsampled_reports_delete(...)`, `unsampled_reports_get(...)`, `unsampled_reports_insert(...)`, `unsampled_reports_list(...)`, `uploads_delete_upload_data(...)`, `uploads_get(...)`, `uploads_list(...)`, `uploads_upload_data(...)`, `web_property_ad_words_links_delete(...)`, `web_property_ad_words_links_get(...)`, `web_property_ad_words_links_insert(...)`, `web_property_ad_words_links_list(...)`, `web_property_ad_words_links_patch(...)`, `web_property_ad_words_links_update(...)`, `webproperties_get(...)`, `webproperties_insert(...)`, `webproperties_list(...)`, `webproperties_patch(...)`, `webproperties_update(...)`, `webproperty_user_links_delete(...)`, `webproperty_user_links_insert(...)`, `webproperty_user_links_list(...)` and `webproperty_user_links_update(...)` /// // to build up your call. /// let rb = hub.management(); /// # } @@ -3312,19 +3517,21 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing web property. + /// Returns a single profile filter link. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `accountId` - Account ID to which the web property belongs - /// * `webPropertyId` - Web property ID - pub fn webproperties_update(&self, request: Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { - ManagementWebpropertyUpdateCall { + /// * `accountId` - Account ID to retrieve profile filter link for. + /// * `webPropertyId` - Web property Id to retrieve profile filter link for. + /// * `profileId` - Profile ID to retrieve filter link for. + /// * `linkId` - ID of the profile filter link. + pub fn profile_filter_links_get(&self, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { + ManagementProfileFilterLinkGetCall { hub: self.hub, - _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), + _profile_id: profile_id.to_string(), + _link_id: link_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3377,6 +3584,52 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Delete a profile filter link. + /// + /// # Arguments + /// + /// * `accountId` - Account ID to which the profile filter link belongs. + /// * `webPropertyId` - Web property Id to which the profile filter link belongs. + /// * `profileId` - Profile ID to which the filter link belongs. + /// * `linkId` - ID of the profile filter link to delete. + pub fn profile_filter_links_delete(&self, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + ManagementProfileFilterLinkDeleteCall { + hub: self.hub, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _profile_id: profile_id.to_string(), + _link_id: link_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 remarketing audiences. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `accountId` - Account ID for the remarketing audience to update. + /// * `webPropertyId` - Web property ID for the remarketing audience to update. + /// * `remarketingAudienceId` - Remarketing audience ID of the remarketing audience to update. + pub fn remarketing_audience_update(&self, request: RemarketingAudience, account_id: &str, web_property_id: &str, remarketing_audience_id: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + ManagementRemarketingAudienceUpdateCall { + hub: self.hub, + _request: request, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _remarketing_audience_id: remarketing_audience_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Get a custom metric to which the user has access. @@ -3423,19 +3676,23 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns a web property-AdWords link to which the user has access. + /// Update an existing experiment. This method supports patch semantics. /// /// # Arguments /// - /// * `accountId` - ID of the account which the given web property belongs to. - /// * `webPropertyId` - Web property ID to retrieve the AdWords link for. - /// * `webPropertyAdWordsLinkId` - Web property-AdWords link ID. - pub fn web_property_ad_words_links_get(&self, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { - ManagementWebPropertyAdWordsLinkGetCall { + /// * `request` - No description provided. + /// * `accountId` - Account ID of the experiment to update. + /// * `webPropertyId` - Web property ID of the experiment to update. + /// * `profileId` - View (Profile) ID of the experiment to update. + /// * `experimentId` - Experiment ID of the experiment to update. + pub fn experiments_patch(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentPatchCall<'a, C, A> { + ManagementExperimentPatchCall { hub: self.hub, + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), + _profile_id: profile_id.to_string(), + _experiment_id: experiment_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3604,21 +3861,63 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Delete a profile filter link. + /// Upload data for a custom data source. /// /// # Arguments /// - /// * `accountId` - Account ID to which the profile filter link belongs. - /// * `webPropertyId` - Web property Id to which the profile filter link belongs. - /// * `profileId` - Profile ID to which the filter link belongs. - /// * `linkId` - ID of the profile filter link to delete. - pub fn profile_filter_links_delete(&self, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { - ManagementProfileFilterLinkDeleteCall { + /// * `accountId` - Account Id associated with the upload. + /// * `webPropertyId` - Web property UA-string associated with the upload. + /// * `customDataSourceId` - Custom data source Id to which the data being uploaded belongs. + pub fn uploads_upload_data(&self, account_id: &str, web_property_id: &str, custom_data_source_id: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + ManagementUploadUploadDataCall { hub: self.hub, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), + _custom_data_source_id: custom_data_source_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists webProperty-AdWords links for a given web property. + /// + /// # Arguments + /// + /// * `accountId` - ID of the account which the given web property belongs to. + /// * `webPropertyId` - Web property ID to retrieve the AdWords links for. + pub fn web_property_ad_words_links_list(&self, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { + ManagementWebPropertyAdWordsLinkListCall { + hub: self.hub, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _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: + /// + /// Create a new experiment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `accountId` - Account ID to create the experiment for. + /// * `webPropertyId` - Web property ID to create the experiment for. + /// * `profileId` - View (Profile) ID to create the experiment for. + pub fn experiments_insert(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementExperimentInsertCall<'a, C, A> { + ManagementExperimentInsertCall { + hub: self.hub, + _request: request, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), - _link_id: link_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3711,23 +4010,19 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Update an existing experiment. This method supports patch semantics. + /// Returns a web property-AdWords link to which the user has access. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `accountId` - Account ID of the experiment to update. - /// * `webPropertyId` - Web property ID of the experiment to update. - /// * `profileId` - View (Profile) ID of the experiment to update. - /// * `experimentId` - Experiment ID of the experiment to update. - pub fn experiments_patch(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentPatchCall<'a, C, A> { - ManagementExperimentPatchCall { + /// * `accountId` - ID of the account which the given web property belongs to. + /// * `webPropertyId` - Web property ID to retrieve the AdWords link for. + /// * `webPropertyAdWordsLinkId` - Web property-AdWords link ID. + pub fn web_property_ad_words_links_get(&self, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { + ManagementWebPropertyAdWordsLinkGetCall { hub: self.hub, - _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _profile_id: profile_id.to_string(), - _experiment_id: experiment_id.to_string(), + _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3850,19 +4145,21 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Upload data for a custom data source. + /// Lists all profile filter links for a profile. /// /// # Arguments /// - /// * `accountId` - Account Id associated with the upload. - /// * `webPropertyId` - Web property UA-string associated with the upload. - /// * `customDataSourceId` - Custom data source Id to which the data being uploaded belongs. - pub fn uploads_upload_data(&self, account_id: &str, web_property_id: &str, custom_data_source_id: &str) -> ManagementUploadUploadDataCall<'a, C, A> { - ManagementUploadUploadDataCall { + /// * `accountId` - Account ID to retrieve profile filter links for. + /// * `webPropertyId` - Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to. + /// * `profileId` - Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to. + pub fn profile_filter_links_list(&self, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { + ManagementProfileFilterLinkListCall { hub: self.hub, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _custom_data_source_id: custom_data_source_id.to_string(), + _profile_id: profile_id.to_string(), + _start_index: Default::default(), + _max_results: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3911,21 +4208,19 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Delete an experiment. + /// Create a new custom metric. /// /// # Arguments /// - /// * `accountId` - Account ID to which the experiment belongs - /// * `webPropertyId` - Web property ID to which the experiment belongs - /// * `profileId` - View (Profile) ID to which the experiment belongs - /// * `experimentId` - ID of the experiment to delete - pub fn experiments_delete(&self, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentDeleteCall<'a, C, A> { - ManagementExperimentDeleteCall { + /// * `request` - No description provided. + /// * `accountId` - Account ID for the custom metric to create. + /// * `webPropertyId` - Web property ID for the custom dimension to create. + pub fn custom_metrics_insert(&self, request: CustomMetric, account_id: &str, web_property_id: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { + ManagementCustomMetricInsertCall { hub: self.hub, + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _profile_id: profile_id.to_string(), - _experiment_id: experiment_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3997,27 +4292,6 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Lists webProperty-AdWords links for a given web property. - /// - /// # Arguments - /// - /// * `accountId` - ID of the account which the given web property belongs to. - /// * `webPropertyId` - Web property ID to retrieve the AdWords links for. - pub fn web_property_ad_words_links_list(&self, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { - ManagementWebPropertyAdWordsLinkListCall { - hub: self.hub, - _account_id: account_id.to_string(), - _web_property_id: web_property_id.to_string(), - _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: /// /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access. @@ -4101,17 +4375,19 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists account-user links for a given account. + /// Creates a new remarketing audiences. /// /// # Arguments /// - /// * `accountId` - Account ID to retrieve the user links for. - pub fn account_user_links_list(&self, account_id: &str) -> ManagementAccountUserLinkListCall<'a, C, A> { - ManagementAccountUserLinkListCall { + /// * `request` - No description provided. + /// * `accountId` - Account ID to create the remarketing audience for. + /// * `webPropertyId` - Web property ID to create the remarketing audience for. + pub fn remarketing_audience_insert(&self, request: RemarketingAudience, account_id: &str, web_property_id: &str) -> ManagementRemarketingAudienceInsertCall<'a, C, A> { + ManagementRemarketingAudienceInsertCall { hub: self.hub, + _request: request, _account_id: account_id.to_string(), - _start_index: Default::default(), - _max_results: Default::default(), + _web_property_id: web_property_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4120,22 +4396,19 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing custom metric. + /// Deletes a web property-AdWords link. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `accountId` - Account ID for the custom metric to update. - /// * `webPropertyId` - Web property ID for the custom metric to update. - /// * `customMetricId` - Custom metric ID for the custom metric to update. - pub fn custom_metrics_update(&self, request: CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { - ManagementCustomMetricUpdateCall { + /// * `accountId` - ID of the account which the given web property belongs to. + /// * `webPropertyId` - Web property ID to delete the AdWords link for. + /// * `webPropertyAdWordsLinkId` - Web property AdWords link ID. + pub fn web_property_ad_words_links_delete(&self, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + ManagementWebPropertyAdWordsLinkDeleteCall { hub: self.hub, - _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _custom_metric_id: custom_metric_id.to_string(), - _ignore_custom_data_source_links: Default::default(), + _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4167,21 +4440,40 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Update an existing experiment. + /// Creates a webProperty-AdWords link. /// /// # Arguments /// /// * `request` - No description provided. - /// * `accountId` - Account ID of the experiment to update. - /// * `webPropertyId` - Web property ID of the experiment to update. - /// * `profileId` - View (Profile) ID of the experiment to update. - /// * `experimentId` - Experiment ID of the experiment to update. - pub fn experiments_update(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentUpdateCall<'a, C, A> { - ManagementExperimentUpdateCall { + /// * `accountId` - ID of the Google Analytics account to create the link for. + /// * `webPropertyId` - Web property ID to create the link for. + pub fn web_property_ad_words_links_insert(&self, request: EntityAdWordsLink, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { + ManagementWebPropertyAdWordsLinkInsertCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Delete an experiment. + /// + /// # Arguments + /// + /// * `accountId` - Account ID to which the experiment belongs + /// * `webPropertyId` - Web property ID to which the experiment belongs + /// * `profileId` - View (Profile) ID to which the experiment belongs + /// * `experimentId` - ID of the experiment to delete + pub fn experiments_delete(&self, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + ManagementExperimentDeleteCall { + hub: self.hub, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), _profile_id: profile_id.to_string(), _experiment_id: experiment_id.to_string(), _delegate: Default::default(), @@ -4301,16 +4593,16 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Create a new experiment. + /// Updates an existing view (profile). /// /// # Arguments /// /// * `request` - No description provided. - /// * `accountId` - Account ID to create the experiment for. - /// * `webPropertyId` - Web property ID to create the experiment for. - /// * `profileId` - View (Profile) ID to create the experiment for. - pub fn experiments_insert(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementExperimentInsertCall<'a, C, A> { - ManagementExperimentInsertCall { + /// * `accountId` - Account ID to which the view (profile) belongs + /// * `webPropertyId` - Web property ID to which the view (profile) belongs + /// * `profileId` - ID of the view (profile) to be updated. + pub fn profiles_update(&self, request: Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUpdateCall<'a, C, A> { + ManagementProfileUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), @@ -4345,21 +4637,19 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all profile filter links for a profile. + /// Gets remarketing audiences to which the user has access. /// /// # Arguments /// - /// * `accountId` - Account ID to retrieve profile filter links for. - /// * `webPropertyId` - Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to. - /// * `profileId` - Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to. - pub fn profile_filter_links_list(&self, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { - ManagementProfileFilterLinkListCall { + /// * `accountId` - Account ID for the remarketing audience to retrieve. + /// * `webPropertyId` - Web property ID for the remarketing audience to retrieve. + /// * `remarketingAudienceId` - The ID to retrieve the Remarketing Audience for. + pub fn remarketing_audience_get(&self, account_id: &str, web_property_id: &str, remarketing_audience_id: &str) -> ManagementRemarketingAudienceGetCall<'a, C, A> { + ManagementRemarketingAudienceGetCall { hub: self.hub, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _profile_id: profile_id.to_string(), - _start_index: Default::default(), - _max_results: Default::default(), + _remarketing_audience_id: remarketing_audience_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4387,6 +4677,27 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Updates an existing web property. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `accountId` - Account ID to which the web property belongs + /// * `webPropertyId` - Web property ID + pub fn webproperties_update(&self, request: Webproperty, account_id: &str, web_property_id: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + ManagementWebpropertyUpdateCall { + hub: self.hub, + _request: request, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Create a new custom dimension. @@ -4410,19 +4721,17 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Create a new custom metric. + /// Removes a user from the given account. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `accountId` - Account ID for the custom metric to create. - /// * `webPropertyId` - Web property ID for the custom dimension to create. - pub fn custom_metrics_insert(&self, request: CustomMetric, account_id: &str, web_property_id: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { - ManagementCustomMetricInsertCall { + /// * `accountId` - Account ID to delete the user link for. + /// * `linkId` - Link ID to delete the user link for. + pub fn account_user_links_delete(&self, account_id: &str, link_id: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { + ManagementAccountUserLinkDeleteCall { hub: self.hub, - _request: request, _account_id: account_id.to_string(), - _web_property_id: web_property_id.to_string(), + _link_id: link_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4452,6 +4761,31 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Update an existing experiment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `accountId` - Account ID of the experiment to update. + /// * `webPropertyId` - Web property ID of the experiment to update. + /// * `profileId` - View (Profile) ID of the experiment to update. + /// * `experimentId` - Experiment ID of the experiment to update. + pub fn experiments_update(&self, request: Experiment, account_id: &str, web_property_id: &str, profile_id: &str, experiment_id: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + ManagementExperimentUpdateCall { + hub: self.hub, + _request: request, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _profile_id: profile_id.to_string(), + _experiment_id: experiment_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists web properties to which the user has access. @@ -4471,27 +4805,6 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Creates a webProperty-AdWords link. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `accountId` - ID of the Google Analytics account to create the link for. - /// * `webPropertyId` - Web property ID to create the link for. - pub fn web_property_ad_words_links_insert(&self, request: EntityAdWordsLink, account_id: &str, web_property_id: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - ManagementWebPropertyAdWordsLinkInsertCall { - hub: self.hub, - _request: request, - _account_id: account_id.to_string(), - _web_property_id: web_property_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 webProperty-AdWords link. This method supports patch semantics. @@ -4540,19 +4853,45 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a web property-AdWords link. + /// Updates an existing custom metric. /// /// # Arguments /// - /// * `accountId` - ID of the account which the given web property belongs to. - /// * `webPropertyId` - Web property ID to delete the AdWords link for. - /// * `webPropertyAdWordsLinkId` - Web property AdWords link ID. - pub fn web_property_ad_words_links_delete(&self, account_id: &str, web_property_id: &str, web_property_ad_words_link_id: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { - ManagementWebPropertyAdWordsLinkDeleteCall { + /// * `request` - No description provided. + /// * `accountId` - Account ID for the custom metric to update. + /// * `webPropertyId` - Web property ID for the custom metric to update. + /// * `customMetricId` - Custom metric ID for the custom metric to update. + pub fn custom_metrics_update(&self, request: CustomMetric, account_id: &str, web_property_id: &str, custom_metric_id: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { + ManagementCustomMetricUpdateCall { hub: self.hub, + _request: request, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(), + _custom_metric_id: custom_metric_id.to_string(), + _ignore_custom_data_source_links: 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 remarketing audiences. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `accountId` - Account ID for the remarketing audience to update. + /// * `webPropertyId` - Web property ID for the remarketing audience to update. + /// * `remarketingAudienceId` - Remarketing audience ID of the remarketing audience to update. + pub fn remarketing_audience_patch(&self, request: RemarketingAudience, account_id: &str, web_property_id: &str, remarketing_audience_id: &str) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + ManagementRemarketingAudiencePatchCall { + hub: self.hub, + _request: request, + _account_id: account_id.to_string(), + _web_property_id: web_property_id.to_string(), + _remarketing_audience_id: remarketing_audience_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4664,17 +5003,17 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Removes a user from the given account. + /// Lists account-user links for a given account. /// /// # Arguments /// - /// * `accountId` - Account ID to delete the user link for. - /// * `linkId` - Link ID to delete the user link for. - pub fn account_user_links_delete(&self, account_id: &str, link_id: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { - ManagementAccountUserLinkDeleteCall { + /// * `accountId` - Account ID to retrieve the user links for. + pub fn account_user_links_list(&self, account_id: &str) -> ManagementAccountUserLinkListCall<'a, C, A> { + ManagementAccountUserLinkListCall { hub: self.hub, _account_id: account_id.to_string(), - _link_id: link_id.to_string(), + _start_index: Default::default(), + _max_results: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4683,44 +5022,20 @@ impl<'a, C, A> ManagementMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing view (profile). + /// Lists remarketing audiences to which the user has access. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `accountId` - Account ID to which the view (profile) belongs - /// * `webPropertyId` - Web property ID to which the view (profile) belongs - /// * `profileId` - ID of the view (profile) to be updated. - pub fn profiles_update(&self, request: Profile, account_id: &str, web_property_id: &str, profile_id: &str) -> ManagementProfileUpdateCall<'a, C, A> { - ManagementProfileUpdateCall { - hub: self.hub, - _request: request, - _account_id: account_id.to_string(), - _web_property_id: web_property_id.to_string(), - _profile_id: profile_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns a single profile filter link. - /// - /// # Arguments - /// - /// * `accountId` - Account ID to retrieve profile filter link for. - /// * `webPropertyId` - Web property Id to retrieve profile filter link for. - /// * `profileId` - Profile ID to retrieve filter link for. - /// * `linkId` - ID of the profile filter link. - pub fn profile_filter_links_get(&self, account_id: &str, web_property_id: &str, profile_id: &str, link_id: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { - ManagementProfileFilterLinkGetCall { + /// * `accountId` - Account ID for the remarketing audience to retrieve. + /// * `webPropertyId` - Web property ID for the remarketing audience to retrieve. + pub fn remarketing_audience_list(&self, account_id: &str, web_property_id: &str) -> ManagementRemarketingAudienceListCall<'a, C, A> { + ManagementRemarketingAudienceListCall { hub: self.hub, _account_id: account_id.to_string(), _web_property_id: web_property_id.to_string(), - _profile_id: profile_id.to_string(), - _link_id: link_id.to_string(), + _type_: Default::default(), + _start_index: Default::default(), + _max_results: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -7384,9 +7699,9 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< } -/// Updates an existing web property. +/// Returns a single profile filter link. /// -/// A builder for the *webproperties.update* method supported by a *management* resource. +/// A builder for the *profileFilterLinks.get* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -7397,7 +7712,6 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_analytics3 as analytics3; -/// use analytics3::Webproperty; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -7408,37 +7722,33 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Analytics::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 = Webproperty::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.management().webproperties_update(req, "accountId", "webPropertyId") +/// let result = hub.management().profile_filter_links_get("accountId", "webPropertyId", "profileId", "linkId") /// .doit(); /// # } /// ``` -pub struct ManagementWebpropertyUpdateCall<'a, C, A> +pub struct ManagementProfileFilterLinkGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: Webproperty, _account_id: String, _web_property_id: String, + _profile_id: String, + _link_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementWebpropertyUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkGetCall<'a, C, A> {} -impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementProfileFilterLinkGetCall<'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, Webproperty)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProfileFilterLink)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -7446,12 +7756,14 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.webproperties.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.profileFilterLinks.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId"].iter() { + params.push(("profileId", self._profile_id.to_string())); + params.push(("linkId", self._link_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7463,12 +7775,12 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -7479,8 +7791,8 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(2); - for param_name in ["webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["linkId", "profileId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -7495,17 +7807,6 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Account ID to which the web property belongs + /// Account ID to retrieve profile filter link for. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID + /// Web property Id to retrieve profile filter link for. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } + /// Profile ID to retrieve filter link for. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// ID of the profile filter link. + /// + /// Sets the *link 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 link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { + self._link_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) -> ManagementWebpropertyUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementProfileFilterLinkGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -7637,7 +7945,7 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementWebpropertyUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementProfileFilterLinkGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -7646,7 +7954,7 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementWebpropertyUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementProfileFilterLinkGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -8242,6 +8550,556 @@ impl<'a, C, A> ManagementUnsampledReportInsertCall<'a, C, A> where C: BorrowMut< } +/// Delete a profile filter link. +/// +/// A builder for the *profileFilterLinks.delete* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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.management().profile_filter_links_delete("accountId", "webPropertyId", "profileId", "linkId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementProfileFilterLinkDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _account_id: String, + _web_property_id: String, + _profile_id: String, + _link_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkDeleteCall<'a, C, A> {} + +impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'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: "analytics.management.profileFilterLinks.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("linkId", self._link_id.to_string())); + for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId"), ("{linkId}", "linkId")].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 ["linkId", "profileId", "webPropertyId", "accountId"].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) + } + } + } + } + + + /// Account ID to which the profile filter link belongs. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property Id to which the profile filter link belongs. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// Profile ID to which the filter link belongs. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// ID of the profile filter link to delete. + /// + /// Sets the *link 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 link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + self._link_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) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementProfileFilterLinkDeleteCall<'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::Edit`. + /// + /// 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) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing audiences. +/// +/// A builder for the *remarketingAudience.update* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// use analytics3::RemarketingAudience; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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 = RemarketingAudience::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.management().remarketing_audience_update(req, "accountId", "webPropertyId", "remarketingAudienceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementRemarketingAudienceUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _request: RemarketingAudience, + _account_id: String, + _web_property_id: String, + _remarketing_audience_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementRemarketingAudienceUpdateCall<'a, C, A> {} + +impl<'a, C, A> ManagementRemarketingAudienceUpdateCall<'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, RemarketingAudience)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.remarketingAudience.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("remarketingAudienceId", self._remarketing_audience_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{remarketingAudienceId}", "remarketingAudienceId")].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 ["remarketingAudienceId", "webPropertyId", "accountId"].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: RemarketingAudience) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID for the remarketing audience to update. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID for the remarketing audience to update. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// Remarketing audience ID of the remarketing audience to update. + /// + /// Sets the *remarketing audience 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 remarketing_audience_id(mut self, new_value: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + self._remarketing_audience_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) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementRemarketingAudienceUpdateCall<'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::Edit`. + /// + /// 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) -> ManagementRemarketingAudienceUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Get a custom metric to which the user has access. /// /// A builder for the *customMetrics.get* method supported by a *management* resource. @@ -8772,9 +9630,9 @@ impl<'a, C, A> ManagementUploadGetCall<'a, C, A> where C: BorrowMut ManagementUploadGetCall<'a, C, A> where C: BorrowMut ManagementUploadGetCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Analytics::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 = Experiment::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.management().web_property_ad_words_links_get("accountId", "webPropertyId", "webPropertyAdWordsLinkId") +/// let result = hub.management().experiments_patch(req, "accountId", "webPropertyId", "profileId", "experimentId") /// .doit(); /// # } /// ``` -pub struct ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> +pub struct ManagementExperimentPatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, + _request: Experiment, _account_id: String, _web_property_id: String, - _web_property_ad_words_link_id: String, + _profile_id: String, + _experiment_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementExperimentPatchCall<'a, C, A> {} -impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementExperimentPatchCall<'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, EntityAdWordsLink)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Experiment)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -8828,13 +9694,14 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.experiments.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("webPropertyAdWordsLinkId", self._web_property_ad_words_link_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() { + params.push(("profileId", self._profile_id.to_string())); + params.push(("experimentId", self._experiment_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "profileId", "experimentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8846,12 +9713,12 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}".to_string(); + let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId")].iter() { + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId"), ("{experimentId}", "experimentId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -8862,8 +9729,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow 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 ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["experimentId", "profileId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -8878,6 +9745,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow 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 { @@ -8894,11 +9772,15 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow } }; 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.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() @@ -8949,34 +9831,53 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow } - /// ID of the account which the given web property belongs to. + /// + /// 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: Experiment) -> ManagementExperimentPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID of the experiment to update. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID to retrieve the AdWords link for. + /// Web property ID of the experiment to update. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Web property-AdWords link ID. + /// View (Profile) ID of the experiment to update. /// - /// Sets the *web property ad words link id* path property to the given value. + /// Sets the *profile 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 web_property_ad_words_link_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { - self._web_property_ad_words_link_id = new_value.to_string(); + pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Experiment ID of the experiment to update. + /// + /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { + self._experiment_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -8985,7 +9886,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementExperimentPatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9006,7 +9907,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow /// * *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) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementExperimentPatchCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -9015,7 +9916,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow /// 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`. + /// `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. @@ -9023,7 +9924,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow /// 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) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementExperimentPatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -9058,8 +9959,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.management().webproperty_user_links_list("accountId", "webPropertyId") -/// .start_index(-40) -/// .max_results(-58) +/// .start_index(-48) +/// .max_results(-48) /// .doit(); /// # } /// ``` @@ -9908,7 +10809,7 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Analytics::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `upload_resumable(...)`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.management().uploads_upload_data("accountId", "webPropertyId", "customDataSourceId") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// # } +/// ``` +pub struct ManagementUploadUploadDataCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _account_id: String, + _web_property_id: String, + _custom_data_source_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementUploadUploadDataCall<'a, C, A> {} + +impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, Upload)> + where RS: ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.uploads.uploadData", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("customDataSourceId", self._custom_data_source_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "customDataSourceId"].iter() { + if self._additional_params.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, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads".to_string(), "multipart") + } else if protocol == "resumable" { + ("https://www.googleapis.com/resumable/upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads".to_string(), "resumable") + } else { + unreachable!() + }; + params.push(("uploadType", upload_type.to_string())); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{customDataSourceId}", "customDataSourceId")].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 ["customDataSourceId", "webPropertyId", "accountId"].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 should_ask_dlg_for_url = false; + let mut upload_url_from_server; + let mut upload_url: Option = None; + + 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 = { + if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { + should_ask_dlg_for_url = false; + upload_url_from_server = false; + let url = upload_url.as_ref().and_then(|s| Some(hyper::Url::parse(s).unwrap())).unwrap(); + hyper::client::Response::new(url, Box::new(cmn::DummyNetworkStream)).and_then(|mut res| { + res.status = hyper::status::StatusCode::Ok; + res.headers.set(Location(upload_url.as_ref().unwrap().clone())); + Ok(res) + }) + } else { + 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()); + if protocol == "simple" { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + req = req.header(ContentType(reader_mime_type.clone())) + .header(ContentLength(size)) + .body(&mut reader); + } + upload_url_from_server = true; + if protocol == "resumable" { + req = req.header(cmn::XUploadContentType(reader_mime_type.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)) + } + } + if protocol == "resumable" { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + let mut client = &mut *self.hub.client.borrow_mut(); + let upload_result = { + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + cmn::ResumableUploadHelper { + client: &mut client.borrow_mut(), + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &mut *self.hub.auth.borrow_mut(), + user_agent: &self.hub._user_agent, + auth_header: auth_header.clone(), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload() + }; + match upload_result { + None => { + dlg.finished(false); + return Err(Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Some(Ok(upload_result)) => { + res = upload_result; + if !res.status.is_success() { + dlg.store_upload_url(None); + dlg.finished(false); + return Err(Error::Failure(res)) + } + } + } + } + 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) + } + } + } + } + + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *max size*: 1GB + /// * *multipart*: yes + /// * *valid mime types*: 'application/octet-stream' + pub fn upload(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Upload)> + where RS: ReadSeek { + self.doit(stream, mime_type, "simple") + } + /// Upload media in a resumable fashion. + /// Even if the upload fails or is interrupted, it can be resumed for a + /// certain amount of time as the server maintains state temporarily. + /// + /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL + /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate + /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using + /// `cancel_chunk_upload(...)`. + /// + /// * *max size*: 1GB + /// * *multipart*: yes + /// * *valid mime types*: 'application/octet-stream' + pub fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Upload)> + where RS: ReadSeek { + self.doit(resumeable_stream, mime_type, "resumable") + } + + /// Account Id associated with the upload. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property UA-string associated with the upload. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// Custom data source Id to which the data being uploaded belongs. + /// + /// Sets the *custom data source 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 custom_data_source_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + self._custom_data_source_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) -> ManagementUploadUploadDataCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementUploadUploadDataCall<'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) -> ManagementUploadUploadDataCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists webProperty-AdWords links for a given web property. +/// +/// A builder for the *webPropertyAdWordsLinks.list* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -11042,30 +12311,32 @@ impl<'a, C, A> ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut +pub struct ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, _account_id: String, _web_property_id: String, - _profile_id: String, - _link_id: String, + _start_index: Option, + _max_results: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkListCall<'a, C, A> {} -impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, EntityAdWordsLinks)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -11073,14 +12344,18 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.profileFilterLinks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("linkId", self._link_id.to_string())); - for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() { + if let Some(value) = self._start_index { + params.push(("start-index", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("max-results", value.to_string())); + } + for &field in ["alt", "accountId", "webPropertyId", "start-index", "max-results"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -11090,13 +12365,14 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu params.push((&name, value.clone())); } + params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}".to_string(); + let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId"), ("{linkId}", "linkId")].iter() { + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -11107,8 +12383,8 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu 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 ["linkId", "profileId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -11141,7 +12417,7 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -11174,7 +12450,17 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu Ok(serr) => Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -11184,44 +12470,38 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu } - /// Account ID to which the profile filter link belongs. + /// ID of the account which the given web property belongs to. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property Id to which the profile filter link belongs. + /// Web property ID to retrieve the AdWords links for. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Profile ID to which the filter link belongs. + /// An index of the first webProperty-AdWords link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. /// - /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { - self._profile_id = new_value.to_string(); + /// Sets the *start-index* query property to the given value. + pub fn start_index(mut self, new_value: i32) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { + self._start_index = Some(new_value); self } - /// ID of the profile filter link to delete. + /// The maximum number of webProperty-AdWords links to include in this response. /// - /// Sets the *link 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 link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { - self._link_id = new_value.to_string(); + /// Sets the *max-results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagementWebPropertyAdWordsLinkListCall<'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 @@ -11230,7 +12510,7 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -11251,7 +12531,7 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu /// * *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) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -11260,7 +12540,7 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu /// 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::Edit`. + /// `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. @@ -11268,7 +12548,297 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu /// 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) -> ManagementProfileFilterLinkDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Create a new experiment. +/// +/// A builder for the *experiments.insert* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// use analytics3::Experiment; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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 = Experiment::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.management().experiments_insert(req, "accountId", "webPropertyId", "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementExperimentInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _request: Experiment, + _account_id: String, + _web_property_id: String, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementExperimentInsertCall<'a, C, A> {} + +impl<'a, C, A> ManagementExperimentInsertCall<'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, Experiment)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.experiments.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId")].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 ["profileId", "webPropertyId", "accountId"].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: Experiment) -> ManagementExperimentInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID to create the experiment for. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID to create the experiment for. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// View (Profile) ID to create the experiment for. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + self._profile_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) -> ManagementExperimentInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementExperimentInsertCall<'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) -> ManagementExperimentInsertCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -11303,8 +12873,8 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.management().segments_list() -/// .start_index(-88) -/// .max_results(-96) +/// .start_index(-37) +/// .max_results(-66) /// .doit(); /// # } /// ``` @@ -12354,9 +13924,9 @@ impl<'a, C, A> ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Analytics::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 = Experiment::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.management().experiments_patch(req, "accountId", "webPropertyId", "profileId", "experimentId") +/// let result = hub.management().web_property_ad_words_links_get("accountId", "webPropertyId", "webPropertyAdWordsLinkId") /// .doit(); /// # } /// ``` -pub struct ManagementExperimentPatchCall<'a, C, A> +pub struct ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: Experiment, _account_id: String, _web_property_id: String, - _profile_id: String, - _experiment_id: String, + _web_property_ad_words_link_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementExperimentPatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> {} -impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'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, Experiment)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, EntityAdWordsLink)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -12418,14 +13980,13 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.experiments.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("experimentId", self._experiment_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "profileId", "experimentId"].iter() { + params.push(("webPropertyAdWordsLinkId", self._web_property_ad_words_link_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12437,12 +13998,12 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -12453,8 +14014,8 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(4); - for param_name in ["experimentId", "profileId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -12469,17 +14030,6 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Account ID of the experiment to update. + /// ID of the account which the given web property belongs to. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID of the experiment to update. + /// Web property ID to retrieve the AdWords link for. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// View (Profile) ID of the experiment to update. + /// Web property-AdWords link ID. /// - /// Sets the *profile id* path property to the given value. + /// Sets the *web property ad words link 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 profile_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Experiment ID of the experiment to update. - /// - /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C, A> { - self._experiment_id = new_value.to_string(); + pub fn web_property_ad_words_link_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { + self._web_property_ad_words_link_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -12610,7 +14137,7 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -12631,7 +14158,7 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementExperimentPatchCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -12640,7 +14167,7 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementExperimentPatchCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -12683,8 +14210,8 @@ impl<'a, C, A> ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentListCall<'a, C, A> where C: BorrowMut ManagementProfileListCall<'a, C, A> where C: BorrowMut ManagementGoalInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Analytics::new(hyper::Client::new(), auth); /// // You can configure optional parameters by calling the respective setters at will, and -/// // execute the final call using `upload_resumable(...)`. +/// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.management().uploads_upload_data("accountId", "webPropertyId", "customDataSourceId") -/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// let result = hub.management().profile_filter_links_list("accountId", "webPropertyId", "profileId") +/// .start_index(-19) +/// .max_results(-93) +/// .doit(); /// # } /// ``` -pub struct ManagementUploadUploadDataCall<'a, C, A> +pub struct ManagementProfileFilterLinkListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, _account_id: String, _web_property_id: String, - _custom_data_source_id: String, + _profile_id: String, + _start_index: Option, + _max_results: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementUploadUploadDataCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkListCall<'a, C, A> {} -impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, Upload)> - where RS: ReadSeek { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProfileFilterLinks)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -14143,13 +15672,19 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.uploads.uploadData", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.profileFilterLinks.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("customDataSourceId", self._custom_data_source_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "customDataSourceId"].iter() { + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._start_index { + params.push(("start-index", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("max-results", value.to_string())); + } + for &field in ["alt", "accountId", "webPropertyId", "profileId", "start-index", "max-results"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14161,20 +15696,12 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -14186,7 +15713,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(3); - for param_name in ["customDataSourceId", "webPropertyId", "accountId"].iter() { + for param_name in ["profileId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -14202,9 +15729,6 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut = None; loop { let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { @@ -14221,38 +15745,13 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut 1073741824 { - return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) - } - req = req.header(ContentType(reader_mime_type.clone())) - .header(ContentLength(size)) - .body(&mut reader); - } - upload_url_from_server = true; - if protocol == "resumable" { - req = req.header(cmn::XUploadContentType(reader_mime_type.clone())); - } - - dlg.pre_request(); - req.send() - } + 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 { @@ -14280,51 +15779,6 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut Err(Error::BadRequest(serr)) } } - if protocol == "resumable" { - let size = reader.seek(io::SeekFrom::End(0)).unwrap(); - reader.seek(io::SeekFrom::Start(0)).unwrap(); - if size > 1073741824 { - return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) - } - let mut client = &mut *self.hub.client.borrow_mut(); - let upload_result = { - let url_str = &res.headers.get::().expect("Location header is part of protocol").0; - if upload_url_from_server { - dlg.store_upload_url(Some(url_str)); - } - - cmn::ResumableUploadHelper { - client: &mut client.borrow_mut(), - delegate: dlg, - start_at: if upload_url_from_server { Some(0) } else { None }, - auth: &mut *self.hub.auth.borrow_mut(), - user_agent: &self.hub._user_agent, - auth_header: auth_header.clone(), - url: url_str, - reader: &mut reader, - media_type: reader_mime_type.clone(), - content_length: size - }.upload() - }; - match upload_result { - None => { - dlg.finished(false); - return Err(Error::Cancelled) - } - Some(Err(err)) => { - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Some(Ok(upload_result)) => { - res = upload_result; - if !res.status.is_success() { - dlg.store_upload_url(None); - dlg.finished(false); - return Err(Error::Failure(res)) - } - } - } - } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); @@ -14344,61 +15798,49 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Upload)> - where RS: ReadSeek { - self.doit(stream, mime_type, "simple") - } - /// Upload media in a resumable fashion. - /// Even if the upload fails or is interrupted, it can be resumed for a - /// certain amount of time as the server maintains state temporarily. - /// - /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL - /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate - /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using - /// `cancel_chunk_upload(...)`. - /// - /// * *max size*: 1GB - /// * *multipart*: yes - /// * *valid mime types*: 'application/octet-stream' - pub fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Upload)> - where RS: ReadSeek { - self.doit(resumeable_stream, mime_type, "resumable") - } - /// Account Id associated with the upload. + /// Account ID to retrieve profile filter links for. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property UA-string associated with the upload. + /// Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Custom data source Id to which the data being uploaded belongs. + /// Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to. /// - /// Sets the *custom data source id* path property to the given value. + /// Sets the *profile 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 custom_data_source_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C, A> { - self._custom_data_source_id = new_value.to_string(); + pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. + /// + /// Sets the *start-index* query property to the given value. + pub fn start_index(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C, A> { + self._start_index = Some(new_value); + self + } + /// The maximum number of profile filter links to include in this response. + /// + /// Sets the *max-results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'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 @@ -14407,7 +15849,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementUploadUploadDataCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementProfileFilterLinkListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14428,7 +15870,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementUploadUploadDataCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementProfileFilterLinkListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -14437,7 +15879,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementUploadUploadDataCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementProfileFilterLinkListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -14997,9 +16439,9 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow } -/// Delete an experiment. +/// Create a new custom metric. /// -/// A builder for the *experiments.delete* method supported by a *management* resource. +/// A builder for the *customMetrics.insert* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -15010,6 +16452,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_analytics3 as analytics3; +/// use analytics3::CustomMetric; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -15020,33 +16463,37 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Analytics::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 = CustomMetric::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.management().experiments_delete("accountId", "webPropertyId", "profileId", "experimentId") +/// let result = hub.management().custom_metrics_insert(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` -pub struct ManagementExperimentDeleteCall<'a, C, A> +pub struct ManagementCustomMetricInsertCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, + _request: CustomMetric, _account_id: String, _web_property_id: String, - _profile_id: String, - _experiment_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementExperimentDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementCustomMetricInsertCall<'a, C, A> {} -impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, CustomMetric)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -15054,14 +16501,12 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.experiments.delete", - http_method: hyper::method::Method::Delete }); + dlg.begin(MethodInfo { id: "analytics.management.customMetrics.insert", + http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("experimentId", self._experiment_id.to_string())); - for &field in ["accountId", "webPropertyId", "profileId", "experimentId"].iter() { + for &field in ["alt", "accountId", "webPropertyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15071,13 +16516,14 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -15088,8 +16534,8 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(4); - for param_name in ["experimentId", "profileId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -15104,6 +16550,17 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -15165,53 +16636,42 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID for the custom metric to create. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID to which the experiment belongs + /// Web property ID for the custom dimension to create. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// View (Profile) ID to which the experiment belongs - /// - /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// ID of the experiment to delete - /// - /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { - self._experiment_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) -> ManagementExperimentDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementCustomMetricInsertCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -15232,7 +16692,7 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementExperimentDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementCustomMetricInsertCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -15241,7 +16701,7 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementExperimentDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementCustomMetricInsertCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -16054,277 +17514,6 @@ impl<'a, C, A> ManagementFilterGetCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Analytics::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.management().web_property_ad_words_links_list("accountId", "webPropertyId") -/// .start_index(-67) -/// .max_results(-17) -/// .doit(); -/// # } -/// ``` -pub struct ManagementWebPropertyAdWordsLinkListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Analytics, - _account_id: String, - _web_property_id: String, - _start_index: Option, - _max_results: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkListCall<'a, C, A> {} - -impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'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, EntityAdWordsLinks)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("accountId", self._account_id.to_string())); - params.push(("webPropertyId", self._web_property_id.to_string())); - if let Some(value) = self._start_index { - params.push(("start-index", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("max-results", value.to_string())); - } - for &field in ["alt", "accountId", "webPropertyId", "start-index", "max-results"].iter() { - if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId")].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 ["webPropertyId", "accountId"].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) - } - } - } - } - - - /// ID of the account which the given web property belongs to. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// Web property ID to retrieve the AdWords links for. - /// - /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { - self._web_property_id = new_value.to_string(); - self - } - /// An index of the first webProperty-AdWords link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. - /// - /// Sets the *start-index* query property to the given value. - pub fn start_index(mut self, new_value: i32) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { - self._start_index = Some(new_value); - self - } - /// The maximum number of webProperty-AdWords links to include in this response. - /// - /// Sets the *max-results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> ManagementWebPropertyAdWordsLinkListCall<'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) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ManagementWebPropertyAdWordsLinkListCall<'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) -> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access. /// /// A builder for the *accountSummaries.list* method supported by a *management* resource. @@ -16352,8 +17541,8 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: Borro /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.management().account_summaries_list() -/// .start_index(-74) -/// .max_results(-48) +/// .start_index(-96) +/// .max_results(-22) /// .doit(); /// # } /// ``` @@ -16578,8 +17767,8 @@ impl<'a, C, A> ManagementAccountSummaryListCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionListCall<'a, C, A> where C: BorrowMut ManagementUploadListCall<'a, C, A> where C: BorrowMut ManagementProfileUserLinkListCall<'a, C, A> where C: BorrowMut ManagementProfileUserLinkListCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Analytics::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.management().account_user_links_list("accountId") -/// .start_index(-91) -/// .max_results(-15) -/// .doit(); -/// # } -/// ``` -pub struct ManagementAccountUserLinkListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Analytics, - _account_id: String, - _start_index: Option, - _max_results: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ManagementAccountUserLinkListCall<'a, C, A> {} - -impl<'a, C, A> ManagementAccountUserLinkListCall<'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, EntityUserLinks)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "analytics.management.accountUserLinks.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("accountId", self._account_id.to_string())); - if let Some(value) = self._start_index { - params.push(("start-index", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("max-results", value.to_string())); - } - for &field in ["alt", "accountId", "start-index", "max-results"].iter() { - if self._additional_params.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/analytics/v3/management/accounts/{accountId}/entityUserLinks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::ManageUserReadonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{accountId}", "accountId")].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 ["accountId"].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) - } - } - } - } - - - /// Account ID to retrieve the user links for. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementAccountUserLinkListCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// An index of the first account-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. - /// - /// Sets the *start-index* query property to the given value. - pub fn start_index(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C, A> { - self._start_index = Some(new_value); - self - } - /// The maximum number of account-user links to include in this response. - /// - /// Sets the *max-results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'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) -> ManagementAccountUserLinkListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ManagementAccountUserLinkListCall<'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::ManageUserReadonly`. - /// - /// 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) -> ManagementAccountUserLinkListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing custom metric. -/// -/// A builder for the *customMetrics.update* method supported by a *management* resource. -/// It is not used directly, but through a `ManagementMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_analytics3 as analytics3; -/// use analytics3::CustomMetric; +/// use analytics3::RemarketingAudience; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -17674,37 +18604,34 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut +pub struct ManagementRemarketingAudienceInsertCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: CustomMetric, + _request: RemarketingAudience, _account_id: String, _web_property_id: String, - _custom_metric_id: String, - _ignore_custom_data_source_links: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementCustomMetricUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementRemarketingAudienceInsertCall<'a, C, A> {} -impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementRemarketingAudienceInsertCall<'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, CustomMetric)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingAudience)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -17712,16 +18639,12 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.customMetrics.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.remarketingAudience.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("customMetricId", self._custom_metric_id.to_string())); - if let Some(value) = self._ignore_custom_data_source_links { - params.push(("ignoreCustomDataSourceLinks", value.to_string())); - } - for &field in ["alt", "accountId", "webPropertyId", "customMetricId", "ignoreCustomDataSourceLinks"].iter() { + for &field in ["alt", "accountId", "webPropertyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17733,12 +18656,12 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -17749,8 +18672,8 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(3); - for param_name in ["customMetricId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -17795,7 +18718,7 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut ManagementCustomMetricUpdateCall<'a, C, A> { + pub fn request(mut self, new_value: RemarketingAudience) -> ManagementRemarketingAudienceInsertCall<'a, C, A> { self._request = new_value; self } - /// Account ID for the custom metric to update. + /// Account ID to create the remarketing audience for. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceInsertCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID for the custom metric to update. + /// Web property ID to create the remarketing audience for. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementRemarketingAudienceInsertCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Custom metric ID for the custom metric to update. - /// - /// Sets the *custom metric 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 custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { - self._custom_metric_id = new_value.to_string(); - self - } - /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set. - /// - /// Sets the *ignore custom data source links* query property to the given value. - pub fn ignore_custom_data_source_links(mut self, new_value: bool) -> ManagementCustomMetricUpdateCall<'a, C, A> { - self._ignore_custom_data_source_links = 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) -> ManagementCustomMetricUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementRemarketingAudienceInsertCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -17924,7 +18830,7 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementCustomMetricUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementRemarketingAudienceInsertCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -17941,7 +18847,255 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementCustomMetricUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementRemarketingAudienceInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a web property-AdWords link. +/// +/// A builder for the *webPropertyAdWordsLinks.delete* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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.management().web_property_ad_words_links_delete("accountId", "webPropertyId", "webPropertyAdWordsLinkId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _account_id: String, + _web_property_id: String, + _web_property_ad_words_link_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> {} + +impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'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: "analytics.management.webPropertyAdWordsLinks.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("webPropertyAdWordsLinkId", self._web_property_ad_words_link_id.to_string())); + for &field in ["accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId")].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 ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"].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) + } + } + } + } + + + /// ID of the account which the given web property belongs to. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID to delete the AdWords link for. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// Web property AdWords link ID. + /// + /// Sets the *web property ad words link 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 web_property_ad_words_link_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + self._web_property_ad_words_link_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) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementWebPropertyAdWordsLinkDeleteCall<'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::Edit`. + /// + /// 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) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -18228,9 +19382,9 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut } -/// Update an existing experiment. +/// Creates a webProperty-AdWords link. /// -/// A builder for the *experiments.update* method supported by a *management* resource. +/// A builder for the *webPropertyAdWordsLinks.insert* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -18241,7 +19395,7 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_analytics3 as analytics3; -/// use analytics3::Experiment; +/// use analytics3::EntityAdWordsLink; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -18255,36 +19409,34 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut /// // 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 = Experiment::default(); +/// let mut req = EntityAdWordsLink::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.management().experiments_update(req, "accountId", "webPropertyId", "profileId", "experimentId") +/// let result = hub.management().web_property_ad_words_links_insert(req, "accountId", "webPropertyId") /// .doit(); /// # } /// ``` -pub struct ManagementExperimentUpdateCall<'a, C, A> +pub struct ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: Experiment, + _request: EntityAdWordsLink, _account_id: String, _web_property_id: String, - _profile_id: String, - _experiment_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementExperimentUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> {} -impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'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, Experiment)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, EntityAdWordsLink)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -18292,14 +19444,12 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.experiments.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("experimentId", self._experiment_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "profileId", "experimentId"].iter() { + for &field in ["alt", "accountId", "webPropertyId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -18311,12 +19461,12 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -18327,8 +19477,8 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(4); - for param_name in ["experimentId", "profileId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -18373,7 +19523,7 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut ManagementExperimentUpdateCall<'a, C, A> { + pub fn request(mut self, new_value: EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { self._request = new_value; self } - /// Account ID of the experiment to update. + /// ID of the Google Analytics account to create the link for. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID of the experiment to update. + /// Web property ID to create the link for. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// View (Profile) ID of the experiment to update. - /// - /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Experiment ID of the experiment to update. - /// - /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { - self._experiment_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) -> ManagementExperimentUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -18505,7 +19635,267 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementExperimentUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkInsertCall<'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::Edit`. + /// + /// 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) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Delete an experiment. +/// +/// A builder for the *experiments.delete* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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.management().experiments_delete("accountId", "webPropertyId", "profileId", "experimentId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementExperimentDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _account_id: String, + _web_property_id: String, + _profile_id: String, + _experiment_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementExperimentDeleteCall<'a, C, A> {} + +impl<'a, C, A> ManagementExperimentDeleteCall<'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: "analytics.management.experiments.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("experimentId", self._experiment_id.to_string())); + for &field in ["accountId", "webPropertyId", "profileId", "experimentId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId"), ("{experimentId}", "experimentId")].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 ["experimentId", "profileId", "webPropertyId", "accountId"].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) + } + } + } + } + + + /// Account ID to which the experiment belongs + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID to which the experiment belongs + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// View (Profile) ID to which the experiment belongs + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// ID of the experiment to delete + /// + /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C, A> { + self._experiment_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) -> ManagementExperimentDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementExperimentDeleteCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -18522,7 +19912,7 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementExperimentUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementExperimentDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -18859,8 +20249,8 @@ impl<'a, C, A> ManagementGoalUpdateCall<'a, C, A> where C: BorrowMut ManagementCustomDataSourceListCall<'a, C, A> where C: BorrowMut ManagementCustomMetricListCall<'a, C, A> where C: BorrowMut ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut +pub struct ManagementProfileUpdateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: Experiment, + _request: Profile, _account_id: String, _web_property_id: String, _profile_id: String, @@ -19953,13 +21343,13 @@ pub struct ManagementExperimentInsertCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementExperimentInsertCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementProfileUpdateCall<'a, C, A> {} -impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementProfileUpdateCall<'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, Experiment)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Profile)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -19967,8 +21357,8 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.experiments.insert", - http_method: hyper::method::Method::Post }); + dlg.begin(MethodInfo { id: "analytics.management.profiles.update", + http_method: hyper::method::Method::Put }); let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); @@ -19985,9 +21375,9 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> { + pub fn request(mut self, new_value: Profile) -> ManagementProfileUpdateCall<'a, C, A> { self._request = new_value; self } - /// Account ID to create the experiment for. + /// Account ID to which the view (profile) belongs /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID to create the experiment for. + /// Web property ID to which the view (profile) belongs /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// View (Profile) ID to create the experiment for. + /// ID of the view (profile) to be updated. /// /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { self._profile_id = new_value.to_string(); self } @@ -20148,7 +21538,7 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementProfileUpdateCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -20169,7 +21559,7 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementExperimentInsertCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementProfileUpdateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -20178,7 +21568,7 @@ impl<'a, C, A> ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementExperimentInsertCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementProfileUpdateCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -20453,9 +21843,9 @@ impl<'a, C, A> ManagementCustomDimensionGetCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionGetCall<'a, C, A> where C: BorrowMut +pub struct ManagementRemarketingAudienceGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, _account_id: String, _web_property_id: String, - _profile_id: String, - _start_index: Option, - _max_results: Option, + _remarketing_audience_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementRemarketingAudienceGetCall<'a, C, A> {} -impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementRemarketingAudienceGetCall<'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, ProfileFilterLinks)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingAudience)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -20513,19 +21899,13 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.profileFilterLinks.list", + dlg.begin(MethodInfo { id: "analytics.management.remarketingAudience.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - if let Some(value) = self._start_index { - params.push(("start-index", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("max-results", value.to_string())); - } - for &field in ["alt", "accountId", "webPropertyId", "profileId", "start-index", "max-results"].iter() { + params.push(("remarketingAudienceId", self._remarketing_audience_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -20537,12 +21917,12 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks".to_string(); + let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId")].iter() { + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{remarketingAudienceId}", "remarketingAudienceId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -20554,7 +21934,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< } { let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["profileId", "webPropertyId", "accountId"].iter() { + for param_name in ["remarketingAudienceId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -20640,48 +22020,34 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< } - /// Account ID to retrieve profile filter links for. + /// Account ID for the remarketing audience to retrieve. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceGetCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property Id for profile filter links for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to. + /// Web property ID for the remarketing audience to retrieve. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementRemarketingAudienceGetCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Profile ID to retrieve filter links for. Can either be a specific profile ID or '~all', which refers to all the profiles that user has access to. + /// The ID to retrieve the Remarketing Audience for. /// - /// Sets the *profile id* path property to the given value. + /// Sets the *remarketing audience 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 profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. - /// - /// Sets the *start-index* query property to the given value. - pub fn start_index(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C, A> { - self._start_index = Some(new_value); - self - } - /// The maximum number of profile filter links to include in this response. - /// - /// Sets the *max-results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C, A> { - self._max_results = Some(new_value); + pub fn remarketing_audience_id(mut self, new_value: &str) -> ManagementRemarketingAudienceGetCall<'a, C, A> { + self._remarketing_audience_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -20690,7 +22056,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementProfileFilterLinkListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementRemarketingAudienceGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -20711,7 +22077,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< /// * *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) -> ManagementProfileFilterLinkListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementRemarketingAudienceGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -20728,7 +22094,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< /// 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) -> ManagementProfileFilterLinkListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementRemarketingAudienceGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -21014,6 +22380,284 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Analytics::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 = Webproperty::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.management().webproperties_update(req, "accountId", "webPropertyId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementWebpropertyUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _request: Webproperty, + _account_id: String, + _web_property_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementWebpropertyUpdateCall<'a, C, A> {} + +impl<'a, C, A> ManagementWebpropertyUpdateCall<'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, Webproperty)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.webproperties.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId")].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 ["webPropertyId", "accountId"].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: Webproperty) -> ManagementWebpropertyUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID to which the web property belongs + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C, A> { + self._web_property_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) -> ManagementWebpropertyUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementWebpropertyUpdateCall<'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::Edit`. + /// + /// 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) -> ManagementWebpropertyUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Create a new custom dimension. /// /// A builder for the *customDimensions.insert* method supported by a *management* resource. @@ -21292,9 +22936,9 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< } -/// Create a new custom metric. +/// Removes a user from the given account. /// -/// A builder for the *customMetrics.insert* method supported by a *management* resource. +/// A builder for the *accountUserLinks.delete* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -21305,7 +22949,6 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_analytics3 as analytics3; -/// use analytics3::CustomMetric; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -21316,37 +22959,31 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Analytics::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 = CustomMetric::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.management().custom_metrics_insert(req, "accountId", "webPropertyId") +/// let result = hub.management().account_user_links_delete("accountId", "linkId") /// .doit(); /// # } /// ``` -pub struct ManagementCustomMetricInsertCall<'a, C, A> +pub struct ManagementAccountUserLinkDeleteCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, - _request: CustomMetric, _account_id: String, - _web_property_id: String, + _link_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementCustomMetricInsertCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementAccountUserLinkDeleteCall<'a, C, A> {} -impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'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, CustomMetric)> { + pub fn doit(mut self) -> Result { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -21354,12 +22991,12 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.customMetrics.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.accountUserLinks.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); - params.push(("webPropertyId", self._web_property_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId"].iter() { + params.push(("linkId", self._link_id.to_string())); + for &field in ["accountId", "linkId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -21369,14 +23006,13 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -21388,7 +23024,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(2); - for param_name in ["webPropertyId", "accountId"].iter() { + for param_name in ["linkId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -21403,17 +23039,6 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut 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)); - } - } - }; + let result_value = res; dlg.finished(true); return Ok(result_value) @@ -21489,33 +23100,24 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// Account ID for the custom metric to create. + /// Account ID to delete the user link for. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID for the custom dimension to create. + /// Link ID to delete the user link for. /// - /// Sets the *web property id* path property to the given value. + /// Sets the *link 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 web_property_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C, A> { - self._web_property_id = new_value.to_string(); + pub fn link_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { + self._link_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -21524,7 +23126,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -21545,7 +23147,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementCustomMetricInsertCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementAccountUserLinkDeleteCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -21554,7 +23156,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementCustomMetricInsertCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementAccountUserLinkDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -21860,6 +23462,308 @@ impl<'a, C, A> ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< } +/// Update an existing experiment. +/// +/// A builder for the *experiments.update* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// use analytics3::Experiment; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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 = Experiment::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.management().experiments_update(req, "accountId", "webPropertyId", "profileId", "experimentId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementExperimentUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _request: Experiment, + _account_id: String, + _web_property_id: String, + _profile_id: String, + _experiment_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementExperimentUpdateCall<'a, C, A> {} + +impl<'a, C, A> ManagementExperimentUpdateCall<'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, Experiment)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.experiments.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("experimentId", self._experiment_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "profileId", "experimentId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId"), ("{experimentId}", "experimentId")].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 ["experimentId", "profileId", "webPropertyId", "accountId"].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: Experiment) -> ManagementExperimentUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID of the experiment to update. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID of the experiment to update. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// View (Profile) ID of the experiment to update. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Experiment ID of the experiment to update. + /// + /// Sets the *experiment 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 experiment_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C, A> { + self._experiment_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) -> ManagementExperimentUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementExperimentUpdateCall<'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) -> ManagementExperimentUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists web properties to which the user has access. /// /// A builder for the *webproperties.list* method supported by a *management* resource. @@ -21887,8 +23791,8 @@ impl<'a, C, A> ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.management().webproperties_list("accountId") -/// .start_index(-35) -/// .max_results(-65) +/// .start_index(-32) +/// .max_results(-101) /// .doit(); /// # } /// ``` @@ -22119,284 +24023,6 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Analytics::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 = EntityAdWordsLink::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.management().web_property_ad_words_links_insert(req, "accountId", "webPropertyId") -/// .doit(); -/// # } -/// ``` -pub struct ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Analytics, - _request: EntityAdWordsLink, - _account_id: String, - _web_property_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> {} - -impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'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, EntityAdWordsLink)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("accountId", self._account_id.to_string())); - params.push(("webPropertyId", self._web_property_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId"].iter() { - if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId")].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 ["webPropertyId", "accountId"].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: EntityAdWordsLink) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - self._request = new_value; - self - } - /// ID of the Google Analytics account to create the link for. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// Web property ID to create the link for. - /// - /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - self._web_property_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) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ManagementWebPropertyAdWordsLinkInsertCall<'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::Edit`. - /// - /// 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) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates an existing webProperty-AdWords link. This method supports patch semantics. /// /// A builder for the *webPropertyAdWordsLinks.patch* method supported by a *management* resource. @@ -22958,9 +24584,9 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut } -/// Deletes a web property-AdWords link. +/// Updates an existing custom metric. /// -/// A builder for the *webPropertyAdWordsLinks.delete* method supported by a *management* resource. +/// A builder for the *customMetrics.update* method supported by a *management* resource. /// It is not used directly, but through a `ManagementMethods` instance. /// /// # Example @@ -22971,6 +24597,7 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_analytics3 as analytics3; +/// use analytics3::CustomMetric; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -22981,32 +24608,40 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Analytics::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 = CustomMetric::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.management().web_property_ad_words_links_delete("accountId", "webPropertyId", "webPropertyAdWordsLinkId") +/// let result = hub.management().custom_metrics_update(req, "accountId", "webPropertyId", "customMetricId") +/// .ignore_custom_data_source_links(true) /// .doit(); /// # } /// ``` -pub struct ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> +pub struct ManagementCustomMetricUpdateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, + _request: CustomMetric, _account_id: String, _web_property_id: String, - _web_property_ad_words_link_id: String, + _custom_metric_id: String, + _ignore_custom_data_source_links: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementCustomMetricUpdateCall<'a, C, A> {} -impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, CustomMetric)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -23014,13 +24649,16 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.webPropertyAdWordsLinks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "analytics.management.customMetrics.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("webPropertyAdWordsLinkId", self._web_property_ad_words_link_id.to_string())); - for &field in ["accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() { + params.push(("customMetricId", self._custom_metric_id.to_string())); + if let Some(value) = self._ignore_custom_data_source_links { + params.push(("ignoreCustomDataSourceLinks", value.to_string())); + } + for &field in ["alt", "accountId", "webPropertyId", "customMetricId", "ignoreCustomDataSourceLinks"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -23030,13 +24668,14 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor params.push((&name, value.clone())); } + params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}".to_string(); + let mut url = "https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId")].iter() { + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{customMetricId}", "customMetricId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -23048,7 +24687,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor } { let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"].iter() { + for param_name in ["customMetricId", "webPropertyId", "accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -23063,6 +24702,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor 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 { @@ -23079,11 +24729,15 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor } }; 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::Delete, &url) + let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.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() @@ -23114,7 +24768,17 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor Ok(serr) => Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -23124,34 +24788,50 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor } - /// ID of the account which the given web property belongs to. + /// + /// 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: CustomMetric) -> ManagementCustomMetricUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID for the custom metric to update. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property ID to delete the AdWords link for. + /// Web property ID for the custom metric to update. /// /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { self._web_property_id = new_value.to_string(); self } - /// Web property AdWords link ID. + /// Custom metric ID for the custom metric to update. /// - /// Sets the *web property ad words link id* path property to the given value. + /// Sets the *custom metric 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 web_property_ad_words_link_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { - self._web_property_ad_words_link_id = new_value.to_string(); + pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C, A> { + self._custom_metric_id = new_value.to_string(); + self + } + /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set. + /// + /// Sets the *ignore custom data source links* query property to the given value. + pub fn ignore_custom_data_source_links(mut self, new_value: bool) -> ManagementCustomMetricUpdateCall<'a, C, A> { + self._ignore_custom_data_source_links = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -23160,7 +24840,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementCustomMetricUpdateCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -23181,7 +24861,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor /// * *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) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementCustomMetricUpdateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -23198,7 +24878,297 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor /// 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) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementCustomMetricUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing audiences. This method supports patch semantics. +/// +/// A builder for the *remarketingAudience.patch* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// use analytics3::RemarketingAudience; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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 = RemarketingAudience::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.management().remarketing_audience_patch(req, "accountId", "webPropertyId", "remarketingAudienceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagementRemarketingAudiencePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _request: RemarketingAudience, + _account_id: String, + _web_property_id: String, + _remarketing_audience_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementRemarketingAudiencePatchCall<'a, C, A> {} + +impl<'a, C, A> ManagementRemarketingAudiencePatchCall<'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, RemarketingAudience)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.remarketingAudience.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + params.push(("remarketingAudienceId", self._remarketing_audience_id.to_string())); + for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{remarketingAudienceId}", "remarketingAudienceId")].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 ["remarketingAudienceId", "webPropertyId", "accountId"].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: RemarketingAudience) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Account ID for the remarketing audience to update. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID for the remarketing audience to update. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// Remarketing audience ID of the remarketing audience to update. + /// + /// Sets the *remarketing audience 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 remarketing_audience_id(mut self, new_value: &str) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + self._remarketing_audience_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) -> ManagementRemarketingAudiencePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementRemarketingAudiencePatchCall<'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::Edit`. + /// + /// 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) -> ManagementRemarketingAudiencePatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -23801,8 +25771,8 @@ impl<'a, C, A> ManagementFilterPatchCall<'a, C, A> where C: BorrowMut ManagementProfileInsertCall<'a, C, A> where C: BorrowMut ManagementProfileInsertCall<'a, C, A> where C: BorrowMut +pub struct ManagementAccountUserLinkListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Analytics, _account_id: String, - _link_id: String, + _start_index: Option, + _max_results: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ManagementAccountUserLinkDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ManagementAccountUserLinkListCall<'a, C, A> {} -impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, EntityUserLinks)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -24613,542 +26586,17 @@ impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut< Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "analytics.management.accountUserLinks.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("accountId", self._account_id.to_string())); - params.push(("linkId", self._link_id.to_string())); - for &field in ["accountId", "linkId"].iter() { - if self._additional_params.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/analytics/v3/management/accounts/{accountId}/entityUserLinks/{linkId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::ManageUser.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{linkId}", "linkId")].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 ["linkId", "accountId"].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) - } - } - } - } - - - /// Account ID to delete the user link for. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// Link ID to delete the user link for. - /// - /// Sets the *link 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 link_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { - self._link_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) -> ManagementAccountUserLinkDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ManagementAccountUserLinkDeleteCall<'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::ManageUser`. - /// - /// 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) -> ManagementAccountUserLinkDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing view (profile). -/// -/// A builder for the *profiles.update* method supported by a *management* resource. -/// It is not used directly, but through a `ManagementMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_analytics3 as analytics3; -/// use analytics3::Profile; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use analytics3::Analytics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Analytics::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 = Profile::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.management().profiles_update(req, "accountId", "webPropertyId", "profileId") -/// .doit(); -/// # } -/// ``` -pub struct ManagementProfileUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Analytics, - _request: Profile, - _account_id: String, - _web_property_id: String, - _profile_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ManagementProfileUpdateCall<'a, C, A> {} - -impl<'a, C, A> ManagementProfileUpdateCall<'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, Profile)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "analytics.management.profiles.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("accountId", self._account_id.to_string())); - params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() { - if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Edit.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId"), ("{profileId}", "profileId")].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 ["profileId", "webPropertyId", "accountId"].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: Profile) -> ManagementProfileUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// Account ID to which the view (profile) belongs - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// Web property ID to which the view (profile) belongs - /// - /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { - self._web_property_id = new_value.to_string(); - self - } - /// ID of the view (profile) to be updated. - /// - /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C, A> { - self._profile_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) -> ManagementProfileUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ManagementProfileUpdateCall<'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::Edit`. - /// - /// 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) -> ManagementProfileUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns a single profile filter link. -/// -/// A builder for the *profileFilterLinks.get* method supported by a *management* resource. -/// It is not used directly, but through a `ManagementMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_analytics3 as analytics3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use analytics3::Analytics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Analytics::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.management().profile_filter_links_get("accountId", "webPropertyId", "profileId", "linkId") -/// .doit(); -/// # } -/// ``` -pub struct ManagementProfileFilterLinkGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Analytics, - _account_id: String, - _web_property_id: String, - _profile_id: String, - _link_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ManagementProfileFilterLinkGetCall<'a, C, A> {} - -impl<'a, C, A> ManagementProfileFilterLinkGetCall<'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, ProfileFilterLink)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "analytics.management.profileFilterLinks.get", + dlg.begin(MethodInfo { id: "analytics.management.accountUserLinks.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); - params.push(("webPropertyId", self._web_property_id.to_string())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("linkId", self._link_id.to_string())); - for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() { + if let Some(value) = self._start_index { + params.push(("start-index", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("max-results", value.to_string())); + } + for &field in ["alt", "accountId", "start-index", "max-results"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -25160,12 +26608,12 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -25176,8 +26624,8 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(4); - for param_name in ["linkId", "profileId", "webPropertyId", "accountId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["accountId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -25263,44 +26711,28 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkGetCall<'a, C, A> { + pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkListCall<'a, C, A> { self._account_id = new_value.to_string(); self } - /// Web property Id to retrieve profile filter link for. + /// An index of the first account-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. /// - /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { - self._web_property_id = new_value.to_string(); + /// Sets the *start-index* query property to the given value. + pub fn start_index(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C, A> { + self._start_index = Some(new_value); self } - /// Profile ID to retrieve filter link for. + /// The maximum number of account-user links to include in this response. /// - /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// ID of the profile filter link. - /// - /// Sets the *link 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 link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C, A> { - self._link_id = new_value.to_string(); + /// Sets the *max-results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'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 @@ -25309,7 +26741,7 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ManagementAccountUserLinkListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -25330,7 +26762,289 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ManagementProfileFilterLinkGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ManagementAccountUserLinkListCall<'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::ManageUserReadonly`. + /// + /// 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) -> ManagementAccountUserLinkListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists remarketing audiences to which the user has access. +/// +/// A builder for the *remarketingAudience.list* method supported by a *management* resource. +/// It is not used directly, but through a `ManagementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_analytics3 as analytics3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use analytics3::Analytics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Analytics::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.management().remarketing_audience_list("accountId", "webPropertyId") +/// .type_("vero") +/// .start_index(-91) +/// .max_results(-8) +/// .doit(); +/// # } +/// ``` +pub struct ManagementRemarketingAudienceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Analytics, + _account_id: String, + _web_property_id: String, + _type_: Option, + _start_index: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagementRemarketingAudienceListCall<'a, C, A> {} + +impl<'a, C, A> ManagementRemarketingAudienceListCall<'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, RemarketingAudiences)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "analytics.management.remarketingAudience.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("webPropertyId", self._web_property_id.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._start_index { + params.push(("start-index", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("max-results", value.to_string())); + } + for &field in ["alt", "accountId", "webPropertyId", "type", "start-index", "max-results"].iter() { + if self._additional_params.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/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{webPropertyId}", "webPropertyId")].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 ["webPropertyId", "accountId"].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) + } + } + } + } + + + /// Account ID for the remarketing audience to retrieve. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Web property ID for the remarketing audience to retrieve. + /// + /// Sets the *web property 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 web_property_id(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C, A> { + self._web_property_id = new_value.to_string(); + self + } + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C, A> { + self._type_ = Some(new_value.to_string()); + self + } + /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. + /// + /// Sets the *start-index* query property to the given value. + pub fn start_index(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'a, C, A> { + self._start_index = Some(new_value); + self + } + /// The maximum number of remarketing audiences to include in this response. + /// + /// Sets the *max-results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'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) -> ManagementRemarketingAudienceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagementRemarketingAudienceListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -25347,7 +27061,7 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ManagementProfileFilterLinkGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ManagementRemarketingAudienceListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -25382,12 +27096,12 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut DataMcfGetCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.data().ga_get("ids", "start-date", "end-date", "metrics") -/// .start_index(-91) -/// .sort("takimata") -/// .segment("dolores") -/// .sampling_level("consetetur") -/// .output("erat") -/// .max_results(-52) +/// .start_index(-32) +/// .sort("gubergren") +/// .segment("sit") +/// .sampling_level("gubergren") +/// .output("sit") +/// .max_results(-97) /// .include_empty_rows(true) -/// .filters("dolores") -/// .dimensions("et") +/// .filters("sanctus") +/// .dimensions("Lorem") /// .doit(); /// # } /// ``` @@ -26062,10 +27776,10 @@ impl<'a, C, A> DataGaGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.data().realtime_get("ids", "metrics") -/// .sort("aliquyam") -/// .max_results(-91) -/// .filters("sit") -/// .dimensions("aliquyam") +/// .sort("eirmod") +/// .max_results(-45) +/// .filters("Lorem") +/// .dimensions("sed") /// .doit(); /// # } /// ``` diff --git a/gen/androidenterprise1-cli/Cargo.toml b/gen/androidenterprise1-cli/Cargo.toml index 129109c2bb..22f133454c 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+20160331" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "androidenterprise1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-androidenterprise1/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-androidenterprise1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-androidenterprise1] diff --git a/gen/androidenterprise1-cli/README.md b/gen/androidenterprise1-cli/README.md index c34cbc5ecf..a493c71405 100644 --- a/gen/androidenterprise1-cli/README.md +++ b/gen/androidenterprise1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Android Enterprise* API at revision *20160331*. 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 *0.3.6*. ```bash androidenterprise1 [options] @@ -47,12 +47,17 @@ androidenterprise1 [options] list [-p ]... [-o ] set-state (-r )... [-p ]... [-o ] enterprises + acknowledge-notification-set [-p ]... + complete-signup [-p ]... [-o ] delete [-p ]... enroll (-r )... [-p ]... [-o ] + generate-signup-url [-p ]... [-o ] get [-p ]... [-o ] + get-service-account [-p ]... [-o ] get-store-layout [-p ]... [-o ] insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] + pull-notification-set [-p ]... [-o ] send-test-push-notification [-p ]... [-o ] set-account (-r )... [-p ]... [-o ] set-store-layout (-r )... [-p ]... [-o ] @@ -74,6 +79,18 @@ androidenterprise1 [options] list [-p ]... [-o ] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] + managedconfigurationsfordevice + delete [-p ]... + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + managedconfigurationsforuser + delete [-p ]... + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] permissions get [-p ]... [-o ] products @@ -82,7 +99,13 @@ androidenterprise1 [options] get [-p ]... [-o ] get-app-restrictions-schema [-p ]... [-o ] get-permissions [-p ]... [-o ] + list [-p ]... [-o ] + unapprove [-p ]... update-permissions (-r )... [-p ]... [-o ] + serviceaccountkeys + delete [-p ]... + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] storelayoutclusters delete [-p ]... get [-p ]... [-o ] @@ -98,12 +121,17 @@ androidenterprise1 [options] patch (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] users + delete [-p ]... + generate-authentication-token [-p ]... [-o ] generate-token [-p ]... [-o ] get [-p ]... [-o ] get-available-product-set [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] revoke-token [-p ]... set-available-product-set (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] androidenterprise1 --help Configuration: diff --git a/gen/androidenterprise1-cli/mkdocs.yml b/gen/androidenterprise1-cli/mkdocs.yml index 8cb4d64671..c326ef3c52 100644 --- a/gen/androidenterprise1-cli/mkdocs.yml +++ b/gen/androidenterprise1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Enterprise v0.3.6+20160331 +site_name: Android Enterprise v0.3.6+20160831 site_url: http://byron.github.io/google-apis-rs/google-androidenterprise1-cli site_description: Write integrating applications with bcore @@ -24,12 +24,17 @@ pages: - ['devices_get-state.md', 'Devices', 'Get State'] - ['devices_list.md', 'Devices', 'List'] - ['devices_set-state.md', 'Devices', 'Set State'] +- ['enterprises_acknowledge-notification-set.md', 'Enterprises', 'Acknowledge Notification Set'] +- ['enterprises_complete-signup.md', 'Enterprises', 'Complete Signup'] - ['enterprises_delete.md', 'Enterprises', 'Delete'] - ['enterprises_enroll.md', 'Enterprises', 'Enroll'] +- ['enterprises_generate-signup-url.md', 'Enterprises', 'Generate Signup Url'] - ['enterprises_get.md', 'Enterprises', 'Get'] +- ['enterprises_get-service-account.md', 'Enterprises', 'Get Service Account'] - ['enterprises_get-store-layout.md', 'Enterprises', 'Get Store Layout'] - ['enterprises_insert.md', 'Enterprises', 'Insert'] - ['enterprises_list.md', 'Enterprises', 'List'] +- ['enterprises_pull-notification-set.md', 'Enterprises', 'Pull Notification Set'] - ['enterprises_send-test-push-notification.md', 'Enterprises', 'Send Test Push Notification'] - ['enterprises_set-account.md', 'Enterprises', 'Set Account'] - ['enterprises_set-store-layout.md', 'Enterprises', 'Set Store Layout'] @@ -47,13 +52,28 @@ pages: - ['installs_list.md', 'Installs', 'List'] - ['installs_patch.md', 'Installs', 'Patch'] - ['installs_update.md', 'Installs', 'Update'] +- ['managedconfigurationsfordevice_delete.md', 'Managedconfigurationsfordevice', 'Delete'] +- ['managedconfigurationsfordevice_get.md', 'Managedconfigurationsfordevice', 'Get'] +- ['managedconfigurationsfordevice_list.md', 'Managedconfigurationsfordevice', 'List'] +- ['managedconfigurationsfordevice_patch.md', 'Managedconfigurationsfordevice', 'Patch'] +- ['managedconfigurationsfordevice_update.md', 'Managedconfigurationsfordevice', 'Update'] +- ['managedconfigurationsforuser_delete.md', 'Managedconfigurationsforuser', 'Delete'] +- ['managedconfigurationsforuser_get.md', 'Managedconfigurationsforuser', 'Get'] +- ['managedconfigurationsforuser_list.md', 'Managedconfigurationsforuser', 'List'] +- ['managedconfigurationsforuser_patch.md', 'Managedconfigurationsforuser', 'Patch'] +- ['managedconfigurationsforuser_update.md', 'Managedconfigurationsforuser', 'Update'] - ['permissions_get.md', 'Permissions', 'Get'] - ['products_approve.md', 'Products', 'Approve'] - ['products_generate-approval-url.md', 'Products', 'Generate Approval Url'] - ['products_get.md', 'Products', 'Get'] - ['products_get-app-restrictions-schema.md', 'Products', 'Get App Restrictions Schema'] - ['products_get-permissions.md', 'Products', 'Get Permissions'] +- ['products_list.md', 'Products', 'List'] +- ['products_unapprove.md', 'Products', 'Unapprove'] - ['products_update-permissions.md', 'Products', 'Update Permissions'] +- ['serviceaccountkeys_delete.md', 'Serviceaccountkeys', 'Delete'] +- ['serviceaccountkeys_insert.md', 'Serviceaccountkeys', 'Insert'] +- ['serviceaccountkeys_list.md', 'Serviceaccountkeys', 'List'] - ['storelayoutclusters_delete.md', 'Storelayoutclusters', 'Delete'] - ['storelayoutclusters_get.md', 'Storelayoutclusters', 'Get'] - ['storelayoutclusters_insert.md', 'Storelayoutclusters', 'Insert'] @@ -66,12 +86,17 @@ pages: - ['storelayoutpages_list.md', 'Storelayoutpages', 'List'] - ['storelayoutpages_patch.md', 'Storelayoutpages', 'Patch'] - ['storelayoutpages_update.md', 'Storelayoutpages', 'Update'] +- ['users_delete.md', 'Users', 'Delete'] +- ['users_generate-authentication-token.md', 'Users', 'Generate Authentication Token'] - ['users_generate-token.md', 'Users', 'Generate Token'] - ['users_get.md', 'Users', 'Get'] - ['users_get-available-product-set.md', 'Users', 'Get Available Product Set'] +- ['users_insert.md', 'Users', 'Insert'] - ['users_list.md', 'Users', 'List'] +- ['users_patch.md', 'Users', 'Patch'] - ['users_revoke-token.md', 'Users', 'Revoke Token'] - ['users_set-available-product-set.md', 'Users', 'Set Available Product Set'] +- ['users_update.md', 'Users', 'Update'] theme: readthedocs diff --git a/gen/androidenterprise1-cli/src/main.rs b/gen/androidenterprise1-cli/src/main.rs index 77a085655a..e7da9d9fcc 100644 --- a/gen/androidenterprise1-cli/src/main.rs +++ b/gen/androidenterprise1-cli/src/main.rs @@ -632,10 +632,14 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-identifier" => Some(("accountIdentifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "management-type" => Some(("managementType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "primary-email" => Some(("primaryEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-type" => Some(("accountType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "primary-email"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-identifier", "account-type", "display-name", "id", "kind", "management-type", "primary-email"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -719,10 +723,14 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-identifier" => Some(("accountIdentifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "management-type" => Some(("managementType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "primary-email" => Some(("primaryEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-type" => Some(("accountType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "primary-email"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-identifier", "account-type", "display-name", "id", "kind", "management-type", "primary-email"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1024,6 +1032,113 @@ impl<'n> Engine<'n> { } } + fn _enterprises_acknowledge_notification_set(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.enterprises().acknowledge_notification_set(); + for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "notification-set-id" => { + call = call.notification_set_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(["notification-set-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _enterprises_complete_signup(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.enterprises().complete_signup(); + for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "enterprise-token" => { + call = call.enterprise_token(value.unwrap_or("")); + }, + "completion-token" => { + call = call.completion_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(["enterprise-token", "completion-token"].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 _enterprises_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.enterprises().delete(opt.value_of("enterprise-id").unwrap_or("")); @@ -1156,6 +1271,62 @@ impl<'n> Engine<'n> { } } + fn _enterprises_generate_signup_url(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.enterprises().generate_signup_url(); + for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "callback-url" => { + call = call.callback_url(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(["callback-url"].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 _enterprises_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.enterprises().get(opt.value_of("enterprise-id").unwrap_or("")); @@ -1208,6 +1379,62 @@ impl<'n> Engine<'n> { } } + fn _enterprises_get_service_account(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.enterprises().get_service_account(opt.value_of("enterprise-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 { + "key-type" => { + call = call.key_type(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(["key-type"].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 _enterprises_get_store_layout(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.enterprises().get_store_layout(opt.value_of("enterprise-id").unwrap_or("")); @@ -1400,6 +1627,62 @@ impl<'n> Engine<'n> { } } + fn _enterprises_pull_notification_set(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.enterprises().pull_notification_set(); + for parg in 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-mode" => { + call = call.request_mode(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-mode"].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 _enterprises_send_test_push_notification(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.enterprises().send_test_push_notification(opt.value_of("enterprise-id").unwrap_or("")); @@ -2478,6 +2761,646 @@ impl<'n> Engine<'n> { } } + fn _managedconfigurationsfordevice_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsfordevice().delete(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("device-id").unwrap_or(""), opt.value_of("managed-configuration-for-device-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _managedconfigurationsfordevice_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsfordevice().get(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("device-id").unwrap_or(""), opt.value_of("managed-configuration-for-device-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 _managedconfigurationsfordevice_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsfordevice().list(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("device-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 _managedconfigurationsfordevice_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 })), + "product-id" => Some(("productId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "product-id"]); + 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::ManagedConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.managedconfigurationsfordevice().patch(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("device-id").unwrap_or(""), opt.value_of("managed-configuration-for-device-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 _managedconfigurationsfordevice_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 })), + "product-id" => Some(("productId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "product-id"]); + 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::ManagedConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.managedconfigurationsfordevice().update(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("device-id").unwrap_or(""), opt.value_of("managed-configuration-for-device-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 _managedconfigurationsforuser_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsforuser().delete(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("managed-configuration-for-user-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _managedconfigurationsforuser_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsforuser().get(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("managed-configuration-for-user-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 _managedconfigurationsforuser_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.managedconfigurationsforuser().list(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-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 _managedconfigurationsforuser_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 })), + "product-id" => Some(("productId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "product-id"]); + 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::ManagedConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.managedconfigurationsforuser().patch(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("managed-configuration-for-user-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 _managedconfigurationsforuser_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 })), + "product-id" => Some(("productId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "product-id"]); + 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::ManagedConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.managedconfigurationsforuser().update(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or(""), opt.value_of("managed-configuration-for-user-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 _permissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.permissions().get(opt.value_of("permission-id").unwrap_or("")); @@ -2832,6 +3755,118 @@ impl<'n> Engine<'n> { } } + fn _products_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.products().list(opt.value_of("enterprise-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 { + "token" => { + call = call.token(value.unwrap_or("")); + }, + "query" => { + call = call.query(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "language" => { + call = call.language(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "boolean")); + }, + _ => { + 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(["query", "token", "language", "max-results", "approved"].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 _products_unapprove(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.products().unapprove(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("product-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + fn _products_update_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { @@ -2918,6 +3953,190 @@ impl<'n> Engine<'n> { } } + fn _serviceaccountkeys_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.serviceaccountkeys().delete(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("key-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _serviceaccountkeys_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()[..] { + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "data" => Some(("data", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["data", "id", "kind", "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::ServiceAccountKey = json::value::from_value(object).unwrap(); + let mut call = self.hub.serviceaccountkeys().insert(request, opt.value_of("enterprise-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 _serviceaccountkeys_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.serviceaccountkeys().list(opt.value_of("enterprise-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 _storelayoutclusters_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.storelayoutclusters().delete(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("page-id").unwrap_or(""), opt.value_of("cluster-id").unwrap_or("")); @@ -3739,6 +4958,102 @@ impl<'n> Engine<'n> { } } + fn _users_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().delete(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _users_generate_authentication_token(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().generate_authentication_token(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-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 _users_generate_token(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.users().generate_token(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or("")); @@ -3895,6 +5210,97 @@ impl<'n> Engine<'n> { } } + fn _users_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 })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-identifier" => Some(("accountIdentifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "management-type" => Some(("managementType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-email" => Some(("primaryEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-type" => Some(("accountType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-identifier", "account-type", "display-name", "id", "kind", "management-type", "primary-email"]); + 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::User = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().insert(request, opt.value_of("enterprise-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 _users_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.users().list(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("email").unwrap_or("")); @@ -3947,6 +5353,97 @@ impl<'n> Engine<'n> { } } + fn _users_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 })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-identifier" => Some(("accountIdentifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "management-type" => Some(("managementType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-email" => Some(("primaryEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-type" => Some(("accountType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-identifier", "account-type", "display-name", "id", "kind", "management-type", "primary-email"]); + 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::User = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().patch(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-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 _users_revoke_token(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.users().revoke_token(opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-id").unwrap_or("")); @@ -4077,6 +5574,97 @@ impl<'n> Engine<'n> { } } + fn _users_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 })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-identifier" => Some(("accountIdentifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "management-type" => Some(("managementType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-email" => Some(("primaryEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-type" => Some(("accountType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-identifier", "account-type", "display-name", "id", "kind", "management-type", "primary-email"]); + 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::User = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().update(request, opt.value_of("enterprise-id").unwrap_or(""), opt.value_of("user-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(()); @@ -4153,15 +5741,27 @@ impl<'n> Engine<'n> { }, ("enterprises", Some(opt)) => { match opt.subcommand() { + ("acknowledge-notification-set", Some(opt)) => { + call_result = self._enterprises_acknowledge_notification_set(opt, dry_run, &mut err); + }, + ("complete-signup", Some(opt)) => { + call_result = self._enterprises_complete_signup(opt, dry_run, &mut err); + }, ("delete", Some(opt)) => { call_result = self._enterprises_delete(opt, dry_run, &mut err); }, ("enroll", Some(opt)) => { call_result = self._enterprises_enroll(opt, dry_run, &mut err); }, + ("generate-signup-url", Some(opt)) => { + call_result = self._enterprises_generate_signup_url(opt, dry_run, &mut err); + }, ("get", Some(opt)) => { call_result = self._enterprises_get(opt, dry_run, &mut err); }, + ("get-service-account", Some(opt)) => { + call_result = self._enterprises_get_service_account(opt, dry_run, &mut err); + }, ("get-store-layout", Some(opt)) => { call_result = self._enterprises_get_store_layout(opt, dry_run, &mut err); }, @@ -4171,6 +5771,9 @@ impl<'n> Engine<'n> { ("list", Some(opt)) => { call_result = self._enterprises_list(opt, dry_run, &mut err); }, + ("pull-notification-set", Some(opt)) => { + call_result = self._enterprises_pull_notification_set(opt, dry_run, &mut err); + }, ("send-test-push-notification", Some(opt)) => { call_result = self._enterprises_send_test_push_notification(opt, dry_run, &mut err); }, @@ -4260,6 +5863,52 @@ impl<'n> Engine<'n> { } } }, + ("managedconfigurationsfordevice", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._managedconfigurationsfordevice_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._managedconfigurationsfordevice_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._managedconfigurationsfordevice_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._managedconfigurationsfordevice_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._managedconfigurationsfordevice_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("managedconfigurationsfordevice".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("managedconfigurationsforuser", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._managedconfigurationsforuser_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._managedconfigurationsforuser_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._managedconfigurationsforuser_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._managedconfigurationsforuser_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._managedconfigurationsforuser_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("managedconfigurationsforuser".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, ("permissions", Some(opt)) => { match opt.subcommand() { ("get", Some(opt)) => { @@ -4288,6 +5937,12 @@ impl<'n> Engine<'n> { ("get-permissions", Some(opt)) => { call_result = self._products_get_permissions(opt, dry_run, &mut err); }, + ("list", Some(opt)) => { + call_result = self._products_list(opt, dry_run, &mut err); + }, + ("unapprove", Some(opt)) => { + call_result = self._products_unapprove(opt, dry_run, &mut err); + }, ("update-permissions", Some(opt)) => { call_result = self._products_update_permissions(opt, dry_run, &mut err); }, @@ -4297,6 +5952,23 @@ impl<'n> Engine<'n> { } } }, + ("serviceaccountkeys", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._serviceaccountkeys_delete(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._serviceaccountkeys_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._serviceaccountkeys_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("serviceaccountkeys".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, ("storelayoutclusters", Some(opt)) => { match opt.subcommand() { ("delete", Some(opt)) => { @@ -4351,6 +6023,12 @@ impl<'n> Engine<'n> { }, ("users", Some(opt)) => { match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._users_delete(opt, dry_run, &mut err); + }, + ("generate-authentication-token", Some(opt)) => { + call_result = self._users_generate_authentication_token(opt, dry_run, &mut err); + }, ("generate-token", Some(opt)) => { call_result = self._users_generate_token(opt, dry_run, &mut err); }, @@ -4360,15 +6038,24 @@ impl<'n> Engine<'n> { ("get-available-product-set", Some(opt)) => { call_result = self._users_get_available_product_set(opt, dry_run, &mut err); }, + ("insert", Some(opt)) => { + call_result = self._users_insert(opt, dry_run, &mut err); + }, ("list", Some(opt)) => { call_result = self._users_list(opt, dry_run, &mut err); }, + ("patch", Some(opt)) => { + call_result = self._users_patch(opt, dry_run, &mut err); + }, ("revoke-token", Some(opt)) => { call_result = self._users_revoke_token(opt, dry_run, &mut err); }, ("set-available-product-set", Some(opt)) => { call_result = self._users_set_available_product_set(opt, dry_run, &mut err); }, + ("update", Some(opt)) => { + call_result = self._users_update(opt, dry_run, &mut err); + }, _ => { err.issues.push(CLIError::MissingMethodError("users".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); @@ -4837,7 +6524,7 @@ fn main() { Some(false)), ]), ("get-state", - Some(r##"Retrieves whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services."##), + Some(r##"Retrieves whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/devices_get-state", vec![ (Some(r##"enterprise-id"##), @@ -4899,7 +6586,7 @@ fn main() { Some(false)), ]), ("set-state", - Some(r##"Sets whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services."##), + Some(r##"Sets whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/devices_set-state", vec![ (Some(r##"enterprise-id"##), @@ -4940,7 +6627,33 @@ fn main() { ]), ]), - ("enterprises", "methods: 'delete', 'enroll', 'get', 'get-store-layout', 'insert', 'list', 'send-test-push-notification', 'set-account', 'set-store-layout' and 'unenroll'", vec![ + ("enterprises", "methods: 'acknowledge-notification-set', 'complete-signup', 'delete', 'enroll', 'generate-signup-url', 'get', 'get-service-account', 'get-store-layout', 'insert', 'list', 'pull-notification-set', 'send-test-push-notification', 'set-account', 'set-store-layout' and 'unenroll'", vec![ + ("acknowledge-notification-set", + Some(r##"Acknowledges notifications that were received from Enterprises.PullNotificationSet to prevent subsequent calls from returning the same notifications."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_acknowledge-notification-set", + vec![ + (Some(r##"v"##), + Some(r##"p"##), + Some(r##"Set various optional parameters, matching the key=value form"##), + Some(false), + Some(true)), + ]), + ("complete-signup", + Some(r##"Completes the signup flow, by specifying the Completion token and Enterprise token. This request must not be called multiple times for a given Enterprise Token."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_complete-signup", + 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)), + ]), ("delete", Some(r##"Deletes the binding between the EMM and enterprise. This is now deprecated; use this to unenroll customers that were previously enrolled with the 'insert' call, then enroll them again with the 'enroll' call."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_delete", @@ -4979,6 +6692,22 @@ fn main() { 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)), + ]), + ("generate-signup-url", + Some(r##"Generates a sign-up URL."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_generate-signup-url", + 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"##), @@ -5001,6 +6730,34 @@ fn main() { 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-service-account", + Some(r##"Returns a service account and credentials. The service account can be bound to the enterprise by calling setAccount. The service account is unique to this enterprise and EMM, and will be deleted if the enterprise is unbound. The credentials contain private key data and are not stored server-side. + + This method can only be called after calling Enterprises.Enroll or Enterprises.CompleteSignup, and before Enterprises.SetAccount; at other times it will return an error. + + Subsequent calls after the first will generate a new, unique set of credentials, and invalidate the previously generated credentials. + + Once the service account is bound to the enterprise, it can be managed using the serviceAccountKeys resource."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_get-service-account", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + 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"##), @@ -5008,7 +6765,7 @@ fn main() { Some(false)), ]), ("get-store-layout", - Some(r##"Returns the store layout resource."##), + Some(r##"Returns the store layout for the enterprise. If the store layout has not been set, or if the store layout has no homepageId set, returns a NOT_FOUND error."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_get-store-layout", vec![ (Some(r##"enterprise-id"##), @@ -5058,7 +6815,7 @@ fn main() { Some(false)), ]), ("list", - Some(r##"Looks up an enterprise by domain name."##), + Some(r##"Looks up an enterprise by domain name. This is only supported for enterprises created via the Google-initiated creation flow. Lookup of the id is not needed for enterprises created via the EMM-initiated flow since the EMM learns the enterprise ID in the callback specified in the Enterprises.generateSignupUrl call."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_list", vec![ (Some(r##"domain"##), @@ -5073,6 +6830,25 @@ fn main() { 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)), + ]), + ("pull-notification-set", + Some(r##"Pulls and returns a notification set for the enterprises associated with the service account authenticated for the request. The notification set may be empty if no notification are pending. + A notification set returned needs to be acknowledged within 20 seconds by calling Enterprises.AcknowledgeNotificationSet, unless the notification set is empty. + Notifications that are not acknowledged within the 20 seconds will eventually be included again in the response to another PullNotificationSet request, and those that are never acknowledged will ultimately be deleted according to the Google Cloud Platform Pub/Sub system policy. + Multiple requests might be performed concurrently to retrieve notifications, in which case the pending notifications (if any) will be split among each caller, if any are pending."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_pull-notification-set", + 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"##), @@ -5130,7 +6906,7 @@ fn main() { Some(false)), ]), ("set-store-layout", - Some(r##"Sets the store layout resource."##), + Some(r##"Sets the store layout for the enterprise."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/enterprises_set-store-layout", vec![ (Some(r##"enterprise-id"##), @@ -5635,6 +7411,382 @@ fn main() { ]), ]), + ("managedconfigurationsfordevice", "methods: 'delete', 'get', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Removes a per-device managed configuration for an app for the specified device."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsfordevice_delete", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"device-id"##), + None, + Some(r##"The Android ID of the device."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-device-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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 details of a per-device managed configuration."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsfordevice_get", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"device-id"##), + None, + Some(r##"The Android ID of the device."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-device-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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##"Lists all the per-device managed configurations for the specified device. Only the ID is set."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsfordevice_list", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"device-id"##), + None, + Some(r##"The Android ID of the device."##), + 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##"Adds or updates a per-device managed configuration for an app for the specified device. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsfordevice_patch", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"device-id"##), + None, + Some(r##"The Android ID of the device."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-device-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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##"Adds or updates a per-device managed configuration for an app for the specified device."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsfordevice_update", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"device-id"##), + None, + Some(r##"The Android ID of the device."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-device-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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)), + ]), + ]), + + ("managedconfigurationsforuser", "methods: 'delete', 'get', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Removes a per-user managed configuration for an app for the specified user."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsforuser_delete", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-user-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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 details of a per-user managed configuration for an app for the specified user."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsforuser_get", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-user-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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##"Lists all the per-user managed configurations for the specified user. Only the ID is set."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsforuser_list", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + 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##"Adds or updates a per-user managed configuration for an app for the specified user. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsforuser_patch", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-user-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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##"Adds or updates a per-user managed configuration for an app for the specified user."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/managedconfigurationsforuser_update", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + Some(true), + Some(false)), + + (Some(r##"managed-configuration-for-user-id"##), + None, + Some(r##"The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm"."##), + 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)), + ]), + ]), + ("permissions", "methods: 'get'", vec![ ("get", Some(r##"Retrieves details of an Android app permission for display to an enterprise admin."##), @@ -5660,9 +7812,11 @@ fn main() { ]), ]), - ("products", "methods: 'approve', 'generate-approval-url', 'get', 'get-app-restrictions-schema', 'get-permissions' and 'update-permissions'", vec![ + ("products", "methods: 'approve', 'generate-approval-url', 'get', 'get-app-restrictions-schema', 'get-permissions', 'list', 'unapprove' and 'update-permissions'", vec![ ("approve", - Some(r##"Approves the specified product (and the relevant app permissions, if any)."##), + Some(r##"Approves the specified product and the relevant app permissions, if any. The maximum number of products that you can approve per enterprise customer is 1,000. + + To learn how to use Google Play for Work to design and create a store layout to display approved products to your users, see Store Layout Design."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/products_approve", vec![ (Some(r##"enterprise-id"##), @@ -5748,7 +7902,7 @@ fn main() { Some(false)), ]), ("get-app-restrictions-schema", - Some(r##"Retrieves the schema defining app restrictions configurable for this product. All products have a schema, but this may be empty if no app restrictions are defined."##), + Some(r##"Retrieves the schema that defines the configurable properties for this product. All products have a schema, but this schema may be empty if no managed configurations have been defined. This schema can be used to populate a UI that allows an administrator to configure the product. To apply a managed configuration based on the schema obtained using this API, see Managed Configurations through Play."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/products_get-app-restrictions-schema", vec![ (Some(r##"enterprise-id"##), @@ -5803,6 +7957,50 @@ fn main() { Some(false), Some(false)), ]), + ("list", + Some(r##"Finds approved products that match a query, or all approved products if there is no query."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/products_list", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + 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)), + ]), + ("unapprove", + Some(r##"Unapproves the specified product (and the relevant app permissions, if any)"##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/products_unapprove", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"product-id"##), + None, + Some(r##"The ID of the product."##), + 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)), + ]), ("update-permissions", Some(r##"This method has been deprecated. To programmatically approve applications, you must use the iframe mechanism via the generateApprovalUrl and approve methods of the Products resource. For more information, see the Play EMM API usage requirements. @@ -5841,6 +8039,83 @@ fn main() { ]), ]), + ("serviceaccountkeys", "methods: 'delete', 'insert' and 'list'", vec![ + ("delete", + Some(r##"Removes and invalidates the specified credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/serviceaccountkeys_delete", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"key-id"##), + None, + Some(r##"The ID of the key."##), + 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)), + ]), + ("insert", + Some(r##"Generates new credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. + + Only the type of the key should be populated in the resource to be inserted."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/serviceaccountkeys_insert", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + 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##"Lists all active credentials for the service account associated with this enterprise. Only the ID and key type are returned. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/serviceaccountkeys_list", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + 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)), + ]), + ]), + ("storelayoutclusters", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ ("delete", Some(r##"Deletes a cluster."##), @@ -6219,7 +8494,59 @@ fn main() { ]), ]), - ("users", "methods: 'generate-token', 'get', 'get-available-product-set', 'list', 'revoke-token' and 'set-available-product-set'", vec![ + ("users", "methods: 'delete', 'generate-authentication-token', 'generate-token', 'get', 'get-available-product-set', 'insert', 'list', 'patch', 'revoke-token', 'set-available-product-set' and 'update'", vec![ + ("delete", + Some(r##"Deleted an EMM-managed user."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_delete", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + 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)), + ]), + ("generate-authentication-token", + Some(r##"Generates an authentication token which the device policy client can use to provision the given EMM-managed user account on a device. The generated token is single-use and expires after a few minutes. + + This call only works with EMM-managed accounts."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_generate-authentication-token", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + 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)), + ]), ("generate-token", Some(r##"Generates a token (activation code) to allow this user to configure their work account in the Android Setup Wizard. Revokes any previously generated token. @@ -6300,6 +8627,36 @@ fn main() { 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 new EMM-managed user. + + The Users resource passed in the body of the request should include an accountIdentifier and an accountType."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_insert", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + 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"##), @@ -6307,7 +8664,7 @@ fn main() { Some(false)), ]), ("list", - Some(r##"Looks up a user by their primary email address."##), + Some(r##"Looks up a user by primary email address. This is only supported for Google-managed users. Lookup of the id is not needed for EMM-managed users because the id is already returned in the result of the Users.insert call."##), "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_list", vec![ (Some(r##"enterprise-id"##), @@ -6328,6 +8685,42 @@ fn main() { 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 details of an EMM-managed user. + + Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_patch", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + 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"##), @@ -6384,6 +8777,42 @@ fn main() { 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 details of an EMM-managed user. + + Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value."##), + "Details at http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/users_update", + vec![ + (Some(r##"enterprise-id"##), + None, + Some(r##"The ID of the enterprise."##), + Some(true), + Some(false)), + + (Some(r##"user-id"##), + None, + Some(r##"The ID of the user."##), + 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"##), @@ -6396,7 +8825,7 @@ fn main() { let mut app = App::new("androidenterprise1") .author("Sebastian Thiel ") - .version("0.3.6+20160331") + .version("0.3.6+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/androidenterprise1/Cargo.toml b/gen/androidenterprise1/Cargo.toml index fc1f1d6d19..b71cd49f4d 100644 --- a/gen/androidenterprise1/Cargo.toml +++ b/gen/androidenterprise1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidenterprise1" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/androidenterprise1/README.md b/gen/androidenterprise1/README.md index 7db7c76cff..5d320c42c7 100644 --- a/gen/androidenterprise1/README.md +++ b/gen/androidenterprise1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-androidenterprise1` library allows access to all features of the *Google Android Enterprise* service. -This documentation was generated from *Android Enterprise* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Android Enterprise* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Android Enterprise* *v1* API can be found at the [official documentation site](https://developers.google.com/android/work/play/emm-api). @@ -20,7 +20,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [devices](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Device.html) * [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.DeviceGetCall.html), [*get state*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.DeviceGetStateCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.DeviceListCall.html) and [*set state*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.DeviceSetStateCall.html) * [enterprises](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Enterprise.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseDeleteCall.html), [*enroll*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseEnrollCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGetCall.html), [*get store layout*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGetStoreLayoutCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseListCall.html), [*send test push notification*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSendTestPushNotificationCall.html), [*set account*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSetAccountCall.html), [*set store layout*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSetStoreLayoutCall.html) and [*unenroll*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseUnenrollCall.html) + * [*acknowledge notification set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseAcknowledgeNotificationSetCall.html), [*complete signup*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseCompleteSignupCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseDeleteCall.html), [*enroll*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseEnrollCall.html), [*generate signup url*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGenerateSignupUrlCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGetCall.html), [*get service account*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGetServiceAccountCall.html), [*get store layout*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseGetStoreLayoutCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseListCall.html), [*pull notification set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterprisePullNotificationSetCall.html), [*send test push notification*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSendTestPushNotificationCall.html), [*set account*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSetAccountCall.html), [*set store layout*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseSetStoreLayoutCall.html) and [*unenroll*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EnterpriseUnenrollCall.html) * [entitlements](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Entitlement.html) * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EntitlementDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EntitlementGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EntitlementListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EntitlementPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.EntitlementUpdateCall.html) * grouplicenses @@ -29,16 +29,22 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.GrouplicenseuserListCall.html) * [installs](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Install.html) * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.InstallDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.InstallGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.InstallListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.InstallPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.InstallUpdateCall.html) +* managedconfigurationsfordevice + * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsfordeviceDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsfordeviceGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsfordeviceListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsfordevicePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsfordeviceUpdateCall.html) +* managedconfigurationsforuser + * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsforuserDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsforuserGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsforuserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsforuserPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ManagedconfigurationsforuserUpdateCall.html) * [permissions](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Permission.html) * [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.PermissionGetCall.html) * [products](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.Product.html) - * [*approve*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductApproveCall.html), [*generate approval url*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGenerateApprovalUrlCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetCall.html), [*get app restrictions schema*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetAppRestrictionsSchemaCall.html), [*get permissions*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetPermissionCall.html) and [*update permissions*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductUpdatePermissionCall.html) + * [*approve*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductApproveCall.html), [*generate approval url*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGenerateApprovalUrlCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetCall.html), [*get app restrictions schema*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetAppRestrictionsSchemaCall.html), [*get permissions*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductGetPermissionCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductListCall.html), [*unapprove*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductUnapproveCall.html) and [*update permissions*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ProductUpdatePermissionCall.html) +* serviceaccountkeys + * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ServiceaccountkeyDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ServiceaccountkeyInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.ServiceaccountkeyListCall.html) * storelayoutclusters * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutclusterUpdateCall.html) * storelayoutpages * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpageDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpageGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpageInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpageListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpagePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.StorelayoutpageUpdateCall.html) * [users](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.User.html) - * [*generate token*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGenerateTokenCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGetCall.html), [*get available product set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGetAvailableProductSetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserListCall.html), [*revoke token*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserRevokeTokenCall.html) and [*set available product set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserSetAvailableProductSetCall.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserDeleteCall.html), [*generate authentication token*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGenerateAuthenticationTokenCall.html), [*generate token*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGenerateTokenCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGetCall.html), [*get available product set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserGetAvailableProductSetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserPatchCall.html), [*revoke token*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserRevokeTokenCall.html), [*set available product set*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserSetAvailableProductSetCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidenterprise1/struct.UserUpdateCall.html) @@ -72,15 +78,20 @@ Or specifically ... ```ignore let r = hub.enterprises().send_test_push_notification(...).doit() -let r = hub.enterprises().set_store_layout(...).doit() let r = hub.enterprises().get_store_layout(...).doit() +let r = hub.enterprises().get_service_account(...).doit() +let r = hub.enterprises().acknowledge_notification_set(...).doit() +let r = hub.enterprises().set_store_layout(...).doit() +let r = hub.enterprises().insert(...).doit() +let r = hub.enterprises().complete_signup(...).doit() let r = hub.enterprises().list(...).doit() let r = hub.enterprises().unenroll(...).doit() let r = hub.enterprises().set_account(...).doit() -let r = hub.enterprises().delete(...).doit() +let r = hub.enterprises().pull_notification_set(...).doit() let r = hub.enterprises().enroll(...).doit() -let r = hub.enterprises().insert(...).doit() let r = hub.enterprises().get(...).doit() +let r = hub.enterprises().delete(...).doit() +let r = hub.enterprises().generate_signup_url(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -105,7 +116,6 @@ google-androidenterprise1 = "*" extern crate hyper; extern crate yup_oauth2 as oauth2; extern crate google_androidenterprise1 as androidenterprise1; -use androidenterprise1::StoreLayout; use androidenterprise1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -123,15 +133,11 @@ let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, hyper::Client::new(), ::default(), None); let mut hub = AndroidEnterprise::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 = StoreLayout::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.enterprises().set_store_layout(req, "enterpriseId") +let result = hub.enterprises().get_service_account("enterpriseId") + .key_type("sit") .doit(); match result { diff --git a/gen/androidenterprise1/src/lib.rs b/gen/androidenterprise1/src/lib.rs index aa54cc1ffc..6875b12855 100644 --- a/gen/androidenterprise1/src/lib.rs +++ b/gen/androidenterprise1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Android Enterprise* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Android Enterprise* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *androidenterprise:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Android Enterprise* *v1* API can be found at the //! [official documentation site](https://developers.google.com/android/work/play/emm-api). @@ -18,7 +18,7 @@ //! * [devices](struct.Device.html) //! * [*get*](struct.DeviceGetCall.html), [*get state*](struct.DeviceGetStateCall.html), [*list*](struct.DeviceListCall.html) and [*set state*](struct.DeviceSetStateCall.html) //! * [enterprises](struct.Enterprise.html) -//! * [*delete*](struct.EnterpriseDeleteCall.html), [*enroll*](struct.EnterpriseEnrollCall.html), [*get*](struct.EnterpriseGetCall.html), [*get store layout*](struct.EnterpriseGetStoreLayoutCall.html), [*insert*](struct.EnterpriseInsertCall.html), [*list*](struct.EnterpriseListCall.html), [*send test push notification*](struct.EnterpriseSendTestPushNotificationCall.html), [*set account*](struct.EnterpriseSetAccountCall.html), [*set store layout*](struct.EnterpriseSetStoreLayoutCall.html) and [*unenroll*](struct.EnterpriseUnenrollCall.html) +//! * [*acknowledge notification set*](struct.EnterpriseAcknowledgeNotificationSetCall.html), [*complete signup*](struct.EnterpriseCompleteSignupCall.html), [*delete*](struct.EnterpriseDeleteCall.html), [*enroll*](struct.EnterpriseEnrollCall.html), [*generate signup url*](struct.EnterpriseGenerateSignupUrlCall.html), [*get*](struct.EnterpriseGetCall.html), [*get service account*](struct.EnterpriseGetServiceAccountCall.html), [*get store layout*](struct.EnterpriseGetStoreLayoutCall.html), [*insert*](struct.EnterpriseInsertCall.html), [*list*](struct.EnterpriseListCall.html), [*pull notification set*](struct.EnterprisePullNotificationSetCall.html), [*send test push notification*](struct.EnterpriseSendTestPushNotificationCall.html), [*set account*](struct.EnterpriseSetAccountCall.html), [*set store layout*](struct.EnterpriseSetStoreLayoutCall.html) and [*unenroll*](struct.EnterpriseUnenrollCall.html) //! * [entitlements](struct.Entitlement.html) //! * [*delete*](struct.EntitlementDeleteCall.html), [*get*](struct.EntitlementGetCall.html), [*list*](struct.EntitlementListCall.html), [*patch*](struct.EntitlementPatchCall.html) and [*update*](struct.EntitlementUpdateCall.html) //! * grouplicenses @@ -27,16 +27,22 @@ //! * [*list*](struct.GrouplicenseuserListCall.html) //! * [installs](struct.Install.html) //! * [*delete*](struct.InstallDeleteCall.html), [*get*](struct.InstallGetCall.html), [*list*](struct.InstallListCall.html), [*patch*](struct.InstallPatchCall.html) and [*update*](struct.InstallUpdateCall.html) +//! * managedconfigurationsfordevice +//! * [*delete*](struct.ManagedconfigurationsfordeviceDeleteCall.html), [*get*](struct.ManagedconfigurationsfordeviceGetCall.html), [*list*](struct.ManagedconfigurationsfordeviceListCall.html), [*patch*](struct.ManagedconfigurationsfordevicePatchCall.html) and [*update*](struct.ManagedconfigurationsfordeviceUpdateCall.html) +//! * managedconfigurationsforuser +//! * [*delete*](struct.ManagedconfigurationsforuserDeleteCall.html), [*get*](struct.ManagedconfigurationsforuserGetCall.html), [*list*](struct.ManagedconfigurationsforuserListCall.html), [*patch*](struct.ManagedconfigurationsforuserPatchCall.html) and [*update*](struct.ManagedconfigurationsforuserUpdateCall.html) //! * [permissions](struct.Permission.html) //! * [*get*](struct.PermissionGetCall.html) //! * [products](struct.Product.html) -//! * [*approve*](struct.ProductApproveCall.html), [*generate approval url*](struct.ProductGenerateApprovalUrlCall.html), [*get*](struct.ProductGetCall.html), [*get app restrictions schema*](struct.ProductGetAppRestrictionsSchemaCall.html), [*get permissions*](struct.ProductGetPermissionCall.html) and [*update permissions*](struct.ProductUpdatePermissionCall.html) +//! * [*approve*](struct.ProductApproveCall.html), [*generate approval url*](struct.ProductGenerateApprovalUrlCall.html), [*get*](struct.ProductGetCall.html), [*get app restrictions schema*](struct.ProductGetAppRestrictionsSchemaCall.html), [*get permissions*](struct.ProductGetPermissionCall.html), [*list*](struct.ProductListCall.html), [*unapprove*](struct.ProductUnapproveCall.html) and [*update permissions*](struct.ProductUpdatePermissionCall.html) +//! * serviceaccountkeys +//! * [*delete*](struct.ServiceaccountkeyDeleteCall.html), [*insert*](struct.ServiceaccountkeyInsertCall.html) and [*list*](struct.ServiceaccountkeyListCall.html) //! * storelayoutclusters //! * [*delete*](struct.StorelayoutclusterDeleteCall.html), [*get*](struct.StorelayoutclusterGetCall.html), [*insert*](struct.StorelayoutclusterInsertCall.html), [*list*](struct.StorelayoutclusterListCall.html), [*patch*](struct.StorelayoutclusterPatchCall.html) and [*update*](struct.StorelayoutclusterUpdateCall.html) //! * storelayoutpages //! * [*delete*](struct.StorelayoutpageDeleteCall.html), [*get*](struct.StorelayoutpageGetCall.html), [*insert*](struct.StorelayoutpageInsertCall.html), [*list*](struct.StorelayoutpageListCall.html), [*patch*](struct.StorelayoutpagePatchCall.html) and [*update*](struct.StorelayoutpageUpdateCall.html) //! * [users](struct.User.html) -//! * [*generate token*](struct.UserGenerateTokenCall.html), [*get*](struct.UserGetCall.html), [*get available product set*](struct.UserGetAvailableProductSetCall.html), [*list*](struct.UserListCall.html), [*revoke token*](struct.UserRevokeTokenCall.html) and [*set available product set*](struct.UserSetAvailableProductSetCall.html) +//! * [*delete*](struct.UserDeleteCall.html), [*generate authentication token*](struct.UserGenerateAuthenticationTokenCall.html), [*generate token*](struct.UserGenerateTokenCall.html), [*get*](struct.UserGetCall.html), [*get available product set*](struct.UserGetAvailableProductSetCall.html), [*insert*](struct.UserInsertCall.html), [*list*](struct.UserListCall.html), [*patch*](struct.UserPatchCall.html), [*revoke token*](struct.UserRevokeTokenCall.html), [*set available product set*](struct.UserSetAvailableProductSetCall.html) and [*update*](struct.UserUpdateCall.html) //! //! //! @@ -72,15 +78,20 @@ //! //! ```ignore //! let r = hub.enterprises().send_test_push_notification(...).doit() -//! let r = hub.enterprises().set_store_layout(...).doit() //! let r = hub.enterprises().get_store_layout(...).doit() +//! let r = hub.enterprises().get_service_account(...).doit() +//! let r = hub.enterprises().acknowledge_notification_set(...).doit() +//! let r = hub.enterprises().set_store_layout(...).doit() +//! let r = hub.enterprises().insert(...).doit() +//! let r = hub.enterprises().complete_signup(...).doit() //! let r = hub.enterprises().list(...).doit() //! let r = hub.enterprises().unenroll(...).doit() //! let r = hub.enterprises().set_account(...).doit() -//! let r = hub.enterprises().delete(...).doit() +//! let r = hub.enterprises().pull_notification_set(...).doit() //! let r = hub.enterprises().enroll(...).doit() -//! let r = hub.enterprises().insert(...).doit() //! let r = hub.enterprises().get(...).doit() +//! let r = hub.enterprises().delete(...).doit() +//! let r = hub.enterprises().generate_signup_url(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -105,7 +116,6 @@ //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; //! extern crate google_androidenterprise1 as androidenterprise1; -//! use androidenterprise1::StoreLayout; //! use androidenterprise1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; @@ -124,15 +134,11 @@ //! hyper::Client::new(), //! ::default(), None); //! let mut hub = AndroidEnterprise::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 = StoreLayout::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.enterprises().set_store_layout(req, "enterpriseId") +//! let result = hub.enterprises().get_service_account("enterpriseId") +//! .key_type("dolor") //! .doit(); //! //! match result { diff --git a/gen/androidenterprise1/src/lib.rs.in b/gen/androidenterprise1/src/lib.rs.in index d5f24cb1be..bde68527dd 100644 --- a/gen/androidenterprise1/src/lib.rs.in +++ b/gen/androidenterprise1/src/lib.rs.in @@ -70,7 +70,6 @@ impl Default for Scope { /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_androidenterprise1 as androidenterprise1; -/// use androidenterprise1::StoreLayout; /// use androidenterprise1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; @@ -89,15 +88,11 @@ impl Default for Scope { /// hyper::Client::new(), /// ::default(), None); /// let mut hub = AndroidEnterprise::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 = StoreLayout::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.enterprises().set_store_layout(req, "enterpriseId") +/// let result = hub.enterprises().get_service_account("enterpriseId") +/// .key_type("sed") /// .doit(); /// /// match result { @@ -161,12 +156,21 @@ impl<'a, C, A> AndroidEnterprise pub fn installs(&'a self) -> InstallMethods<'a, C, A> { InstallMethods { hub: &self } } + pub fn managedconfigurationsfordevice(&'a self) -> ManagedconfigurationsfordeviceMethods<'a, C, A> { + ManagedconfigurationsfordeviceMethods { hub: &self } + } + pub fn managedconfigurationsforuser(&'a self) -> ManagedconfigurationsforuserMethods<'a, C, A> { + ManagedconfigurationsforuserMethods { hub: &self } + } pub fn permissions(&'a self) -> PermissionMethods<'a, C, A> { PermissionMethods { hub: &self } } pub fn products(&'a self) -> ProductMethods<'a, C, A> { ProductMethods { hub: &self } } + pub fn serviceaccountkeys(&'a self) -> ServiceaccountkeyMethods<'a, C, A> { + ServiceaccountkeyMethods { hub: &self } + } pub fn storelayoutclusters(&'a self) -> StorelayoutclusterMethods<'a, C, A> { StorelayoutclusterMethods { hub: &self } } @@ -192,6 +196,20 @@ impl<'a, C, A> AndroidEnterprise // ############ // SCHEMAS ### // ########## +/// An event generated when a new app version is uploaded to Google Play and its app restrictions schema changed. To fetch the app restrictions schema for an app, use Products.getAppRestrictionsSchema on the EMM 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 AppRestrictionsSchemaChangeEvent { + /// The id of the product (e.g. "app:com.google.android.gm") for which the app restriction schema changed. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for AppRestrictionsSchemaChangeEvent {} + + /// A typed value for the restriction. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -218,47 +236,24 @@ pub struct AppRestrictionsSchemaRestrictionRestrictionValue { impl Part for AppRestrictionsSchemaRestrictionRestrictionValue {} -/// The existence of an install resource indicates that an app is installed on a particular device (or that an install is pending). -/// -/// The API can be used to create an install resource using the update method. This triggers the actual install of the app on the device. If the user does not already have an entitlement for the app then an attempt is made to create one. If this fails (e.g. because the app is not free and there is no available license) then the creation of the install fails. -/// -/// The API can also be used to update an installed app. If the update method is used on an existing install then the app will be updated to the latest available version. -/// -/// Note that it is not possible to force the installation of a specific version of an app; the version code is read-only. -/// -/// If a user installs an app themselves (as permitted by the enterprise), then again an install resource and possibly an entitlement resource are automatically created. -/// -/// The API can also be used to delete an install resource, which triggers the removal of the app from the device. Note that deleting an install does not automatically remove the corresponding entitlement, even if there are no remaining installs. The install resource will also be deleted if the user uninstalls the app themselves. +/// The matching enterprise 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*). /// -/// * [patch installs](struct.InstallPatchCall.html) (request|response) -/// * [list installs](struct.InstallListCall.html) (none) -/// * [delete installs](struct.InstallDeleteCall.html) (none) -/// * [update installs](struct.InstallUpdateCall.html) (request|response) -/// * [get installs](struct.InstallGetCall.html) (response) +/// * [list enterprises](struct.EnterpriseListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Install { - /// Install state. The state "installPending" means that an install request has recently been made and download to the device is in progress. The state "installed" means that the app has been installed. This field is read-only. - #[serde(rename="installState")] - pub install_state: Option, - /// The version of the installed product. Guaranteed to be set only if the install state is "installed". - #[serde(rename="versionCode")] - pub version_code: Option, - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#install". +pub struct EnterprisesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#enterprisesListResponse". pub kind: Option, - /// The ID of the product that the install is for, e.g. "app:com.google.android.gm". - #[serde(rename="productId")] - pub product_id: Option, + /// An enterprise. + pub enterprise: Option>, } -impl RequestValue for Install {} -impl Resource for Install {} -impl ResponseResult for Install {} +impl ResponseResult for EnterprisesListResponse {} /// The existence of an entitlement resource means that a user has the right to use a particular app on any of their devices. This might be because the app is free or because they have been allocated a license to the app from a group license purchased by the enterprise. @@ -298,6 +293,27 @@ impl Resource for Entitlement {} impl ResponseResult for Entitlement {} +/// The managed configuration resources for 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*). +/// +/// * [list managedconfigurationsforuser](struct.ManagedconfigurationsforuserListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedConfigurationsForUserListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#managedConfigurationsForUserListResponse". + pub kind: Option, + /// A managed configuration for an app for a specific user. + #[serde(rename="managedConfigurationForUser")] + pub managed_configuration_for_user: Option>, +} + +impl ResponseResult for ManagedConfigurationsForUserListResponse {} + + /// The install resources for the device. /// /// # Activities @@ -341,6 +357,100 @@ impl RequestValue for ProductSet {} impl ResponseResult for ProductSet {} +/// Information about the permissions required by a specific app and whether they have been accepted by the enterprise. +/// +/// # 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 permissions products](struct.ProductUpdatePermissionCall.html) (request|response) +/// * [get permissions products](struct.ProductGetPermissionCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductPermissions { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#productPermissions". + pub kind: Option, + /// The permissions required by the app. + pub permission: Option>, + /// The ID of the app that the permissions relate to, e.g. "app:com.google.android.gm". + #[serde(rename="productId")] + pub product_id: Option, +} + +impl RequestValue for ProductPermissions {} +impl ResponseResult for ProductPermissions {} + + +/// A collection resource defines a named set of apps that is visible to a set of users in the Google Play Store app running on those users' managed devices. Those users can then install any of those apps if they wish (which will trigger creation of install and entitlement resources). A user cannot install an app on a managed device unless the app is listed in at least one collection that is visible to that user. +/// +/// Note that the API can be used to directly install an app regardless of whether it is in any collection - so an enterprise has a choice of either directly pushing apps to users, or allowing users to install apps if they want. Which is appropriate will depend on the enterprise's policies and the purpose of the apps concerned. +/// +/// # 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 collections](struct.CollectionListCall.html) (none) +/// * [patch collections](struct.CollectionPatchCall.html) (request|response) +/// * [insert collections](struct.CollectionInsertCall.html) (request|response) +/// * [get collections](struct.CollectionGetCall.html) (response) +/// * [delete collections](struct.CollectionDeleteCall.html) (none) +/// * [update collections](struct.CollectionUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Collection { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#collection". + pub kind: Option, + /// Arbitrary unique ID, allocated by the API on creation. + #[serde(rename="collectionId")] + pub collection_id: Option, + /// A user-friendly name for the collection (should be unique), e.g. "Accounting apps". + pub name: Option, + /// Whether this collection is visible to all users, or only to the users that have been granted access through the "Collectionviewers" API. With the launch of the "setAvailableProductSet" API, this property should always be set to "viewersOnly", as the "allUsers" option will bypass the "availableProductSet" for all users within a domain. + /// + /// The "allUsers" setting is deprecated, and will be removed. + pub visibility: Option, + /// The IDs of the products in the collection, in the order in which they should be displayed. + #[serde(rename="productId")] + pub product_id: Option>, +} + +impl RequestValue for Collection {} +impl Resource for Collection {} +impl ResponseResult for Collection {} + + +/// Definition of a Google Play for Work store page, made of a localized name and links to other pages. A page also contains clusters defined as a subcollection. +/// +/// # 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 storelayoutpages](struct.StorelayoutpageGetCall.html) (response) +/// * [update storelayoutpages](struct.StorelayoutpageUpdateCall.html) (request|response) +/// * [patch storelayoutpages](struct.StorelayoutpagePatchCall.html) (request|response) +/// * [insert storelayoutpages](struct.StorelayoutpageInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct StorePage { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#storePage". + pub kind: Option, + /// Ordered list of pages a user should be able to reach from this page. The pages must exist, must not be this page, and once a link is created the page linked to cannot be deleted until all links to it are removed. It is recommended that the basic pages are created first, before adding the links between pages. + /// + /// No attempt is made to verify that all pages are reachable from the homepage. + pub link: Option>, + /// Unique ID of this page. Assigned by the server. Immutable once assigned. + pub id: Option, + /// Ordered list of localized strings giving the name of this page. The text displayed is the one that best matches the user locale, or the first entry if there is no good match. There needs to be at least one entry. + pub name: Option>, +} + +impl RequestValue for StorePage {} +impl ResponseResult for StorePage {} + + /// The state of a user's device, as accessed by the getState and setState methods on device resources. /// /// # Activities @@ -382,62 +492,38 @@ pub struct ProductPermission { impl Part for ProductPermission {} -/// A product represents an app in the Google Play Store that is available to at least some users in the enterprise. (Some apps are restricted to a single enterprise, and no information about them is made available outside that enterprise.) +/// This represents an enterprise administrator who can manage the enterprise in the Google Play for Work Store. /// -/// The information provided for each product (localized name, icon, link to the full Google Play details page) is intended to allow a basic representation of the product within an EMM user interface. +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Administrator { + /// The administrator's email address. + pub email: Option, +} + +impl Part for Administrator {} + + +/// The managed configuration resources for the device. /// /// # 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 permissions products](struct.ProductGetPermissionCall.html) (none) -/// * [get products](struct.ProductGetCall.html) (response) -/// * [approve products](struct.ProductApproveCall.html) (none) -/// * [get app restrictions schema products](struct.ProductGetAppRestrictionsSchemaCall.html) (none) -/// * [generate approval url products](struct.ProductGenerateApprovalUrlCall.html) (none) -/// * [update permissions products](struct.ProductUpdatePermissionCall.html) (none) +/// * [list managedconfigurationsfordevice](struct.ManagedconfigurationsfordeviceListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Product { - /// A link to a smaller image that can be used as an icon for the product. This image is suitable for use at up to 128px x 128px. - #[serde(rename="smallIconUrl")] - pub small_icon_url: Option, - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#product". +pub struct ManagedConfigurationsForDeviceListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#managedConfigurationsForDeviceListResponse". pub kind: Option, - /// How and to whom the package is made available. The value publicGoogleHosted means that the package is available through the Play Store and not restricted to a specific enterprise. The value privateGoogleHosted means that the package is a private app (restricted to an enterprise) but hosted by Google. The value privateSelfHosted means that the package is a private app (restricted to an enterprise) and is privately hosted. - #[serde(rename="distributionChannel")] - pub distribution_channel: Option, - /// The name of the product. - pub title: Option, - /// A link to the Google Play for Work details page for the product, for use by an Enterprise administrator. - #[serde(rename="workDetailsUrl")] - pub work_details_url: Option, - /// App versions currently available for this product. The returned list contains only public versions. Alpha and beta versions are not included. - #[serde(rename="appVersion")] - pub app_version: Option>, - /// Whether this product is free, free with in-app purchases, or paid. - #[serde(rename="productPricing")] - pub product_pricing: Option, - /// A link to an image that can be used as an icon for the product. This image is suitable for use at up to 512px x 512px. - #[serde(rename="iconUrl")] - pub icon_url: Option, - /// The name of the author of the product (e.g. the app developer). - #[serde(rename="authorName")] - pub author_name: Option, - /// Whether this app can only be installed on devices using the Android for Work container app. - #[serde(rename="requiresContainerApp")] - pub requires_container_app: Option, - /// A link to the (consumer) Google Play details page for the product. - #[serde(rename="detailsUrl")] - pub details_url: Option, - /// A string of the form app:. For example, app:com.google.android.gm represents the Gmail app. - #[serde(rename="productId")] - pub product_id: Option, + /// A managed configuration for an app on a specific device. + #[serde(rename="managedConfigurationForDevice")] + pub managed_configuration_for_device: Option>, } -impl Resource for Product {} -impl ResponseResult for Product {} +impl ResponseResult for ManagedConfigurationsForDeviceListResponse {} /// A permission represents some extra capability, to be granted to an Android app, which requires explicit consent. An enterprise admin must consent to these permissions on behalf of their users before an entitlement for the app can be created. @@ -468,6 +554,29 @@ impl Resource for Permission {} impl ResponseResult for Permission {} +/// A resource returned by the PullNotificationSet API, which contains a collection of notifications for enterprises associated with the service account authenticated for the request. +/// +/// # 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*). +/// +/// * [pull notification set enterprises](struct.EnterprisePullNotificationSetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct NotificationSet { + /// The notifications received, or empty if no notifications are present. + pub notification: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#notificationSet". + pub kind: Option, + /// The notification set ID, required to mark the notification as received with the Enterprises.AcknowledgeNotification API. This will be omitted if no notifications are present. + #[serde(rename="notificationSetId")] + pub notification_set_id: Option, +} + +impl ResponseResult for NotificationSet {} + + /// The entitlement resources for the user. /// /// # Activities @@ -488,43 +597,86 @@ pub struct EntitlementsListResponse { impl ResponseResult for EntitlementsListResponse {} -/// A collection resource defines a named set of apps that is visible to a set of users in the Google Play Store app running on those users' managed devices. Those users can then install any of those apps if they wish (which will trigger creation of install and entitlement resources). A user cannot install an app on a managed device unless the app is listed in at least one collection that is visible to that user. +/// A notification of one event relating to an enterprise. /// -/// Note that the API can be used to directly install an app regardless of whether it is in any collection - so an enterprise has a choice of either directly pushing apps to users, or allowing users to install apps if they want. Which is appropriate will depend on the enterprise's policies and the purpose of the apps concerned. +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Notification { + /// Notifications about new app restrictions schema changes. + #[serde(rename="appRestrictionsSchemaChangeEvent")] + pub app_restrictions_schema_change_event: Option, + /// Notifications about new app permissions. + #[serde(rename="newPermissionsEvent")] + pub new_permissions_event: Option, + /// Notifications about product availability changes. + #[serde(rename="productAvailabilityChangeEvent")] + pub product_availability_change_event: Option, + /// Notifications about an app installation failure. + #[serde(rename="installFailureEvent")] + pub install_failure_event: Option, + /// The ID of the enterprise for which the notification is sent. This will always be present. + #[serde(rename="enterpriseId")] + pub enterprise_id: Option, + /// Notifications about changes to a product's approval status. + #[serde(rename="productApprovalEvent")] + pub product_approval_event: Option, + /// Notifications about app updates. + #[serde(rename="appUpdateEvent")] + pub app_update_event: Option, + /// The time when the notification was published in milliseconds since 1970-01-01T00:00:00Z. This will always be present. + #[serde(rename="timestampMillis")] + pub timestamp_millis: Option, +} + +impl Part for Notification {} + + +/// An event generated whenever a product's availability changes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductAvailabilityChangeEvent { + /// The new state of the product. This field will always be present. + #[serde(rename="availabilityStatus")] + pub availability_status: Option, + /// The id of the product (e.g. "app:com.google.android.gm") for which the product availability changed. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for ProductAvailabilityChangeEvent {} + + +/// A managed configuration resource contains the set of managed properties that have been configured for an Android app. The app's developer would have defined configurable properties in the managed configurations schema. /// /// # 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 collections](struct.CollectionListCall.html) (none) -/// * [patch collections](struct.CollectionPatchCall.html) (request|response) -/// * [insert collections](struct.CollectionInsertCall.html) (request|response) -/// * [get collections](struct.CollectionGetCall.html) (response) -/// * [delete collections](struct.CollectionDeleteCall.html) (none) -/// * [update collections](struct.CollectionUpdateCall.html) (request|response) +/// * [patch managedconfigurationsforuser](struct.ManagedconfigurationsforuserPatchCall.html) (request|response) +/// * [get managedconfigurationsforuser](struct.ManagedconfigurationsforuserGetCall.html) (response) +/// * [update managedconfigurationsforuser](struct.ManagedconfigurationsforuserUpdateCall.html) (request|response) +/// * [patch managedconfigurationsfordevice](struct.ManagedconfigurationsfordevicePatchCall.html) (request|response) +/// * [get managedconfigurationsfordevice](struct.ManagedconfigurationsfordeviceGetCall.html) (response) +/// * [update managedconfigurationsfordevice](struct.ManagedconfigurationsfordeviceUpdateCall.html) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Collection { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#collection". +pub struct ManagedConfiguration { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#managedConfiguration". pub kind: Option, - /// Arbitrary unique ID, allocated by the API on creation. - #[serde(rename="collectionId")] - pub collection_id: Option, - /// A user-friendly name for the collection (should be unique), e.g. "Accounting apps". - pub name: Option, - /// Whether this collection is visible to all users, or only to the users that have been granted access through the "Collectionviewers" API. With the launch of the "setAvailableProductSet" API, this property should always be set to "viewersOnly", as the "allUsers" option will bypass the "availableProductSet" for all users within a domain. - /// - /// The "allUsers" setting is deprecated, and will be removed. - pub visibility: Option, - /// The IDs of the products in the collection, in the order in which they should be displayed. + /// The set of managed properties for this configuration. + #[serde(rename="managedProperty")] + pub managed_property: Option>, + /// The ID of the product that the managed configuration is for, e.g. "app:com.google.android.gm". #[serde(rename="productId")] - pub product_id: Option>, + pub product_id: Option, } -impl RequestValue for Collection {} -impl Resource for Collection {} -impl ResponseResult for Collection {} +impl RequestValue for ManagedConfiguration {} +impl ResponseResult for ManagedConfiguration {} /// There is no detailed description. @@ -569,50 +721,59 @@ pub struct GroupLicenseUsersListResponse { impl ResponseResult for GroupLicenseUsersListResponse {} -/// Information on an approval URL. +/// A localized string with its locale. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ApprovalUrlInfo { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#approvalUrlInfo". - pub kind: Option, - /// A URL that displays a product's permissions and that can also be used to approve the product with the Products.approve call. - #[serde(rename="approvalUrl")] - pub approval_url: Option, +pub struct LocalizedText { + /// The BCP47 tag for a locale. (e.g. "en-US", "de"). + pub locale: Option, + /// The text localized in the associated locale. + pub text: Option, } -impl Part for ApprovalUrlInfo {} +impl Part for LocalizedText {} -/// A device resource represents a mobile device managed by the EMM and belonging to a specific enterprise user. -/// -/// This collection cannot be modified via the API; it is automatically populated as devices are set up to be managed. +/// An AuthenticationToken is used by the EMM's device policy client on a device to provision the given EMM-managed user on that device. /// /// # 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 devices](struct.DeviceGetCall.html) (response) -/// * [get state devices](struct.DeviceGetStateCall.html) (none) -/// * [list devices](struct.DeviceListCall.html) (none) -/// * [set state devices](struct.DeviceSetStateCall.html) (none) +/// * [generate authentication token users](struct.UserGenerateAuthenticationTokenCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Device { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#device". +pub struct AuthenticationToken { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#authenticationToken". pub kind: Option, - /// The Google Play Services Android ID for the device encoded as a lowercase hex string, e.g. "123456789abcdef0". - #[serde(rename="androidId")] - pub android_id: Option, - /// The mechanism by which this device is managed by the EMM. "managedDevice" means that the EMM's app is a device owner. "managedProfile" means that the EMM's app is the profile owner (and there is a separate personal profile which is not managed). "containerApp" means that the EMM's app is managing the Android for Work container app on the device. - #[serde(rename="managementType")] - pub management_type: Option, + /// The authentication token to be passed to the device policy client on the device where it can be used to provision the account for which this token was generated. + pub token: Option, } -impl Resource for Device {} -impl ResponseResult for Device {} +impl ResponseResult for AuthenticationToken {} + + +/// 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. @@ -659,23 +820,26 @@ impl ResponseResult for AppRestrictionsSchema {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppRestrictionsSchemaRestriction { - /// The type of the restriction. - #[serde(rename="restrictionType")] - pub restriction_type: Option, /// A longer description of the restriction, giving more detail of what it affects. pub description: Option, - /// The unique key that the product uses to identify the restriction, e.g. "com.google.android.gm.fieldname". - pub key: Option, /// The name of the restriction. pub title: Option, - /// For choice or multiselect restrictions, the list of possible entries' human-readable names. - pub entry: Option>, /// The default value of the restriction. #[serde(rename="defaultValue")] pub default_value: Option, + /// For bundle or bundleArray restrictions, the list of nested restrictions. + #[serde(rename="nestedRestriction")] + pub nested_restriction: Option>, /// For choice or multiselect restrictions, the list of possible entries' machine-readable values. #[serde(rename="entryValue")] pub entry_value: Option>, + /// The unique key that the product uses to identify the restriction, e.g. "com.google.android.gm.fieldname". + pub key: Option, + /// For choice or multiselect restrictions, the list of possible entries' human-readable names. + pub entry: Option>, + /// The type of the restriction. + #[serde(rename="restrictionType")] + pub restriction_type: Option, } impl Part for AppRestrictionsSchemaRestriction {} @@ -701,6 +865,26 @@ pub struct StoreLayoutClustersListResponse { impl ResponseResult for StoreLayoutClustersListResponse {} +/// An event generated when new permissions are added to an app. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct NewPermissionsEvent { + /// The set of permissions that the enterprise admin has already approved for this application. Use Permissions.Get on the EMM API to retrieve details about these permissions. + #[serde(rename="approvedPermissions")] + pub approved_permissions: Option>, + /// The set of permissions that the app is currently requesting. Use Permissions.Get on the EMM API to retrieve details about these permissions. + #[serde(rename="requestedPermissions")] + pub requested_permissions: Option>, + /// The id of the product (e.g. "app:com.google.android.gm") for which new permissions were added. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for NewPermissionsEvent {} + + /// The store page resources for the enterprise. /// /// # Activities @@ -721,6 +905,28 @@ pub struct StoreLayoutPagesListResponse { impl ResponseResult for StoreLayoutPagesListResponse {} +/// A service account identity, including the name and credentials that can be used to authenticate as the service account. +/// +/// # 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 service account enterprises](struct.EnterpriseGetServiceAccountCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ServiceAccount { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#serviceAccount". + pub kind: Option, + /// The account name of the service account, in the form of an email address. Assigned by the server. + pub name: Option, + /// Credentials that can be used to authenticate as this ServiceAccount. + pub key: Option, +} + +impl ResponseResult for ServiceAccount {} + + /// A service account that can be used to authenticate as the enterprise to API calls that require such authentication. /// /// # Activities @@ -743,6 +949,49 @@ impl RequestValue for EnterpriseAccount {} impl ResponseResult for EnterpriseAccount {} +/// 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 {} + + +/// The matching products. +/// +/// # 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 products](struct.ProductListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductsListResponse { + /// Information about a product (e.g. an app) in the Google Play Store, for display to an enterprise admin. + pub product: Option>, + /// Pagination information for token pagination. + #[serde(rename="tokenPagination")] + pub token_pagination: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#productsListResponse". + pub kind: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + pub page_info: Option, +} + +impl ResponseResult for ProductsListResponse {} + + /// This represents a single version of the app. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -760,67 +1009,62 @@ pub struct AppVersion { impl Part for AppVersion {} -/// A localized string with its locale. +/// A device resource represents a mobile device managed by the EMM and belonging to a specific enterprise user. /// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct LocalizedText { - /// The BCP47 tag for a locale. (e.g. "en-US", "de"). - pub locale: Option, - /// The text localized in the associated locale. - pub text: Option, -} - -impl Part for LocalizedText {} - - -/// The grouplicense resources for the enterprise. +/// This collection cannot be modified via the API; it is automatically populated as devices are set up to be managed. /// /// # 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 grouplicenses](struct.GrouplicenseListCall.html) (response) +/// * [get devices](struct.DeviceGetCall.html) (response) +/// * [get state devices](struct.DeviceGetStateCall.html) (none) +/// * [list devices](struct.DeviceListCall.html) (none) +/// * [set state devices](struct.DeviceSetStateCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GroupLicensesListResponse { - /// A group license for a product approved for use in the enterprise. - #[serde(rename="groupLicense")] - pub group_license: Option>, - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#groupLicensesListResponse". +pub struct Device { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#device". pub kind: Option, + /// The Google Play Services Android ID for the device encoded as a lowercase hex string, e.g. "123456789abcdef0". + #[serde(rename="androidId")] + pub android_id: Option, + /// Identifies the extent to which the device is controlled by an Android for Work EMM in various deployment configurations. + /// Possible values include: + /// - "managedDevice"—A device that has the EMM's device policy controller (DPC) as the device owner. + /// - "managedProfile"—A device that has a work profile managed by the DPC (DPC is profile owner) in addition to a separate, personal profile that is unavailable to the DPC. + /// - "containerApp"—A device running the Android for Work App. The Android for Work App is managed by the DPC. + /// - "unmanagedProfile"—A device that has been allowed (by the domain's admin, using the Admin Console to enable the privilege) to use Android for Work apps or Google Apps for Work, but the profile is itself not owned by a DPC. + #[serde(rename="managementType")] + pub management_type: Option, } -impl ResponseResult for GroupLicensesListResponse {} +impl Resource for Device {} +impl ResponseResult for Device {} -/// General setting for the Google Play for Work store layout, currently only specifying the page to display the first time the store is opened. +/// A resource returned by the GenerateSignupUrl API, which contains the Signup URL and Completion Token. /// /// # 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 store layout enterprises](struct.EnterpriseSetStoreLayoutCall.html) (request|response) -/// * [get store layout enterprises](struct.EnterpriseGetStoreLayoutCall.html) (response) +/// * [generate signup url enterprises](struct.EnterpriseGenerateSignupUrlCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct StoreLayout { - /// The ID of the store page to be used as the homepage. The homepage will be used as the first page shown in the Google Play for Work store. - /// - /// If there is no homepage set, an empty store is shown. The homepage can be unset (by not specifying it) to empty the store. - /// - /// If there exists at least one page, this field must be set to the ID of a valid page. - #[serde(rename="homepageId")] - pub homepage_id: Option, - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#storeLayout". +pub struct SignupInfo { + /// A URL under which the Admin can sign up for an enterprise. The page pointed to cannot be rendered in an iframe. + pub url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#signupInfo". pub kind: Option, + /// An opaque token that will be required, along with the Enterprise Token, for obtaining the enterprise resource from CompleteSignup. + #[serde(rename="completionToken")] + pub completion_token: Option, } -impl RequestValue for StoreLayout {} -impl ResponseResult for StoreLayout {} +impl ResponseResult for SignupInfo {} /// The device resources for the user. @@ -843,35 +1087,52 @@ pub struct DevicesListResponse { impl ResponseResult for DevicesListResponse {} -/// The matching enterprise resources. +/// The existence of an install resource indicates that an app is installed on a particular device (or that an install is pending). +/// +/// The API can be used to create an install resource using the update method. This triggers the actual install of the app on the device. If the user does not already have an entitlement for the app then an attempt is made to create one. If this fails (e.g. because the app is not free and there is no available license) then the creation of the install fails. +/// +/// The API can also be used to update an installed app. If the update method is used on an existing install then the app will be updated to the latest available version. +/// +/// Note that it is not possible to force the installation of a specific version of an app; the version code is read-only. +/// +/// If a user installs an app themselves (as permitted by the enterprise), then again an install resource and possibly an entitlement resource are automatically created. +/// +/// The API can also be used to delete an install resource, which triggers the removal of the app from the device. Note that deleting an install does not automatically remove the corresponding entitlement, even if there are no remaining installs. The install resource will also be deleted if the user uninstalls the app themselves. /// /// # 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 enterprises](struct.EnterpriseListCall.html) (response) +/// * [patch installs](struct.InstallPatchCall.html) (request|response) +/// * [list installs](struct.InstallListCall.html) (none) +/// * [delete installs](struct.InstallDeleteCall.html) (none) +/// * [update installs](struct.InstallUpdateCall.html) (request|response) +/// * [get installs](struct.InstallGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct EnterprisesListResponse { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#enterprisesListResponse". +pub struct Install { + /// Install state. The state "installPending" means that an install request has recently been made and download to the device is in progress. The state "installed" means that the app has been installed. This field is read-only. + #[serde(rename="installState")] + pub install_state: Option, + /// The version of the installed product. Guaranteed to be set only if the install state is "installed". + #[serde(rename="versionCode")] + pub version_code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#install". pub kind: Option, - /// An enterprise. - pub enterprise: Option>, + /// The ID of the product that the install is for, e.g. "app:com.google.android.gm". + #[serde(rename="productId")] + pub product_id: Option, } -impl ResponseResult for EnterprisesListResponse {} +impl RequestValue for Install {} +impl Resource for Install {} +impl ResponseResult for Install {} -/// An enterprise resource represents a binding between an organization and their EMM. -/// -/// To create an enterprise, an admin of the enterprise must first go through a Play for Work sign-up flow. At the end of this the admin will be presented with a token (a short opaque alphanumeric string). They must then present this to the EMM, who then supplies it to the enroll method. Until this is done the EMM will not have any access to the enterprise. -/// -/// After calling enroll the EMM should call setAccount to specify the service account that will be allowed to act on behalf of the enterprise, which will be required for access to the enterprise's data through this API. Only one call of setAccount is allowed for a given enterprise; the only way to change the account later is to unenroll the enterprise and enroll it again (obtaining a new token). -/// -/// The EMM can unenroll an enterprise in order to sever the binding between them. Re-enrolling an enterprise is possible, but requires a new token to be retrieved. Enterprises.unenroll requires the EMM's credentials (as enroll does), not the enterprise's. Enterprises.unenroll can only be used for enterprises that were previously enrolled with the enroll call. Any enterprises that were enrolled using the (deprecated) Enterprises.insert call must be unenrolled with Enterprises.delete and can then be re-enrolled using the Enterprises.enroll call. -/// -/// The ID for an enterprise is an opaque string. It is returned by insert and enroll and can also be retrieved if the enterprise's primary domain is known using the list method. +/// An Enterprises resource represents the binding between an EMM and a specific organization. That binding can be instantiated in one of two different ways using this API as follows: +/// - For Google managed domain customers, the process involves using Enterprises.enroll and Enterprises.setAccount (in conjunction with artifacts obtained from the Admin console and the Google API Console) and submitted to the EMM through a more-or-less manual process. +/// - For Android for Work Accounts customers, the process involves using Enterprises.generateSignupUrl and Enterprises.completeSignup in conjunction with the Android for Work Sign-up UI (Google-provided mechanism) to create the binding without manual steps. As an EMM, you can support either or both approaches in your EMM console. See Create an Enterprise for details. /// /// # Activities /// @@ -879,26 +1140,33 @@ impl ResponseResult for EnterprisesListResponse {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [send test push notification enterprises](struct.EnterpriseSendTestPushNotificationCall.html) (none) -/// * [set store layout enterprises](struct.EnterpriseSetStoreLayoutCall.html) (none) /// * [get store layout enterprises](struct.EnterpriseGetStoreLayoutCall.html) (none) +/// * [get service account enterprises](struct.EnterpriseGetServiceAccountCall.html) (none) +/// * [acknowledge notification set enterprises](struct.EnterpriseAcknowledgeNotificationSetCall.html) (none) +/// * [set store layout enterprises](struct.EnterpriseSetStoreLayoutCall.html) (none) +/// * [insert enterprises](struct.EnterpriseInsertCall.html) (request|response) +/// * [complete signup enterprises](struct.EnterpriseCompleteSignupCall.html) (response) /// * [list enterprises](struct.EnterpriseListCall.html) (none) /// * [unenroll enterprises](struct.EnterpriseUnenrollCall.html) (none) /// * [set account enterprises](struct.EnterpriseSetAccountCall.html) (none) -/// * [delete enterprises](struct.EnterpriseDeleteCall.html) (none) +/// * [pull notification set enterprises](struct.EnterprisePullNotificationSetCall.html) (none) /// * [enroll enterprises](struct.EnterpriseEnrollCall.html) (request|response) -/// * [insert enterprises](struct.EnterpriseInsertCall.html) (request|response) /// * [get enterprises](struct.EnterpriseGetCall.html) (response) +/// * [delete enterprises](struct.EnterpriseDeleteCall.html) (none) +/// * [generate signup url enterprises](struct.EnterpriseGenerateSignupUrlCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Enterprise { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#enterprise". - pub kind: Option, - /// The enterprise's primary domain, e.g. "example.com". + /// Administrators of the enterprise. This is only supported for enterprises created via the EMM-initiated flow. + pub administrator: Option>, + /// The enterprise's primary domain, such as "example.com". #[serde(rename="primaryDomain")] pub primary_domain: Option, /// The unique ID for the enterprise. pub id: Option, - /// The name of the enterprise, e.g. "Example Inc". + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#enterprise". + pub kind: Option, + /// The name of the enterprise, for example, "Example, Inc". pub name: Option, } @@ -907,6 +1175,32 @@ impl Resource for Enterprise {} impl ResponseResult for Enterprise {} +/// An event generated when an app installation failed on a device +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InstallFailureEvent { + /// The reason for the installation failure. This field will always be present. + #[serde(rename="failureReason")] + pub failure_reason: Option, + /// The ID of the user. This field will always be present. + #[serde(rename="userId")] + pub user_id: Option, + /// The Android ID of the device. This field will always be present. + #[serde(rename="deviceId")] + pub device_id: Option, + /// Additional details on the failure if applicable. + #[serde(rename="failureDetails")] + pub failure_details: Option, + /// The id of the product (e.g. "app:com.google.android.gm") for which the install failure event occured. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for InstallFailureEvent {} + + /// A UserToken is used by a user when setting up a managed device or profile with their work account on a device. When the user enters their email address and token (activation code) the appropriate EMM app can be automatically downloaded. /// /// # Activities @@ -930,6 +1224,20 @@ pub struct UserToken { impl ResponseResult for UserToken {} +/// An event generated when a new version of an app is uploaded to Google Play. Notifications are sent for new public versions only: alpha, beta, or canary versions do not generate this event. To fetch up-to-date version history for an app, use Products.Get on the EMM 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 AppUpdateEvent { + /// The id of the product (e.g. "app:com.google.android.gm") that was updated. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for AppUpdateEvent {} + + /// The user resources for the collection. /// /// # Activities @@ -975,7 +1283,7 @@ pub struct StoreCluster { pub name: Option>, /// String (US-ASCII only) used to determine order of this cluster within the parent page's elements. Page elements are sorted in lexicographic order of this field. Duplicated values are allowed, but ordering between elements with duplicate order is undefined. /// - /// The value of this field is never visible to a user, it is used solely for the purpose of defining an ordering. Maximum length is 20 characters. + /// The value of this field is never visible to a user, it is used solely for the purpose of defining an ordering. Maximum length is 256 characters. #[serde(rename="orderInPage")] pub order_in_page: Option, } @@ -1004,34 +1312,118 @@ pub struct UsersListResponse { impl ResponseResult for UsersListResponse {} -/// Definition of a Google Play for Work store page, made of a localized name and links to other pages. A page also contains clusters defined as a subcollection. +/// General setting for the Google Play for Work store layout, currently only specifying the page to display the first time the store is opened. /// /// # 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 storelayoutpages](struct.StorelayoutpageGetCall.html) (response) -/// * [update storelayoutpages](struct.StorelayoutpageUpdateCall.html) (request|response) -/// * [patch storelayoutpages](struct.StorelayoutpagePatchCall.html) (request|response) -/// * [insert storelayoutpages](struct.StorelayoutpageInsertCall.html) (request|response) +/// * [set store layout enterprises](struct.EnterpriseSetStoreLayoutCall.html) (request|response) +/// * [get store layout enterprises](struct.EnterpriseGetStoreLayoutCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct StorePage { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#storePage". - pub kind: Option, - /// Ordered list of pages a user should be able to reach from this page. The pages must exist, must not be this page, and once a link is created the page linked to cannot be deleted until all links to it are removed. It is recommended that the basic pages are created first, before adding the links between pages. +pub struct StoreLayout { + /// The ID of the store page to be used as the homepage. The homepage will be used as the first page shown in the Google Play for Work store. /// - /// No attempt is made to verify that all pages are reachable from the homepage. - pub link: Option>, - /// Unique ID of this page. Assigned by the server. Immutable once assigned. - pub id: Option, - /// Ordered list of localized strings giving the name of this page. The text displayed is the one that best matches the user locale, or the first entry if there is no good match. There needs to be at least one entry. - pub name: Option>, + /// If a homepage has not been set, the Play store shown on devices will be empty. Not specifying a homepage on a store layout effectively empties the store. + /// + /// If there exists at least one page, this field must be set to the ID of a valid page. + #[serde(rename="homepageId")] + pub homepage_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#storeLayout". + pub kind: Option, } -impl RequestValue for StorePage {} -impl ResponseResult for StorePage {} +impl RequestValue for StoreLayout {} +impl ResponseResult for StoreLayout {} + + +/// Credentials that can be used to authenticate as a service account. +/// +/// # 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 serviceaccountkeys](struct.ServiceaccountkeyInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ServiceAccountKey { + /// The body of the private key credentials file, in string format. This is only populated when the ServiceAccountKey is created, and is not stored by Google. + pub data: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#serviceAccountKey". + pub kind: Option, + /// The file format of the generated key data. + #[serde(rename="type")] + pub type_: Option, + /// An opaque, unique identifier for this ServiceAccountKey. Assigned by the server. + pub id: Option, +} + +impl RequestValue for ServiceAccountKey {} +impl Resource for ServiceAccountKey {} +impl ResponseResult for ServiceAccountKey {} + + +/// A Products resource represents an app in the Google Play Store that is available to at least some users in the enterprise. (Some apps are restricted to a single enterprise, and no information about them is made available outside that enterprise.) +/// +/// The information provided for each product (localized name, icon, link to the full Google Play details page) is intended to allow a basic representation of the product within an EMM user interface. +/// +/// # 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 permissions products](struct.ProductUpdatePermissionCall.html) (none) +/// * [get permissions products](struct.ProductGetPermissionCall.html) (none) +/// * [get products](struct.ProductGetCall.html) (response) +/// * [approve products](struct.ProductApproveCall.html) (none) +/// * [get app restrictions schema products](struct.ProductGetAppRestrictionsSchemaCall.html) (none) +/// * [list products](struct.ProductListCall.html) (none) +/// * [unapprove products](struct.ProductUnapproveCall.html) (none) +/// * [generate approval url products](struct.ProductGenerateApprovalUrlCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Product { + /// A link to a smaller image that can be used as an icon for the product. This image is suitable for use at up to 128px x 128px. + #[serde(rename="smallIconUrl")] + pub small_icon_url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#product". + pub kind: Option, + /// How and to whom the package is made available. The value publicGoogleHosted means that the package is available through the Play Store and not restricted to a specific enterprise. The value privateGoogleHosted means that the package is a private app (restricted to an enterprise) but hosted by Google. The value privateSelfHosted means that the package is a private app (restricted to an enterprise) and is privately hosted. + #[serde(rename="distributionChannel")] + pub distribution_channel: Option, + /// The name of the product. + pub title: Option, + /// A link to the Google Play for Work details page for the product, for use by an Enterprise administrator. + #[serde(rename="workDetailsUrl")] + pub work_details_url: Option, + /// App versions currently available for this product. The returned list contains only public versions. Alpha and beta versions are not included. + #[serde(rename="appVersion")] + pub app_version: Option>, + /// Whether this product is free, free with in-app purchases, or paid. If the pricing is unknown, this means the product is not generally available anymore (even though it might still be available to people who own it). + #[serde(rename="productPricing")] + pub product_pricing: Option, + /// A link to an image that can be used as an icon for the product. This image is suitable for use at up to 512px x 512px. + #[serde(rename="iconUrl")] + pub icon_url: Option, + /// The name of the author of the product (e.g. the app developer). + #[serde(rename="authorName")] + pub author_name: Option, + /// Whether this app can only be installed on devices using the Android for Work container app. + #[serde(rename="requiresContainerApp")] + pub requires_container_app: Option, + /// A link to the (consumer) Google Play details page for the product. + #[serde(rename="detailsUrl")] + pub details_url: Option, + /// A string of the form app:. For example, app:com.google.android.gm represents the Gmail app. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Resource for Product {} +impl ResponseResult for Product {} /// There is no detailed description. @@ -1053,68 +1445,6 @@ pub struct ProductsApproveRequest { impl RequestValue for ProductsApproveRequest {} -/// Information about the permissions required by a specific app and whether they have been accepted by the enterprise. -/// -/// # 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 permissions products](struct.ProductUpdatePermissionCall.html) (request|response) -/// * [get permissions products](struct.ProductGetPermissionCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ProductPermissions { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#productPermissions". - pub kind: Option, - /// The permissions required by the app. - pub permission: Option>, - /// The ID of the app that the permissions relate to, e.g. "app:com.google.android.gm". - #[serde(rename="productId")] - pub product_id: Option, -} - -impl RequestValue for ProductPermissions {} -impl ResponseResult for ProductPermissions {} - - -/// A user resource represents an individual user within the enterprise's domain. -/// -/// Note that each user is associated with a Google account based on the user's corporate email address (which must be in one of the enterprise's domains). As part of installing the EMM's DPC app to manage a device the Google account must be provisioned to the device, and so the user resource must be created before that. This can be done using the Google Admin SDK Directory API. -/// -/// The ID for a user is an opaque string. It can be retrieved using the list method queried by the user's primary email address. -/// -/// # 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*). -/// -/// * [revoke token users](struct.UserRevokeTokenCall.html) (none) -/// * [update collectionviewers](struct.CollectionviewerUpdateCall.html) (request|response) -/// * [patch collectionviewers](struct.CollectionviewerPatchCall.html) (request|response) -/// * [list users](struct.UserListCall.html) (none) -/// * [get collectionviewers](struct.CollectionviewerGetCall.html) (response) -/// * [set available product set users](struct.UserSetAvailableProductSetCall.html) (none) -/// * [generate token users](struct.UserGenerateTokenCall.html) (none) -/// * [get available product set users](struct.UserGetAvailableProductSetCall.html) (none) -/// * [get users](struct.UserGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct User { - /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#user". - pub kind: Option, - /// The user's primary email, e.g. "jsmith@example.com". - #[serde(rename="primaryEmail")] - pub primary_email: Option, - /// The unique ID for the user. - pub id: Option, -} - -impl RequestValue for User {} -impl Resource for User {} -impl ResponseResult for User {} - - /// The collection resources for the enterprise. /// /// # Activities @@ -1135,6 +1465,119 @@ pub struct CollectionsListResponse { impl ResponseResult for CollectionsListResponse {} +/// A managed property of a managed configuration. The property must match one of the properties in the app restrictions schema of the product. Exactly one of the value fields must be populated, and it must match the property's type in the app restrictions schema. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedProperty { + /// The boolean value - this will only be present if type of the property is bool. + #[serde(rename="valueBool")] + pub value_bool: Option, + /// The unique key that identifies the property. + pub key: Option, + /// The list of bundles of properties - this will only be present if type of the property is bundle_array. + #[serde(rename="valueBundleArray")] + pub value_bundle_array: Option>, + /// The integer value - this will only be present if type of the property is integer. + #[serde(rename="valueInteger")] + pub value_integer: Option, + /// The bundle of managed properties - this will only be present if type of the property is bundle. + #[serde(rename="valueBundle")] + pub value_bundle: Option, + /// The list of string values - this will only be present if type of the property is multiselect. + #[serde(rename="valueStringArray")] + pub value_string_array: Option>, + /// The string value - this will only be present if type of the property is string, choice or hidden. + #[serde(rename="valueString")] + pub value_string: Option, +} + +impl Part for ManagedProperty {} + + +/// A Users resource represents an account associated with an enterprise. The account may be specific to a device or to an individual user (who can then use the account across multiple devices). The account may provide access to Google Play for Work only, or to other Google services, depending on the identity model: +/// - Google managed domain identity model requires synchronization to Google account sources (via primaryEmail). +/// - Android for Work Accounts identity model provides a dynamic means for enterprises to create user or device accounts as needed. These accounts provide access to Google Play for Work only. +/// +/// # 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*). +/// +/// * [revoke token users](struct.UserRevokeTokenCall.html) (none) +/// * [delete users](struct.UserDeleteCall.html) (none) +/// * [update collectionviewers](struct.CollectionviewerUpdateCall.html) (request|response) +/// * [patch collectionviewers](struct.CollectionviewerPatchCall.html) (request|response) +/// * [generate authentication token users](struct.UserGenerateAuthenticationTokenCall.html) (none) +/// * [list users](struct.UserListCall.html) (none) +/// * [update users](struct.UserUpdateCall.html) (request|response) +/// * [get collectionviewers](struct.CollectionviewerGetCall.html) (response) +/// * [patch users](struct.UserPatchCall.html) (request|response) +/// * [set available product set users](struct.UserSetAvailableProductSetCall.html) (none) +/// * [insert users](struct.UserInsertCall.html) (request|response) +/// * [generate token users](struct.UserGenerateTokenCall.html) (none) +/// * [get available product set users](struct.UserGetAvailableProductSetCall.html) (none) +/// * [get users](struct.UserGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct User { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#user". + pub kind: Option, + /// The name that will appear in user interfaces. Setting this property is optional when creating EMM-managed users. If you do set this property, use something generic about the organization (such as "Example, Inc.") or your name (as EMM). Not used for Google-managed user accounts. + #[serde(rename="displayName")] + pub display_name: Option, + /// The user's primary email address, for example, "jsmith@example.com". Will always be set for Google managed users and not set for EMM managed users. + #[serde(rename="primaryEmail")] + pub primary_email: Option, + /// The type of account that this user represents. A userAccount can be installed on multiple devices, but a deviceAccount is specific to a single device. An EMM-managed user (emmManaged) can be either type (userAccount, deviceAccount), but a Google-managed user (googleManaged) is always a userAccount. + #[serde(rename="accountType")] + pub account_type: Option, + /// The unique ID for the user. + pub id: Option, + /// A unique identifier you create for this user, such as "user342" or "asset#44418". Do not use personally identifiable information (PII) for this property. Must always be set for EMM-managed users. Not set for Google-managed users. + #[serde(rename="accountIdentifier")] + pub account_identifier: Option, + /// The entity that manages the user. With googleManaged users, the source of truth is Google so EMMs have to make sure a Google Account exists for the user. With emmManaged users, the EMM is in charge. + #[serde(rename="managementType")] + pub management_type: Option, +} + +impl RequestValue for User {} +impl Resource for User {} +impl ResponseResult for User {} + + +/// An event generated when a product's approval status is changed. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductApprovalEvent { + /// Whether the product was approved or unapproved. This field will always be present. + pub approved: Option, + /// The id of the product (e.g. "app:com.google.android.gm") for which the approval status has changed. This field will always be present. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for ProductApprovalEvent {} + + +/// A bundle of managed properties. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedPropertyBundle { + /// The list of managed properties. + #[serde(rename="managedProperty")] + pub managed_property: Option>, +} + +impl Part for ManagedPropertyBundle {} + + /// A group license object indicates a product that an enterprise admin has approved for use in the enterprise. The product may be free or paid. For free products, a group license object is created in these cases: if the enterprise admin approves a product in Google Play, if the product is added to a collection, or if an entitlement for the product is created for a user via the API. For paid products, a group license object is only created as part of the first bulk purchase of that product in Google Play by the enterprise admin. /// /// The API can be used to query group licenses; the available information includes the total number of licenses purchased (for paid products) and the total number of licenses that have been provisioned, that is, the total number of user entitlements in existence for the product. @@ -1172,6 +1615,62 @@ impl Resource for GroupLicense {} impl ResponseResult for GroupLicense {} +/// 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 serviceaccountkeys](struct.ServiceaccountkeyListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ServiceAccountKeysListResponse { + /// The service account credentials. + #[serde(rename="serviceAccountKey")] + pub service_account_key: Option>, +} + +impl ResponseResult for ServiceAccountKeysListResponse {} + + +/// Information on an approval 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 ApprovalUrlInfo { + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#approvalUrlInfo". + pub kind: Option, + /// A URL that displays a product's permissions and that can also be used to approve the product with the Products.approve call. + #[serde(rename="approvalUrl")] + pub approval_url: Option, +} + +impl Part for ApprovalUrlInfo {} + + +/// The grouplicense resources for the enterprise. +/// +/// # 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 grouplicenses](struct.GrouplicenseListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GroupLicensesListResponse { + /// A group license for a product approved for use in the enterprise. + #[serde(rename="groupLicense")] + pub group_license: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#groupLicensesListResponse". + pub kind: Option, +} + +impl ResponseResult for GroupLicensesListResponse {} + + // ################### // MethodBuilders ### @@ -1217,15 +1716,17 @@ impl<'a, C, A> StorelayoutpageMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the details of all pages in the store. + /// Deletes a store page. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - pub fn list(&self, enterprise_id: &str) -> StorelayoutpageListCall<'a, C, A> { - StorelayoutpageListCall { + /// * `pageId` - The ID of the page. + pub fn delete(&self, enterprise_id: &str, page_id: &str) -> StorelayoutpageDeleteCall<'a, C, A> { + StorelayoutpageDeleteCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), + _page_id: page_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1234,15 +1735,17 @@ impl<'a, C, A> StorelayoutpageMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves details of a store page. + /// Updates the content of a store page. This method supports patch semantics. /// /// # Arguments /// + /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `pageId` - The ID of the page. - pub fn get(&self, enterprise_id: &str, page_id: &str) -> StorelayoutpageGetCall<'a, C, A> { - StorelayoutpageGetCall { + pub fn patch(&self, request: StorePage, enterprise_id: &str, page_id: &str) -> StorelayoutpagePatchCall<'a, C, A> { + StorelayoutpagePatchCall { hub: self.hub, + _request: request, _enterprise_id: enterprise_id.to_string(), _page_id: page_id.to_string(), _delegate: Default::default(), @@ -1293,17 +1796,15 @@ impl<'a, C, A> StorelayoutpageMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates the content of a store page. This method supports patch semantics. + /// Retrieves details of a store page. /// /// # Arguments /// - /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `pageId` - The ID of the page. - pub fn patch(&self, request: StorePage, enterprise_id: &str, page_id: &str) -> StorelayoutpagePatchCall<'a, C, A> { - StorelayoutpagePatchCall { + pub fn get(&self, enterprise_id: &str, page_id: &str) -> StorelayoutpageGetCall<'a, C, A> { + StorelayoutpageGetCall { hub: self.hub, - _request: request, _enterprise_id: enterprise_id.to_string(), _page_id: page_id.to_string(), _delegate: Default::default(), @@ -1314,17 +1815,15 @@ impl<'a, C, A> StorelayoutpageMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a store page. + /// Retrieves the details of all pages in the store. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `pageId` - The ID of the page. - pub fn delete(&self, enterprise_id: &str, page_id: &str) -> StorelayoutpageDeleteCall<'a, C, A> { - StorelayoutpageDeleteCall { + pub fn list(&self, enterprise_id: &str) -> StorelayoutpageListCall<'a, C, A> { + StorelayoutpageListCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _page_id: page_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1374,15 +1873,15 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Removes the user from the list of those specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only such users will see the collection. + /// Retrieves the ID of the user if they have been specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only these users will see the collection. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. /// * `collectionId` - The ID of the collection. /// * `userId` - The ID of the user. - pub fn delete(&self, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerDeleteCall<'a, C, A> { - CollectionviewerDeleteCall { + pub fn get(&self, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerGetCall<'a, C, A> { + CollectionviewerGetCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), _collection_id: collection_id.to_string(), @@ -1416,27 +1915,6 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Retrieves the ID of the user if they have been specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only these users will see the collection. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `collectionId` - The ID of the collection. - /// * `userId` - The ID of the user. - pub fn get(&self, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerGetCall<'a, C, A> { - CollectionviewerGetCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _collection_id: collection_id.to_string(), - _user_id: user_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Retrieves the IDs of the users who have been specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only these users will see the collection. @@ -1456,6 +1934,27 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Removes the user from the list of those specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only such users will see the collection. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `collectionId` - The ID of the collection. + /// * `userId` - The ID of the user. + pub fn delete(&self, enterprise_id: &str, collection_id: &str, user_id: &str) -> CollectionviewerDeleteCall<'a, C, A> { + CollectionviewerDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _collection_id: collection_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Adds the user to the list of those specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only such users will see the collection. @@ -1505,7 +2004,7 @@ impl<'a, C, A> CollectionviewerMethods<'a, C, A> { /// ::default(), None); /// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `generate_token(...)`, `get(...)`, `get_available_product_set(...)`, `list(...)`, `revoke_token(...)` and `set_available_product_set(...)` +/// // like `delete(...)`, `generate_authentication_token(...)`, `generate_token(...)`, `get(...)`, `get_available_product_set(...)`, `insert(...)`, `list(...)`, `patch(...)`, `revoke_token(...)`, `set_available_product_set(...)` and `update(...)` /// // to build up your call. /// let rb = hub.users(); /// # } @@ -1541,15 +2040,19 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves a user's details. + /// Updates the details of an EMM-managed user. + /// + /// Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value. /// /// # Arguments /// + /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `userId` - The ID of the user. - pub fn get(&self, enterprise_id: &str, user_id: &str) -> UserGetCall<'a, C, A> { - UserGetCall { + pub fn update(&self, request: User, enterprise_id: &str, user_id: &str) -> UserUpdateCall<'a, C, A> { + UserUpdateCall { hub: self.hub, + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _delegate: Default::default(), @@ -1560,36 +2063,19 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Looks up a user by their primary email address. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `email` - The exact primary email address of the user to look up. - pub fn list(&self, enterprise_id: &str, email: &str) -> UserListCall<'a, C, A> { - UserListCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _email: email.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Generates a token (activation code) to allow this user to configure their work account in the Android Setup Wizard. Revokes any previously generated token. - /// - /// This call only works with Google managed accounts. + /// Updates the details of an EMM-managed user. + /// + /// Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value. This method supports patch semantics. /// /// # Arguments /// + /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. /// * `userId` - The ID of the user. - pub fn generate_token(&self, enterprise_id: &str, user_id: &str) -> UserGenerateTokenCall<'a, C, A> { - UserGenerateTokenCall { + pub fn patch(&self, request: User, enterprise_id: &str, user_id: &str) -> UserPatchCall<'a, C, A> { + UserPatchCall { hub: self.hub, + _request: request, _enterprise_id: enterprise_id.to_string(), _user_id: user_id.to_string(), _delegate: Default::default(), @@ -1637,6 +2123,126 @@ impl<'a, C, A> UserMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a user's details. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + pub fn get(&self, enterprise_id: &str, user_id: &str) -> UserGetCall<'a, C, A> { + UserGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a new EMM-managed user. + /// + /// The Users resource passed in the body of the request should include an accountIdentifier and an accountType. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `enterpriseId` - The ID of the enterprise. + pub fn insert(&self, request: User, enterprise_id: &str) -> UserInsertCall<'a, C, A> { + UserInsertCall { + hub: self.hub, + _request: request, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates a token (activation code) to allow this user to configure their work account in the Android Setup Wizard. Revokes any previously generated token. + /// + /// This call only works with Google managed accounts. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + pub fn generate_token(&self, enterprise_id: &str, user_id: &str) -> UserGenerateTokenCall<'a, C, A> { + UserGenerateTokenCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deleted an EMM-managed user. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + pub fn delete(&self, enterprise_id: &str, user_id: &str) -> UserDeleteCall<'a, C, A> { + UserDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Looks up a user by primary email address. This is only supported for Google-managed users. Lookup of the id is not needed for EMM-managed users because the id is already returned in the result of the Users.insert call. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `email` - The exact primary email address of the user to look up. + pub fn list(&self, enterprise_id: &str, email: &str) -> UserListCall<'a, C, A> { + UserListCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _email: email.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates an authentication token which the device policy client can use to provision the given EMM-managed user account on a device. The generated token is single-use and expires after a few minutes. + /// + /// This call only works with EMM-managed accounts. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + pub fn generate_authentication_token(&self, enterprise_id: &str, user_id: &str) -> UserGenerateAuthenticationTokenCall<'a, C, A> { + UserGenerateAuthenticationTokenCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -1704,6 +2310,29 @@ impl<'a, C, A> InstallMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Requests to remove an app from a device. A call to get or list will still show the app as installed on the device until it is actually removed. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + /// * `installId` - The ID of the product represented by the install, e.g. "app:com.google.android.gm". + pub fn delete(&self, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallDeleteCall<'a, C, A> { + InstallDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _install_id: install_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves details of an installation of an app on a device. @@ -1748,29 +2377,6 @@ impl<'a, C, A> InstallMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Requests to remove an app from a device. A call to get or list will still show the app as installed on the device until it is actually removed. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `userId` - The ID of the user. - /// * `deviceId` - The Android ID of the device. - /// * `installId` - The ID of the product represented by the install, e.g. "app:com.google.android.gm". - pub fn delete(&self, enterprise_id: &str, user_id: &str, device_id: &str, install_id: &str) -> InstallDeleteCall<'a, C, A> { - InstallDeleteCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _user_id: user_id.to_string(), - _device_id: device_id.to_string(), - _install_id: install_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Requests to install the latest version of an app to a device. If the app is already installed then it is updated to the latest version if necessary. @@ -1799,6 +2405,241 @@ impl<'a, C, A> InstallMethods<'a, C, A> { +/// A builder providing access to all methods supported on *grouplicense* resources. +/// It is not used directly, but through the `AndroidEnterprise` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_androidenterprise1 as androidenterprise1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use androidenterprise1::AndroidEnterprise; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = AndroidEnterprise::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.grouplicenses(); +/// # } +/// ``` +pub struct GrouplicenseMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, +} + +impl<'a, C, A> MethodsBuilder for GrouplicenseMethods<'a, C, A> {} + +impl<'a, C, A> GrouplicenseMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves details of an enterprise's group license for a product. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `groupLicenseId` - The ID of the product the group license is for, e.g. "app:com.google.android.gm". + pub fn get(&self, enterprise_id: &str, group_license_id: &str) -> GrouplicenseGetCall<'a, C, A> { + GrouplicenseGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _group_license_id: group_license_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves IDs of all products for which the enterprise has a group license. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn list(&self, enterprise_id: &str) -> GrouplicenseListCall<'a, C, A> { + GrouplicenseListCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *managedconfigurationsfordevice* resources. +/// It is not used directly, but through the `AndroidEnterprise` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_androidenterprise1 as androidenterprise1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use androidenterprise1::AndroidEnterprise; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.managedconfigurationsfordevice(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordeviceMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, +} + +impl<'a, C, A> MethodsBuilder for ManagedconfigurationsfordeviceMethods<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordeviceMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Adds or updates a per-device managed configuration for an app for the specified device. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + /// * `managedConfigurationForDeviceId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn update(&self, request: ManagedConfiguration, enterprise_id: &str, user_id: &str, device_id: &str, managed_configuration_for_device_id: &str) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + ManagedconfigurationsfordeviceUpdateCall { + hub: self.hub, + _request: request, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _managed_configuration_for_device_id: managed_configuration_for_device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Adds or updates a per-device managed configuration for an app for the specified device. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + /// * `managedConfigurationForDeviceId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn patch(&self, request: ManagedConfiguration, enterprise_id: &str, user_id: &str, device_id: &str, managed_configuration_for_device_id: &str) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + ManagedconfigurationsfordevicePatchCall { + hub: self.hub, + _request: request, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _managed_configuration_for_device_id: managed_configuration_for_device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists all the per-device managed configurations for the specified device. Only the ID is set. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + pub fn list(&self, enterprise_id: &str, user_id: &str, device_id: &str) -> ManagedconfigurationsfordeviceListCall<'a, C, A> { + ManagedconfigurationsfordeviceListCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Removes a per-device managed configuration for an app for the specified device. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + /// * `managedConfigurationForDeviceId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn delete(&self, enterprise_id: &str, user_id: &str, device_id: &str, managed_configuration_for_device_id: &str) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + ManagedconfigurationsfordeviceDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _managed_configuration_for_device_id: managed_configuration_for_device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves details of a per-device managed configuration. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The Android ID of the device. + /// * `managedConfigurationForDeviceId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn get(&self, enterprise_id: &str, user_id: &str, device_id: &str, managed_configuration_for_device_id: &str) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + ManagedconfigurationsfordeviceGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _managed_configuration_for_device_id: managed_configuration_for_device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *device* resources. /// It is not used directly, but through the `AndroidEnterprise` hub. /// @@ -1839,7 +2680,7 @@ impl<'a, C, A> DeviceMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sets whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. + /// Sets whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users. /// /// # Arguments /// @@ -1862,7 +2703,28 @@ impl<'a, C, A> DeviceMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. + /// Retrieves the details of a device. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `deviceId` - The ID of the device. + pub fn get(&self, enterprise_id: &str, user_id: &str, device_id: &str) -> DeviceGetCall<'a, C, A> { + DeviceGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _device_id: device_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users. /// /// # Arguments /// @@ -1899,27 +2761,6 @@ impl<'a, C, A> DeviceMethods<'a, C, A> { _additional_params: Default::default(), } } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the details of a device. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `userId` - The ID of the user. - /// * `deviceId` - The ID of the device. - pub fn get(&self, enterprise_id: &str, user_id: &str, device_id: &str) -> DeviceGetCall<'a, C, A> { - DeviceGetCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _user_id: user_id.to_string(), - _device_id: device_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } } @@ -1947,7 +2788,7 @@ impl<'a, C, A> DeviceMethods<'a, C, A> { /// ::default(), None); /// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `enroll(...)`, `get(...)`, `get_store_layout(...)`, `insert(...)`, `list(...)`, `send_test_push_notification(...)`, `set_account(...)`, `set_store_layout(...)` and `unenroll(...)` +/// // like `acknowledge_notification_set(...)`, `complete_signup(...)`, `delete(...)`, `enroll(...)`, `generate_signup_url(...)`, `get(...)`, `get_service_account(...)`, `get_store_layout(...)`, `insert(...)`, `list(...)`, `pull_notification_set(...)`, `send_test_push_notification(...)`, `set_account(...)`, `set_store_layout(...)` and `unenroll(...)` /// // to build up your call. /// let rb = hub.enterprises(); /// # } @@ -1962,23 +2803,6 @@ impl<'a, C, A> MethodsBuilder for EnterpriseMethods<'a, C, A> {} impl<'a, C, A> EnterpriseMethods<'a, C, A> { - /// Create a builder to help you perform the following task: - /// - /// Unenrolls an enterprise from the calling EMM. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - pub fn unenroll(&self, enterprise_id: &str) -> EnterpriseUnenrollCall<'a, C, A> { - EnterpriseUnenrollCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Establishes the binding between the EMM and an enterprise. This is now deprecated; use enroll instead. @@ -2000,75 +2824,7 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sends a test push notification to validate the EMM integration with the Google Cloud Pub/Sub service for this enterprise. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - pub fn send_test_push_notification(&self, enterprise_id: &str) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { - EnterpriseSendTestPushNotificationCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Looks up an enterprise by domain name. - /// - /// # Arguments - /// - /// * `domain` - The exact primary domain name of the enterprise to look up. - pub fn list(&self, domain: &str) -> EnterpriseListCall<'a, C, A> { - EnterpriseListCall { - hub: self.hub, - _domain: domain.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the name and domain of an enterprise. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - pub fn get(&self, enterprise_id: &str) -> EnterpriseGetCall<'a, C, A> { - EnterpriseGetCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the store layout resource. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - pub fn get_store_layout(&self, enterprise_id: &str) -> EnterpriseGetStoreLayoutCall<'a, C, A> { - EnterpriseGetStoreLayoutCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Sets the store layout resource. + /// Sets the store layout for the enterprise. /// /// # Arguments /// @@ -2085,6 +2841,22 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Pulls and returns a notification set for the enterprises associated with the service account authenticated for the request. The notification set may be empty if no notification are pending. + /// A notification set returned needs to be acknowledged within 20 seconds by calling Enterprises.AcknowledgeNotificationSet, unless the notification set is empty. + /// Notifications that are not acknowledged within the 20 seconds will eventually be included again in the response to another PullNotificationSet request, and those that are never acknowledged will ultimately be deleted according to the Google Cloud Platform Pub/Sub system policy. + /// Multiple requests might be performed concurrently to retrieve notifications, in which case the pending notifications (if any) will be split among each caller, if any are pending. + pub fn pull_notification_set(&self) -> EnterprisePullNotificationSetCall<'a, C, A> { + EnterprisePullNotificationSetCall { + hub: self.hub, + _request_mode: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Enrolls an enterprise with the calling EMM. @@ -2123,6 +2895,142 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Looks up an enterprise by domain name. This is only supported for enterprises created via the Google-initiated creation flow. Lookup of the id is not needed for enterprises created via the EMM-initiated flow since the EMM learns the enterprise ID in the callback specified in the Enterprises.generateSignupUrl call. + /// + /// # Arguments + /// + /// * `domain` - The exact primary domain name of the enterprise to look up. + pub fn list(&self, domain: &str) -> EnterpriseListCall<'a, C, A> { + EnterpriseListCall { + hub: self.hub, + _domain: domain.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns the store layout for the enterprise. If the store layout has not been set, or if the store layout has no homepageId set, returns a NOT_FOUND error. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn get_store_layout(&self, enterprise_id: &str) -> EnterpriseGetStoreLayoutCall<'a, C, A> { + EnterpriseGetStoreLayoutCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Completes the signup flow, by specifying the Completion token and Enterprise token. This request must not be called multiple times for a given Enterprise Token. + pub fn complete_signup(&self) -> EnterpriseCompleteSignupCall<'a, C, A> { + EnterpriseCompleteSignupCall { + hub: self.hub, + _enterprise_token: Default::default(), + _completion_token: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a service account and credentials. The service account can be bound to the enterprise by calling setAccount. The service account is unique to this enterprise and EMM, and will be deleted if the enterprise is unbound. The credentials contain private key data and are not stored server-side. + /// + /// This method can only be called after calling Enterprises.Enroll or Enterprises.CompleteSignup, and before Enterprises.SetAccount; at other times it will return an error. + /// + /// Subsequent calls after the first will generate a new, unique set of credentials, and invalidate the previously generated credentials. + /// + /// Once the service account is bound to the enterprise, it can be managed using the serviceAccountKeys resource. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn get_service_account(&self, enterprise_id: &str) -> EnterpriseGetServiceAccountCall<'a, C, A> { + EnterpriseGetServiceAccountCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _key_type: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Acknowledges notifications that were received from Enterprises.PullNotificationSet to prevent subsequent calls from returning the same notifications. + pub fn acknowledge_notification_set(&self) -> EnterpriseAcknowledgeNotificationSetCall<'a, C, A> { + EnterpriseAcknowledgeNotificationSetCall { + hub: self.hub, + _notification_set_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Unenrolls an enterprise from the calling EMM. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn unenroll(&self, enterprise_id: &str) -> EnterpriseUnenrollCall<'a, C, A> { + EnterpriseUnenrollCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Sends a test push notification to validate the EMM integration with the Google Cloud Pub/Sub service for this enterprise. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn send_test_push_notification(&self, enterprise_id: &str) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { + EnterpriseSendTestPushNotificationCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the name and domain of an enterprise. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn get(&self, enterprise_id: &str) -> EnterpriseGetCall<'a, C, A> { + EnterpriseGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes the binding between the EMM and enterprise. This is now deprecated; use this to unenroll customers that were previously enrolled with the 'insert' call, then enroll them again with the 'enroll' call. @@ -2139,6 +3047,19 @@ impl<'a, C, A> EnterpriseMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Generates a sign-up URL. + pub fn generate_signup_url(&self) -> EnterpriseGenerateSignupUrlCall<'a, C, A> { + EnterpriseGenerateSignupUrlCall { + hub: self.hub, + _callback_url: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -2183,19 +3104,17 @@ impl<'a, C, A> StorelayoutclusterMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a cluster. + /// Retrieves the details of all clusters on the specified page. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. /// * `pageId` - The ID of the page. - /// * `clusterId` - The ID of the cluster. - pub fn delete(&self, enterprise_id: &str, page_id: &str, cluster_id: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { - StorelayoutclusterDeleteCall { + pub fn list(&self, enterprise_id: &str, page_id: &str) -> StorelayoutclusterListCall<'a, C, A> { + StorelayoutclusterListCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), _page_id: page_id.to_string(), - _cluster_id: cluster_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2248,25 +3167,6 @@ impl<'a, C, A> StorelayoutclusterMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Retrieves the details of all clusters on the specified page. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `pageId` - The ID of the page. - pub fn list(&self, enterprise_id: &str, page_id: &str) -> StorelayoutclusterListCall<'a, C, A> { - StorelayoutclusterListCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _page_id: page_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Retrieves details of a cluster. @@ -2308,11 +3208,32 @@ impl<'a, C, A> StorelayoutclusterMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a cluster. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `pageId` - The ID of the page. + /// * `clusterId` - The ID of the cluster. + pub fn delete(&self, enterprise_id: &str, page_id: &str, cluster_id: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { + StorelayoutclusterDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _page_id: page_id.to_string(), + _cluster_id: cluster_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } -/// A builder providing access to all methods supported on *collection* resources. +/// A builder providing access to all methods supported on *product* resources. /// It is not used directly, but through the `AndroidEnterprise` hub. /// /// # Example @@ -2335,34 +3256,76 @@ impl<'a, C, A> StorelayoutclusterMethods<'a, C, A> { /// ::default(), None); /// let mut hub = AndroidEnterprise::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(...)` +/// // like `approve(...)`, `generate_approval_url(...)`, `get(...)`, `get_app_restrictions_schema(...)`, `get_permissions(...)`, `list(...)`, `unapprove(...)` and `update_permissions(...)` /// // to build up your call. -/// let rb = hub.collections(); +/// let rb = hub.products(); /// # } /// ``` -pub struct CollectionMethods<'a, C, A> +pub struct ProductMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, } -impl<'a, C, A> MethodsBuilder for CollectionMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for ProductMethods<'a, C, A> {} -impl<'a, C, A> CollectionMethods<'a, C, A> { +impl<'a, C, A> ProductMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Creates a new collection. + /// Retrieves the Android app permissions required by this app. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `productId` - The ID of the product. + pub fn get_permissions(&self, enterprise_id: &str, product_id: &str) -> ProductGetPermissionCall<'a, C, A> { + ProductGetPermissionCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Unapproves the specified product (and the relevant app permissions, if any) + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `productId` - The ID of the product. + pub fn unapprove(&self, enterprise_id: &str, product_id: &str) -> ProductUnapproveCall<'a, C, A> { + ProductUnapproveCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Approves the specified product and the relevant app permissions, if any. The maximum number of products that you can approve per enterprise customer is 1,000. + /// + /// To learn how to use Google Play for Work to design and create a store layout to display approved products to your users, see Store Layout Design. /// /// # Arguments /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - pub fn insert(&self, request: Collection, enterprise_id: &str) -> CollectionInsertCall<'a, C, A> { - CollectionInsertCall { + /// * `productId` - The ID of the product. + pub fn approve(&self, request: ProductsApproveRequest, enterprise_id: &str, product_id: &str) -> ProductApproveCall<'a, C, A> { + ProductApproveCall { hub: self.hub, _request: request, _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2371,19 +3334,21 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a collection. This method supports patch semantics. + /// This method has been deprecated. To programmatically approve applications, you must use the iframe mechanism via the generateApprovalUrl and approve methods of the Products resource. For more information, see the Play EMM API usage requirements. + /// + /// The updatePermissions method (deprecated) updates the set of Android app permissions for this app that have been accepted by the enterprise. /// /// # Arguments /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - /// * `collectionId` - The ID of the collection. - pub fn patch(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionPatchCall<'a, C, A> { - CollectionPatchCall { + /// * `productId` - The ID of the product. + pub fn update_permissions(&self, request: ProductPermissions, enterprise_id: &str, product_id: &str) -> ProductUpdatePermissionCall<'a, C, A> { + ProductUpdatePermissionCall { hub: self.hub, _request: request, _enterprise_id: enterprise_id.to_string(), - _collection_id: collection_id.to_string(), + _product_id: product_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2392,19 +3357,146 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a collection. + /// Retrieves the schema that defines the configurable properties for this product. All products have a schema, but this schema may be empty if no managed configurations have been defined. This schema can be used to populate a UI that allows an administrator to configure the product. To apply a managed configuration based on the schema obtained using this API, see Managed Configurations through Play. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `productId` - The ID of the product. + pub fn get_app_restrictions_schema(&self, enterprise_id: &str, product_id: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { + ProductGetAppRestrictionsSchemaCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), + _language: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Finds approved products that match a query, or all approved products if there is no query. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + pub fn list(&self, enterprise_id: &str) -> ProductListCall<'a, C, A> { + ProductListCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _token: Default::default(), + _query: Default::default(), + _max_results: Default::default(), + _language: Default::default(), + _approved: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves details of a product for display to an enterprise admin. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `productId` - The ID of the product, e.g. "app:com.google.android.gm". + pub fn get(&self, enterprise_id: &str, product_id: &str) -> ProductGetCall<'a, C, A> { + ProductGetCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), + _language: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates a URL that can be rendered in an iframe to display the permissions (if any) of a product. An enterprise admin must view these permissions and accept them on behalf of their organization in order to approve that product. + /// + /// Admins should accept the displayed permissions by interacting with a separate UI element in the EMM console, which in turn should trigger the use of this URL as the approvalUrlInfo.approvalUrl property in a Products.approve call to approve the product. This URL can only be used to display permissions for up to 1 day. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `productId` - The ID of the product. + pub fn generate_approval_url(&self, enterprise_id: &str, product_id: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { + ProductGenerateApprovalUrlCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _product_id: product_id.to_string(), + _language_code: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *managedconfigurationsforuser* resources. +/// It is not used directly, but through the `AndroidEnterprise` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_androidenterprise1 as androidenterprise1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use androidenterprise1::AndroidEnterprise; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.managedconfigurationsforuser(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, +} + +impl<'a, C, A> MethodsBuilder for ManagedconfigurationsforuserMethods<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Adds or updates a per-user managed configuration for an app for the specified user. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - /// * `collectionId` - The ID of the collection. - pub fn update(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionUpdateCall<'a, C, A> { - CollectionUpdateCall { + /// * `userId` - The ID of the user. + /// * `managedConfigurationForUserId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn patch(&self, request: ManagedConfiguration, enterprise_id: &str, user_id: &str, managed_configuration_for_user_id: &str) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + ManagedconfigurationsforuserPatchCall { hub: self.hub, _request: request, _enterprise_id: enterprise_id.to_string(), - _collection_id: collection_id.to_string(), + _user_id: user_id.to_string(), + _managed_configuration_for_user_id: managed_configuration_for_user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2413,15 +3505,17 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the IDs of all the collections for an enterprise. + /// Lists all the per-user managed configurations for the specified user. Only the ID is set. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - pub fn list(&self, enterprise_id: &str) -> CollectionListCall<'a, C, A> { - CollectionListCall { + /// * `userId` - The ID of the user. + pub fn list(&self, enterprise_id: &str, user_id: &str) -> ManagedconfigurationsforuserListCall<'a, C, A> { + ManagedconfigurationsforuserListCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2430,17 +3524,19 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a collection. + /// Removes a per-user managed configuration for an app for the specified user. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `collectionId` - The ID of the collection. - pub fn delete(&self, enterprise_id: &str, collection_id: &str) -> CollectionDeleteCall<'a, C, A> { - CollectionDeleteCall { + /// * `userId` - The ID of the user. + /// * `managedConfigurationForUserId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn delete(&self, enterprise_id: &str, user_id: &str, managed_configuration_for_user_id: &str) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> { + ManagedconfigurationsforuserDeleteCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _collection_id: collection_id.to_string(), + _user_id: user_id.to_string(), + _managed_configuration_for_user_id: managed_configuration_for_user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2449,17 +3545,42 @@ impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the details of a collection. + /// Adds or updates a per-user managed configuration for an app for the specified user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `managedConfigurationForUserId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn update(&self, request: ManagedConfiguration, enterprise_id: &str, user_id: &str, managed_configuration_for_user_id: &str) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + ManagedconfigurationsforuserUpdateCall { + hub: self.hub, + _request: request, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _managed_configuration_for_user_id: managed_configuration_for_user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves details of a per-user managed configuration for an app for the specified user. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `collectionId` - The ID of the collection. - pub fn get(&self, enterprise_id: &str, collection_id: &str) -> CollectionGetCall<'a, C, A> { - CollectionGetCall { + /// * `userId` - The ID of the user. + /// * `managedConfigurationForUserId` - The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + pub fn get(&self, enterprise_id: &str, user_id: &str, managed_configuration_for_user_id: &str) -> ManagedconfigurationsforuserGetCall<'a, C, A> { + ManagedconfigurationsforuserGetCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _collection_id: collection_id.to_string(), + _user_id: user_id.to_string(), + _managed_configuration_for_user_id: managed_configuration_for_user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2567,6 +3688,25 @@ impl<'a, C, A> MethodsBuilder for EntitlementMethods<'a, C, A> {} impl<'a, C, A> EntitlementMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// List of all entitlements for the specified user. Only the ID is set. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + pub fn list(&self, enterprise_id: &str, user_id: &str) -> EntitlementListCall<'a, C, A> { + EntitlementListCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Adds or updates an entitlement to an app for a user. @@ -2591,25 +3731,6 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// List of all entitlements for the specified user. Only the ID is set. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `userId` - The ID of the user. - pub fn list(&self, enterprise_id: &str, user_id: &str) -> EntitlementListCall<'a, C, A> { - EntitlementListCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _user_id: user_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Retrieves details of an entitlement. @@ -2631,6 +3752,27 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Removes an entitlement to an app for a user and uninstalls it. + /// + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `userId` - The ID of the user. + /// * `entitlementId` - The ID of the entitlement (a product ID), e.g. "app:com.google.android.gm". + pub fn delete(&self, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementDeleteCall<'a, C, A> { + EntitlementDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _user_id: user_id.to_string(), + _entitlement_id: entitlement_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Adds or updates an entitlement to an app for a user. This method supports patch semantics. @@ -2654,32 +3796,11 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { _additional_params: Default::default(), } } - - /// Create a builder to help you perform the following task: - /// - /// Removes an entitlement to an app for a user and uninstalls it. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `userId` - The ID of the user. - /// * `entitlementId` - The ID of the entitlement (a product ID), e.g. "app:com.google.android.gm". - pub fn delete(&self, enterprise_id: &str, user_id: &str, entitlement_id: &str) -> EntitlementDeleteCall<'a, C, A> { - EntitlementDeleteCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _user_id: user_id.to_string(), - _entitlement_id: entitlement_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } } -/// A builder providing access to all methods supported on *product* resources. +/// A builder providing access to all methods supported on *collection* resources. /// It is not used directly, but through the `AndroidEnterprise` hub. /// /// # Example @@ -2702,55 +3823,36 @@ impl<'a, C, A> EntitlementMethods<'a, C, A> { /// ::default(), None); /// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `approve(...)`, `generate_approval_url(...)`, `get(...)`, `get_app_restrictions_schema(...)`, `get_permissions(...)` and `update_permissions(...)` +/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. -/// let rb = hub.products(); +/// let rb = hub.collections(); /// # } /// ``` -pub struct ProductMethods<'a, C, A> +pub struct CollectionMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, } -impl<'a, C, A> MethodsBuilder for ProductMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for CollectionMethods<'a, C, A> {} -impl<'a, C, A> ProductMethods<'a, C, A> { +impl<'a, C, A> CollectionMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the Android app permissions required by this app. - /// - /// # Arguments - /// - /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product. - pub fn get_permissions(&self, enterprise_id: &str, product_id: &str) -> ProductGetPermissionCall<'a, C, A> { - ProductGetPermissionCall { - hub: self.hub, - _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Approves the specified product (and the relevant app permissions, if any). + /// Updates a collection. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product. - pub fn approve(&self, request: ProductsApproveRequest, enterprise_id: &str, product_id: &str) -> ProductApproveCall<'a, C, A> { - ProductApproveCall { + /// * `collectionId` - The ID of the collection. + pub fn patch(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionPatchCall<'a, C, A> { + CollectionPatchCall { hub: self.hub, _request: request, _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), + _collection_id: collection_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2759,18 +3861,15 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the schema defining app restrictions configurable for this product. All products have a schema, but this may be empty if no app restrictions are defined. + /// Retrieves the IDs of all the collections for an enterprise. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product. - pub fn get_app_restrictions_schema(&self, enterprise_id: &str, product_id: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { - ProductGetAppRestrictionsSchemaCall { + pub fn list(&self, enterprise_id: &str) -> CollectionListCall<'a, C, A> { + CollectionListCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), - _language: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2779,18 +3878,17 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves details of a product for display to an enterprise admin. + /// Retrieves the details of a collection. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product, e.g. "app:com.google.android.gm". - pub fn get(&self, enterprise_id: &str, product_id: &str) -> ProductGetCall<'a, C, A> { - ProductGetCall { + /// * `collectionId` - The ID of the collection. + pub fn get(&self, enterprise_id: &str, collection_id: &str) -> CollectionGetCall<'a, C, A> { + CollectionGetCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), - _language: Default::default(), + _collection_id: collection_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2799,21 +3897,36 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// This method has been deprecated. To programmatically approve applications, you must use the iframe mechanism via the generateApprovalUrl and approve methods of the Products resource. For more information, see the Play EMM API usage requirements. + /// Deletes a collection. /// - /// The updatePermissions method (deprecated) updates the set of Android app permissions for this app that have been accepted by the enterprise. + /// # Arguments + /// + /// * `enterpriseId` - The ID of the enterprise. + /// * `collectionId` - The ID of the collection. + pub fn delete(&self, enterprise_id: &str, collection_id: &str) -> CollectionDeleteCall<'a, C, A> { + CollectionDeleteCall { + hub: self.hub, + _enterprise_id: enterprise_id.to_string(), + _collection_id: collection_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a new collection. /// /// # Arguments /// /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product. - pub fn update_permissions(&self, request: ProductPermissions, enterprise_id: &str, product_id: &str) -> ProductUpdatePermissionCall<'a, C, A> { - ProductUpdatePermissionCall { + pub fn insert(&self, request: Collection, enterprise_id: &str) -> CollectionInsertCall<'a, C, A> { + CollectionInsertCall { hub: self.hub, _request: request, _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2822,20 +3935,19 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Generates a URL that can be rendered in an iframe to display the permissions (if any) of a product. An enterprise admin must view these permissions and accept them on behalf of their organization in order to approve that product. - /// - /// Admins should accept the displayed permissions by interacting with a separate UI element in the EMM console, which in turn should trigger the use of this URL as the approvalUrlInfo.approvalUrl property in a Products.approve call to approve the product. This URL can only be used to display permissions for up to 1 day. + /// Updates a collection. /// /// # Arguments /// + /// * `request` - No description provided. /// * `enterpriseId` - The ID of the enterprise. - /// * `productId` - The ID of the product. - pub fn generate_approval_url(&self, enterprise_id: &str, product_id: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { - ProductGenerateApprovalUrlCall { + /// * `collectionId` - The ID of the collection. + pub fn update(&self, request: Collection, enterprise_id: &str, collection_id: &str) -> CollectionUpdateCall<'a, C, A> { + CollectionUpdateCall { hub: self.hub, + _request: request, _enterprise_id: enterprise_id.to_string(), - _product_id: product_id.to_string(), - _language_code: Default::default(), + _collection_id: collection_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2845,7 +3957,7 @@ impl<'a, C, A> ProductMethods<'a, C, A> { -/// A builder providing access to all methods supported on *grouplicense* resources. +/// A builder providing access to all methods supported on *serviceaccountkey* resources. /// It is not used directly, but through the `AndroidEnterprise` hub. /// /// # Example @@ -2868,34 +3980,32 @@ impl<'a, C, A> ProductMethods<'a, C, A> { /// ::default(), None); /// let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` and `list(...)` +/// // like `delete(...)`, `insert(...)` and `list(...)` /// // to build up your call. -/// let rb = hub.grouplicenses(); +/// let rb = hub.serviceaccountkeys(); /// # } /// ``` -pub struct GrouplicenseMethods<'a, C, A> +pub struct ServiceaccountkeyMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, } -impl<'a, C, A> MethodsBuilder for GrouplicenseMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for ServiceaccountkeyMethods<'a, C, A> {} -impl<'a, C, A> GrouplicenseMethods<'a, C, A> { +impl<'a, C, A> ServiceaccountkeyMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves details of an enterprise's group license for a product. + /// Lists all active credentials for the service account associated with this enterprise. Only the ID and key type are returned. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - /// * `groupLicenseId` - The ID of the product the group license is for, e.g. "app:com.google.android.gm". - pub fn get(&self, enterprise_id: &str, group_license_id: &str) -> GrouplicenseGetCall<'a, C, A> { - GrouplicenseGetCall { + pub fn list(&self, enterprise_id: &str) -> ServiceaccountkeyListCall<'a, C, A> { + ServiceaccountkeyListCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), - _group_license_id: group_license_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2904,15 +4014,38 @@ impl<'a, C, A> GrouplicenseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves IDs of all products for which the enterprise has a group license. + /// Generates new credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. + /// + /// Only the type of the key should be populated in the resource to be inserted. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `enterpriseId` - The ID of the enterprise. + pub fn insert(&self, request: ServiceAccountKey, enterprise_id: &str) -> ServiceaccountkeyInsertCall<'a, C, A> { + ServiceaccountkeyInsertCall { + hub: self.hub, + _request: request, + _enterprise_id: enterprise_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Removes and invalidates the specified credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. /// /// # Arguments /// /// * `enterpriseId` - The ID of the enterprise. - pub fn list(&self, enterprise_id: &str) -> GrouplicenseListCall<'a, C, A> { - GrouplicenseListCall { + /// * `keyId` - The ID of the key. + pub fn delete(&self, enterprise_id: &str, key_id: &str) -> ServiceaccountkeyDeleteCall<'a, C, A> { + ServiceaccountkeyDeleteCall { hub: self.hub, _enterprise_id: enterprise_id.to_string(), + _key_id: key_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2987,9 +4120,9 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { // CallBuilders ### // ################# -/// Retrieves the details of all pages in the store. +/// Deletes a store page. /// -/// A builder for the *list* method supported by a *storelayoutpage* resource. +/// A builder for the *delete* method supported by a *storelayoutpage* resource. /// It is not used directly, but through a `StorelayoutpageMethods` instance. /// /// # Example @@ -3013,246 +4146,11 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.storelayoutpages().list("enterpriseId") +/// let result = hub.storelayoutpages().delete("enterpriseId", "pageId") /// .doit(); /// # } /// ``` -pub struct StorelayoutpageListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for StorelayoutpageListCall<'a, C, A> {} - -impl<'a, C, A> StorelayoutpageListCall<'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, StoreLayoutPagesListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout/pages".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutpageListCall<'a, C, A> { - self._enterprise_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) -> StorelayoutpageListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> StorelayoutpageListCall<'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) -> StorelayoutpageListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves details of a store page. -/// -/// A builder for the *get* method supported by a *storelayoutpage* resource. -/// It is not used directly, but through a `StorelayoutpageMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.storelayoutpages().get("enterpriseId", "pageId") -/// .doit(); -/// # } -/// ``` -pub struct StorelayoutpageGetCall<'a, C, A> +pub struct StorelayoutpageDeleteCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, @@ -3263,13 +4161,13 @@ pub struct StorelayoutpageGetCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for StorelayoutpageGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for StorelayoutpageDeleteCall<'a, C, A> {} -impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> StorelayoutpageDeleteCall<'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, StorePage)> { + pub fn doit(mut self) -> Result { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3277,12 +4175,12 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); params.push(("pageId", self._page_id.to_string())); - for &field in ["alt", "enterpriseId", "pageId"].iter() { + for &field in ["enterpriseId", "pageId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3292,7 +4190,6 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut StorelayoutpageGetCall<'a, C, A> where C: BorrowMut StorelayoutpageGetCall<'a, C, A> where C: BorrowMut { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { + sleep(d); + continue; + } + 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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutpageDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the page. + /// + /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutpageDeleteCall<'a, C, A> { + self._page_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) -> StorelayoutpageDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> StorelayoutpageDeleteCall<'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) -> StorelayoutpageDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the content of a store page. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *storelayoutpage* resource. +/// It is not used directly, but through a `StorelayoutpageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::StorePage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = StorePage::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.storelayoutpages().patch(req, "enterpriseId", "pageId") +/// .doit(); +/// # } +/// ``` +pub struct StorelayoutpagePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: StorePage, + _enterprise_id: String, + _page_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for StorelayoutpagePatchCall<'a, C, A> {} + +impl<'a, C, A> StorelayoutpagePatchCall<'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, StorePage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("pageId", self._page_id.to_string())); + for &field in ["alt", "enterpriseId", "pageId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout/pages/{pageId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{pageId}", "pageId")].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 ["pageId", "enterpriseId"].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) { @@ -3397,13 +4553,22 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> { + self._request = new_value; + self + } /// The ID of the enterprise. /// /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutpageGetCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> StorelayoutpagePatchCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -3413,7 +4578,7 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut StorelayoutpageGetCall<'a, C, A> { + pub fn page_id(mut self, new_value: &str) -> StorelayoutpagePatchCall<'a, C, A> { self._page_id = new_value.to_string(); self } @@ -3423,7 +4588,7 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut StorelayoutpageGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> StorelayoutpagePatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -3444,7 +4609,7 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> StorelayoutpageGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> StorelayoutpagePatchCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -3461,7 +4626,7 @@ impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> StorelayoutpageGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> StorelayoutpagePatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4013,9 +5178,9 @@ impl<'a, C, A> StorelayoutpageUpdateCall<'a, C, A> where C: BorrowMut StorelayoutpageUpdateCall<'a, C, A> where C: BorrowMut StorelayoutpageUpdateCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = AndroidEnterprise::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 = StorePage::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.storelayoutpages().patch(req, "enterpriseId", "pageId") +/// let result = hub.storelayoutpages().get("enterpriseId", "pageId") /// .doit(); /// # } /// ``` -pub struct StorelayoutpagePatchCall<'a, C, A> +pub struct StorelayoutpageGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, - _request: StorePage, _enterprise_id: String, _page_id: String, _delegate: Option<&'a mut Delegate>, @@ -4061,9 +5219,9 @@ pub struct StorelayoutpagePatchCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for StorelayoutpagePatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for StorelayoutpageGetCall<'a, C, A> {} -impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> StorelayoutpageGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -4075,9 +5233,9 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); params.push(("pageId", self._page_id.to_string())); for &field in ["alt", "enterpriseId", "pageId"].iter() { @@ -4124,17 +5282,6 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> { - self._request = new_value; - self - } /// The ID of the enterprise. /// /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutpagePatchCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> StorelayoutpageGetCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -4235,7 +5369,7 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> { + pub fn page_id(mut self, new_value: &str) -> StorelayoutpageGetCall<'a, C, A> { self._page_id = new_value.to_string(); self } @@ -4245,7 +5379,7 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> StorelayoutpageGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4266,7 +5400,7 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> StorelayoutpagePatchCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> StorelayoutpageGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4283,7 +5417,7 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> StorelayoutpagePatchCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> StorelayoutpageGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4291,9 +5425,9 @@ impl<'a, C, A> StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut StorelayoutpagePatchCall<'a, C, A> where C: BorrowMut +pub struct StorelayoutpageListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, _enterprise_id: String, - _page_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for StorelayoutpageDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for StorelayoutpageListCall<'a, C, A> {} -impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> StorelayoutpageListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, StoreLayoutPagesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4346,12 +5479,11 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.delete", - http_method: hyper::method::Method::Delete }); + dlg.begin(MethodInfo { id: "androidenterprise.storelayoutpages.list", + http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("pageId", self._page_id.to_string())); - for &field in ["enterpriseId", "pageId"].iter() { + for &field in ["alt", "enterpriseId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4361,13 +5493,14 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -4378,8 +5511,8 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(2); - for param_name in ["pageId", "enterpriseId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["enterpriseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -4412,7 +5545,7 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -4461,27 +5604,17 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut StorelayoutpageDeleteCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> StorelayoutpageListCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } - /// The ID of the page. - /// - /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutpageDeleteCall<'a, C, A> { - self._page_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) -> StorelayoutpageDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> StorelayoutpageListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4502,7 +5635,7 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> StorelayoutpageDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> StorelayoutpageListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4519,7 +5652,7 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> StorelayoutpageDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> StorelayoutpageListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4527,9 +5660,9 @@ impl<'a, C, A> StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut StorelayoutpageDeleteCall<'a, C, A> where C: BorrowMut +pub struct CollectionviewerGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, @@ -4569,13 +5702,13 @@ pub struct CollectionviewerDeleteCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CollectionviewerDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CollectionviewerGetCall<'a, C, A> {} -impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CollectionviewerGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, User)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4583,13 +5716,13 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.collectionviewers.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.collectionviewers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); params.push(("collectionId", self._collection_id.to_string())); params.push(("userId", self._user_id.to_string())); - for &field in ["enterpriseId", "collectionId", "userId"].iter() { + for &field in ["alt", "enterpriseId", "collectionId", "userId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4599,6 +5732,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -4699,7 +5843,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -4709,7 +5853,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> { + pub fn collection_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { self._collection_id = new_value.to_string(); self } @@ -4719,7 +5863,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { self._user_id = new_value.to_string(); self } @@ -4729,7 +5873,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CollectionviewerGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4750,7 +5894,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> CollectionviewerDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CollectionviewerGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4767,7 +5911,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> CollectionviewerDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CollectionviewerGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -5065,265 +6209,6 @@ impl<'a, C, A> CollectionviewerPatchCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = AndroidEnterprise::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.collectionviewers().get("enterpriseId", "collectionId", "userId") -/// .doit(); -/// # } -/// ``` -pub struct CollectionviewerGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _collection_id: String, - _user_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for CollectionviewerGetCall<'a, C, A> {} - -impl<'a, C, A> CollectionviewerGetCall<'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, User)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.collectionviewers.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("collectionId", self._collection_id.to_string())); - params.push(("userId", self._user_id.to_string())); - for &field in ["alt", "enterpriseId", "collectionId", "userId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}/users/{userId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId"), ("{userId}", "userId")].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 ["userId", "collectionId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the collection. - /// - /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { - self._collection_id = new_value.to_string(); - self - } - /// The ID of the user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> CollectionviewerGetCall<'a, C, A> { - self._user_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) -> CollectionviewerGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> CollectionviewerGetCall<'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) -> CollectionviewerGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Retrieves the IDs of the users who have been specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only these users will see the collection. /// /// A builder for the *list* method supported by a *collectionviewer* resource. @@ -5571,6 +6456,254 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.collectionviewers().delete("enterpriseId", "collectionId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct CollectionviewerDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _collection_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CollectionviewerDeleteCall<'a, C, A> {} + +impl<'a, C, A> CollectionviewerDeleteCall<'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: "androidenterprise.collectionviewers.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("collectionId", self._collection_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["enterpriseId", "collectionId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}/users/{userId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId"), ("{userId}", "userId")].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 ["userId", "collectionId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionviewerDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the collection. + /// + /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionviewerDeleteCall<'a, C, A> { + self._collection_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> CollectionviewerDeleteCall<'a, C, A> { + self._user_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) -> CollectionviewerDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CollectionviewerDeleteCall<'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) -> CollectionviewerDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Adds the user to the list of those specifically allowed to see the collection. If the collection's visibility is set to viewersOnly then only such users will see the collection. /// /// A builder for the *update* method supported by a *collectionviewer* resource. @@ -6097,9 +7230,11 @@ impl<'a, C, A> UserRevokeTokenCall<'a, C, A> where C: BorrowMut, } -/// Retrieves a user's details. +/// Updates the details of an EMM-managed user. +/// +/// Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value. /// -/// A builder for the *get* method supported by a *user* resource. +/// A builder for the *update* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -6110,6 +7245,7 @@ impl<'a, C, A> UserRevokeTokenCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::User; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -6120,17 +7256,23 @@ impl<'a, C, A> UserRevokeTokenCall<'a, C, A> where C: BorrowMut, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = AndroidEnterprise::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 = User::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.users().get("enterpriseId", "userId") +/// let result = hub.users().update(req, "enterpriseId", "userId") /// .doit(); /// # } /// ``` -pub struct UserGetCall<'a, C, A> +pub struct UserUpdateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, + _request: User, _enterprise_id: String, _user_id: String, _delegate: Option<&'a mut Delegate>, @@ -6138,9 +7280,9 @@ pub struct UserGetCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserUpdateCall<'a, C, A> {} -impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -6152,9 +7294,9 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.users.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.users.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); params.push(("userId", self._user_id.to_string())); for &field in ["alt", "enterpriseId", "userId"].iter() { @@ -6201,6 +7343,17 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth 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 { @@ -6217,11 +7370,15 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth } }; 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Put, &url) .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.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() @@ -6272,13 +7429,22 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth } + /// + /// 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: User) -> UserUpdateCall<'a, C, A> { + self._request = new_value; + self + } /// The ID of the enterprise. /// /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserGetCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> UserUpdateCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -6288,7 +7454,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserGetCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserUpdateCall<'a, C, A> { self._user_id = new_value.to_string(); self } @@ -6298,7 +7464,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserUpdateCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -6319,7 +7485,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// * *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) -> UserGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserUpdateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -6336,7 +7502,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// 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) -> UserGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserUpdateCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -6344,9 +7510,11 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth } -/// Looks up a user by their primary email address. +/// Updates the details of an EMM-managed user. +/// +/// Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value. This method supports patch semantics. /// -/// A builder for the *list* method supported by a *user* resource. +/// A builder for the *patch* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -6357,6 +7525,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::User; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -6367,266 +7536,23 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = AndroidEnterprise::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 = User::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.users().list("enterpriseId", "email") +/// let result = hub.users().patch(req, "enterpriseId", "userId") /// .doit(); /// # } /// ``` -pub struct UserListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _email: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UserListCall<'a, C, A> {} - -impl<'a, C, A> UserListCall<'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, UsersListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.users.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("email", self._email.to_string())); - for &field in ["alt", "enterpriseId", "email"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserListCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The exact primary email address of the user to look up. - /// - /// Sets the *email* 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 email(mut self, new_value: &str) -> UserListCall<'a, C, A> { - self._email = 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) -> UserListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> UserListCall<'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) -> UserListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Generates a token (activation code) to allow this user to configure their work account in the Android Setup Wizard. Revokes any previously generated token. -/// -/// This call only works with Google managed accounts. -/// -/// A builder for the *generateToken* method supported by a *user* resource. -/// It is not used directly, but through a `UserMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.users().generate_token("enterpriseId", "userId") -/// .doit(); -/// # } -/// ``` -pub struct UserGenerateTokenCall<'a, C, A> +pub struct UserPatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, + _request: User, _enterprise_id: String, _user_id: String, _delegate: Option<&'a mut Delegate>, @@ -6634,13 +7560,13 @@ pub struct UserGenerateTokenCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserGenerateTokenCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserPatchCall<'a, C, A> {} -impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserPatchCall<'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, UserToken)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, User)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -6648,9 +7574,9 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.users.generateToken", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.users.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); params.push(("userId", self._user_id.to_string())); for &field in ["alt", "enterpriseId", "userId"].iter() { @@ -6665,7 +7591,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/token".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -6697,6 +7623,17 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut 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 { @@ -6713,11 +7650,15 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut } }; 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, &url) .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.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() @@ -6768,13 +7709,22 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut } + /// + /// 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: User) -> UserPatchCall<'a, C, A> { + self._request = new_value; + self + } /// The ID of the enterprise. /// /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserGenerateTokenCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> UserPatchCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -6784,7 +7734,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserGenerateTokenCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserPatchCall<'a, C, A> { self._user_id = new_value.to_string(); self } @@ -6794,7 +7744,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserGenerateTokenCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserPatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -6815,7 +7765,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// * *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) -> UserGenerateTokenCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserPatchCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -6832,7 +7782,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// 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) -> UserGenerateTokenCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserPatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -7365,6 +8315,1502 @@ impl<'a, C, A> UserGetAvailableProductSetCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.users().get("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserGetCall<'a, C, A> {} + +impl<'a, C, A> UserGetCall<'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, User)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.users.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserGetCall<'a, C, A> { + self._user_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) -> UserGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserGetCall<'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) -> UserGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a new EMM-managed user. +/// +/// The Users resource passed in the body of the request should include an accountIdentifier and an accountType. +/// +/// A builder for the *insert* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::User; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = User::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.users().insert(req, "enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct UserInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: User, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserInsertCall<'a, C, A> {} + +impl<'a, C, A> UserInsertCall<'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, User)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.users.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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: User) -> UserInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserInsertCall<'a, C, A> { + self._enterprise_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) -> UserInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserInsertCall<'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) -> UserInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates a token (activation code) to allow this user to configure their work account in the Android Setup Wizard. Revokes any previously generated token. +/// +/// This call only works with Google managed accounts. +/// +/// A builder for the *generateToken* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.users().generate_token("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserGenerateTokenCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserGenerateTokenCall<'a, C, A> {} + +impl<'a, C, A> UserGenerateTokenCall<'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, UserToken)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.users.generateToken", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/token".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserGenerateTokenCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserGenerateTokenCall<'a, C, A> { + self._user_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) -> UserGenerateTokenCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserGenerateTokenCall<'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) -> UserGenerateTokenCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deleted an EMM-managed user. +/// +/// A builder for the *delete* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.users().delete("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserDeleteCall<'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: "androidenterprise.users.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserDeleteCall<'a, C, A> { + self._user_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) -> UserDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserDeleteCall<'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) -> UserDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Looks up a user by primary email address. This is only supported for Google-managed users. Lookup of the id is not needed for EMM-managed users because the id is already returned in the result of the Users.insert call. +/// +/// A builder for the *list* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.users().list("enterpriseId", "email") +/// .doit(); +/// # } +/// ``` +pub struct UserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserListCall<'a, C, A> {} + +impl<'a, C, A> UserListCall<'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, UsersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.users.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("email", self._email.to_string())); + for &field in ["alt", "enterpriseId", "email"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserListCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The exact primary email address of the user to look up. + /// + /// Sets the *email* 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 email(mut self, new_value: &str) -> UserListCall<'a, C, A> { + self._email = 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) -> UserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserListCall<'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) -> UserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates an authentication token which the device policy client can use to provision the given EMM-managed user account on a device. The generated token is single-use and expires after a few minutes. +/// +/// This call only works with EMM-managed accounts. +/// +/// A builder for the *generateAuthenticationToken* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.users().generate_authentication_token("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserGenerateAuthenticationTokenCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserGenerateAuthenticationTokenCall<'a, C, A> {} + +impl<'a, C, A> UserGenerateAuthenticationTokenCall<'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, AuthenticationToken)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.users.generateAuthenticationToken", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/authenticationToken".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> UserGenerateAuthenticationTokenCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserGenerateAuthenticationTokenCall<'a, C, A> { + self._user_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) -> UserGenerateAuthenticationTokenCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserGenerateAuthenticationTokenCall<'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) -> UserGenerateAuthenticationTokenCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Requests to install the latest version of an app to a device. If the app is already installed then it is updated to the latest version if necessary. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *install* resource. @@ -7667,6 +10113,266 @@ impl<'a, C, A> InstallPatchCall<'a, C, A> where C: BorrowMut, A: } +/// Requests to remove an app from a device. A call to get or list will still show the app as installed on the device until it is actually removed. +/// +/// A builder for the *delete* method supported by a *install* resource. +/// It is not used directly, but through a `InstallMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.installs().delete("enterpriseId", "userId", "deviceId", "installId") +/// .doit(); +/// # } +/// ``` +pub struct InstallDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _install_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InstallDeleteCall<'a, C, A> {} + +impl<'a, C, A> InstallDeleteCall<'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: "androidenterprise.installs.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + params.push(("installId", self._install_id.to_string())); + for &field in ["enterpriseId", "userId", "deviceId", "installId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/installs/{installId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{installId}", "installId")].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 ["installId", "deviceId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { + self._device_id = new_value.to_string(); + self + } + /// The ID of the product represented by the install, e.g. "app:com.google.android.gm". + /// + /// Sets the *install 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 install_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { + self._install_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) -> InstallDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InstallDeleteCall<'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) -> InstallDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves details of an installation of an app on a device. /// /// A builder for the *get* method supported by a *install* resource. @@ -8197,266 +10903,6 @@ impl<'a, C, A> InstallListCall<'a, C, A> where C: BorrowMut, A: o } -/// Requests to remove an app from a device. A call to get or list will still show the app as installed on the device until it is actually removed. -/// -/// A builder for the *delete* method supported by a *install* resource. -/// It is not used directly, but through a `InstallMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.installs().delete("enterpriseId", "userId", "deviceId", "installId") -/// .doit(); -/// # } -/// ``` -pub struct InstallDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _user_id: String, - _device_id: String, - _install_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InstallDeleteCall<'a, C, A> {} - -impl<'a, C, A> InstallDeleteCall<'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: "androidenterprise.installs.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("userId", self._user_id.to_string())); - params.push(("deviceId", self._device_id.to_string())); - params.push(("installId", self._install_id.to_string())); - for &field in ["enterpriseId", "userId", "deviceId", "installId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/installs/{installId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{installId}", "installId")].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 ["installId", "deviceId", "userId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { - self._user_id = new_value.to_string(); - self - } - /// The Android ID of the device. - /// - /// Sets the *device 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 device_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { - self._device_id = new_value.to_string(); - self - } - /// The ID of the product represented by the install, e.g. "app:com.google.android.gm". - /// - /// Sets the *install 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 install_id(mut self, new_value: &str) -> InstallDeleteCall<'a, C, A> { - self._install_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) -> InstallDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> InstallDeleteCall<'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) -> InstallDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Requests to install the latest version of an app to a device. If the app is already installed then it is updated to the latest version if necessary. /// /// A builder for the *update* method supported by a *install* resource. @@ -8759,7 +11205,1883 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: } -/// Sets whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. +/// Retrieves details of an enterprise's group license for a product. +/// +/// A builder for the *get* method supported by a *grouplicense* resource. +/// It is not used directly, but through a `GrouplicenseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.grouplicenses().get("enterpriseId", "groupLicenseId") +/// .doit(); +/// # } +/// ``` +pub struct GrouplicenseGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _group_license_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for GrouplicenseGetCall<'a, C, A> {} + +impl<'a, C, A> GrouplicenseGetCall<'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, GroupLicense)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.grouplicenses.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("groupLicenseId", self._group_license_id.to_string())); + for &field in ["alt", "enterpriseId", "groupLicenseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/groupLicenses/{groupLicenseId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{groupLicenseId}", "groupLicenseId")].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 ["groupLicenseId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> GrouplicenseGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the product the group license is for, e.g. "app:com.google.android.gm". + /// + /// Sets the *group license 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 group_license_id(mut self, new_value: &str) -> GrouplicenseGetCall<'a, C, A> { + self._group_license_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) -> GrouplicenseGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> GrouplicenseGetCall<'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) -> GrouplicenseGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves IDs of all products for which the enterprise has a group license. +/// +/// A builder for the *list* method supported by a *grouplicense* resource. +/// It is not used directly, but through a `GrouplicenseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.grouplicenses().list("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct GrouplicenseListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for GrouplicenseListCall<'a, C, A> {} + +impl<'a, C, A> GrouplicenseListCall<'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, GroupLicensesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.grouplicenses.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/groupLicenses".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> GrouplicenseListCall<'a, C, A> { + self._enterprise_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) -> GrouplicenseListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> GrouplicenseListCall<'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) -> GrouplicenseListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Adds or updates a per-device managed configuration for an app for the specified device. +/// +/// A builder for the *update* method supported by a *managedconfigurationsfordevice* resource. +/// It is not used directly, but through a `ManagedconfigurationsfordeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ManagedConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = ManagedConfiguration::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.managedconfigurationsfordevice().update(req, "enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordeviceUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: ManagedConfiguration, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _managed_configuration_for_device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsfordeviceUpdateCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordeviceUpdateCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsfordevice.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + params.push(("managedConfigurationForDeviceId", self._managed_configuration_for_device_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/managedConfigurationsForDevice/{managedConfigurationForDeviceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{managedConfigurationForDeviceId}", "managedConfigurationForDeviceId")].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 ["managedConfigurationForDeviceId", "deviceId", "userId", "enterpriseId"].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: ManagedConfiguration) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._device_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for device 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 managed_configuration_for_device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._managed_configuration_for_device_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) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsfordeviceUpdateCall<'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) -> ManagedconfigurationsfordeviceUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Adds or updates a per-device managed configuration for an app for the specified device. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *managedconfigurationsfordevice* resource. +/// It is not used directly, but through a `ManagedconfigurationsfordeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ManagedConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = ManagedConfiguration::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.managedconfigurationsfordevice().patch(req, "enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordevicePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: ManagedConfiguration, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _managed_configuration_for_device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsfordevicePatchCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordevicePatchCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsfordevice.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + params.push(("managedConfigurationForDeviceId", self._managed_configuration_for_device_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/managedConfigurationsForDevice/{managedConfigurationForDeviceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{managedConfigurationForDeviceId}", "managedConfigurationForDeviceId")].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 ["managedConfigurationForDeviceId", "deviceId", "userId", "enterpriseId"].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: ManagedConfiguration) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._device_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for device 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 managed_configuration_for_device_id(mut self, new_value: &str) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._managed_configuration_for_device_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) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsfordevicePatchCall<'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) -> ManagedconfigurationsfordevicePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all the per-device managed configurations for the specified device. Only the ID is set. +/// +/// A builder for the *list* method supported by a *managedconfigurationsfordevice* resource. +/// It is not used directly, but through a `ManagedconfigurationsfordeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsfordevice().list("enterpriseId", "userId", "deviceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordeviceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsfordeviceListCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordeviceListCall<'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, ManagedConfigurationsForDeviceListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsfordevice.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "deviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/managedConfigurationsForDevice".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId")].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 ["deviceId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceListCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceListCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceListCall<'a, C, A> { + self._device_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) -> ManagedconfigurationsfordeviceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsfordeviceListCall<'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) -> ManagedconfigurationsfordeviceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Removes a per-device managed configuration for an app for the specified device. +/// +/// A builder for the *delete* method supported by a *managedconfigurationsfordevice* resource. +/// It is not used directly, but through a `ManagedconfigurationsfordeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsfordevice().delete("enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordeviceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _managed_configuration_for_device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsfordeviceDeleteCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordeviceDeleteCall<'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: "androidenterprise.managedconfigurationsfordevice.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + params.push(("managedConfigurationForDeviceId", self._managed_configuration_for_device_id.to_string())); + for &field in ["enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/managedConfigurationsForDevice/{managedConfigurationForDeviceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{managedConfigurationForDeviceId}", "managedConfigurationForDeviceId")].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 ["managedConfigurationForDeviceId", "deviceId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + self._device_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for device 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 managed_configuration_for_device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + self._managed_configuration_for_device_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) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsfordeviceDeleteCall<'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) -> ManagedconfigurationsfordeviceDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves details of a per-device managed configuration. +/// +/// A builder for the *get* method supported by a *managedconfigurationsfordevice* resource. +/// It is not used directly, but through a `ManagedconfigurationsfordeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsfordevice().get("enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsfordeviceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _managed_configuration_for_device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsfordeviceGetCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsfordeviceGetCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsfordevice.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + params.push(("managedConfigurationForDeviceId", self._managed_configuration_for_device_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "deviceId", "managedConfigurationForDeviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}/managedConfigurationsForDevice/{managedConfigurationForDeviceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId"), ("{managedConfigurationForDeviceId}", "managedConfigurationForDeviceId")].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 ["managedConfigurationForDeviceId", "deviceId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The Android ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + self._device_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for device 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 managed_configuration_for_device_id(mut self, new_value: &str) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + self._managed_configuration_for_device_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) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsfordeviceGetCall<'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) -> ManagedconfigurationsfordeviceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Sets whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users. /// /// A builder for the *setState* method supported by a *device* resource. /// It is not used directly, but through a `DeviceMethods` instance. @@ -9049,7 +13371,266 @@ impl<'a, C, A> DeviceSetStateCall<'a, C, A> where C: BorrowMut, A } -/// Retrieves whether a device is enabled or disabled for access by the user to Google services. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. +/// Retrieves the details of a device. +/// +/// A builder for the *get* method supported by a *device* resource. +/// It is not used directly, but through a `DeviceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.devices().get("enterpriseId", "userId", "deviceId") +/// .doit(); +/// # } +/// ``` +pub struct DeviceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _device_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DeviceGetCall<'a, C, A> {} + +impl<'a, C, A> DeviceGetCall<'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, Device)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.devices.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("deviceId", self._device_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "deviceId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId")].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 ["deviceId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the device. + /// + /// Sets the *device 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 device_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { + self._device_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) -> DeviceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DeviceGetCall<'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) -> DeviceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves whether a device's access to Google services is enabled or disabled. The device state takes effect only if enforcing EMM policies on Android devices is enabled in the Google Admin Console. Otherwise, the device state is ignored and all devices are allowed access to Google services. This is only supported for Google-managed users. /// /// A builder for the *getState* method supported by a *device* resource. /// It is not used directly, but through a `DeviceMethods` instance. @@ -9555,489 +14136,6 @@ impl<'a, C, A> DeviceListCall<'a, C, A> where C: BorrowMut, A: oa } -/// Retrieves the details of a device. -/// -/// A builder for the *get* method supported by a *device* resource. -/// It is not used directly, but through a `DeviceMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.devices().get("enterpriseId", "userId", "deviceId") -/// .doit(); -/// # } -/// ``` -pub struct DeviceGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _user_id: String, - _device_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for DeviceGetCall<'a, C, A> {} - -impl<'a, C, A> DeviceGetCall<'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, Device)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.devices.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("userId", self._user_id.to_string())); - params.push(("deviceId", self._device_id.to_string())); - for &field in ["alt", "enterpriseId", "userId", "deviceId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/devices/{deviceId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{deviceId}", "deviceId")].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 ["deviceId", "userId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { - self._user_id = new_value.to_string(); - self - } - /// The ID of the device. - /// - /// Sets the *device 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 device_id(mut self, new_value: &str) -> DeviceGetCall<'a, C, A> { - self._device_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) -> DeviceGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> DeviceGetCall<'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) -> DeviceGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Unenrolls an enterprise from the calling EMM. -/// -/// A builder for the *unenroll* method supported by a *enterprise* resource. -/// It is not used directly, but through a `EnterpriseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.enterprises().unenroll("enterpriseId") -/// .doit(); -/// # } -/// ``` -pub struct EnterpriseUnenrollCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EnterpriseUnenrollCall<'a, C, A> {} - -impl<'a, C, A> EnterpriseUnenrollCall<'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: "androidenterprise.enterprises.unenroll", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["enterpriseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/unenroll".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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 = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseUnenrollCall<'a, C, A> { - self._enterprise_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) -> EnterpriseUnenrollCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EnterpriseUnenrollCall<'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) -> EnterpriseUnenrollCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Establishes the binding between the EMM and an enterprise. This is now deprecated; use enroll instead. /// /// A builder for the *insert* method supported by a *enterprise* resource. @@ -10283,926 +14381,7 @@ impl<'a, C, A> EnterpriseInsertCall<'a, C, A> where C: BorrowMut, } -/// Sends a test push notification to validate the EMM integration with the Google Cloud Pub/Sub service for this enterprise. -/// -/// A builder for the *sendTestPushNotification* method supported by a *enterprise* resource. -/// It is not used directly, but through a `EnterpriseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.enterprises().send_test_push_notification("enterpriseId") -/// .doit(); -/// # } -/// ``` -pub struct EnterpriseSendTestPushNotificationCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EnterpriseSendTestPushNotificationCall<'a, C, A> {} - -impl<'a, C, A> EnterpriseSendTestPushNotificationCall<'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, EnterprisesSendTestPushNotificationResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.enterprises.sendTestPushNotification", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/sendTestPushNotification".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { - self._enterprise_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) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EnterpriseSendTestPushNotificationCall<'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) -> EnterpriseSendTestPushNotificationCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Looks up an enterprise by domain name. -/// -/// A builder for the *list* method supported by a *enterprise* resource. -/// It is not used directly, but through a `EnterpriseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.enterprises().list("domain") -/// .doit(); -/// # } -/// ``` -pub struct EnterpriseListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _domain: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EnterpriseListCall<'a, C, A> {} - -impl<'a, C, A> EnterpriseListCall<'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, EnterprisesListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.enterprises.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("domain", self._domain.to_string())); - for &field in ["alt", "domain"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises".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)); - } - - - - 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 exact primary domain name of the enterprise to look up. - /// - /// Sets the *domain* 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 domain(mut self, new_value: &str) -> EnterpriseListCall<'a, C, A> { - self._domain = 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) -> EnterpriseListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EnterpriseListCall<'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) -> EnterpriseListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the name and domain of an enterprise. -/// -/// A builder for the *get* method supported by a *enterprise* resource. -/// It is not used directly, but through a `EnterpriseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.enterprises().get("enterpriseId") -/// .doit(); -/// # } -/// ``` -pub struct EnterpriseGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EnterpriseGetCall<'a, C, A> {} - -impl<'a, C, A> EnterpriseGetCall<'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, Enterprise)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.enterprises.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseGetCall<'a, C, A> { - self._enterprise_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) -> EnterpriseGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EnterpriseGetCall<'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) -> EnterpriseGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the store layout resource. -/// -/// A builder for the *getStoreLayout* method supported by a *enterprise* resource. -/// It is not used directly, but through a `EnterpriseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.enterprises().get_store_layout("enterpriseId") -/// .doit(); -/// # } -/// ``` -pub struct EnterpriseGetStoreLayoutCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EnterpriseGetStoreLayoutCall<'a, C, A> {} - -impl<'a, C, A> EnterpriseGetStoreLayoutCall<'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, StoreLayout)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.enterprises.getStoreLayout", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseGetStoreLayoutCall<'a, C, A> { - self._enterprise_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) -> EnterpriseGetStoreLayoutCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EnterpriseGetStoreLayoutCall<'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) -> EnterpriseGetStoreLayoutCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets the store layout resource. +/// Sets the store layout for the enterprise. /// /// A builder for the *setStoreLayout* method supported by a *enterprise* resource. /// It is not used directly, but through a `EnterpriseMethods` instance. @@ -11468,6 +14647,224 @@ impl<'a, C, A> EnterpriseSetStoreLayoutCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().pull_notification_set() +/// .request_mode("sit") +/// .doit(); +/// # } +/// ``` +pub struct EnterprisePullNotificationSetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request_mode: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterprisePullNotificationSetCall<'a, C, A> {} + +impl<'a, C, A> EnterprisePullNotificationSetCall<'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, NotificationSet)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.pullNotificationSet", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._request_mode { + params.push(("requestMode", value.to_string())); + } + for &field in ["alt", "requestMode"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/pullNotificationSet".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)); + } + + + + 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) + } + } + } + } + + + /// The request mode for pulling notifications. If omitted, defaults to WAIT_FOR_NOTIFCATIONS. + /// If this is set to WAIT_FOR_NOTIFCATIONS, the request will eventually timeout, in which case it should be retried. + /// + /// Sets the *request mode* query property to the given value. + pub fn request_mode(mut self, new_value: &str) -> EnterprisePullNotificationSetCall<'a, C, A> { + self._request_mode = 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) -> EnterprisePullNotificationSetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterprisePullNotificationSetCall<'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) -> EnterprisePullNotificationSetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Enrolls an enterprise with the calling EMM. /// /// A builder for the *enroll* method supported by a *enterprise* resource. @@ -11979,6 +15376,1831 @@ impl<'a, C, A> EnterpriseSetAccountCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().list("domain") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _domain: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseListCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseListCall<'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, EnterprisesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("domain", self._domain.to_string())); + for &field in ["alt", "domain"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises".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)); + } + + + + 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 exact primary domain name of the enterprise to look up. + /// + /// Sets the *domain* 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 domain(mut self, new_value: &str) -> EnterpriseListCall<'a, C, A> { + self._domain = 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) -> EnterpriseListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseListCall<'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) -> EnterpriseListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns the store layout for the enterprise. If the store layout has not been set, or if the store layout has no homepageId set, returns a NOT_FOUND error. +/// +/// A builder for the *getStoreLayout* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().get_store_layout("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseGetStoreLayoutCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseGetStoreLayoutCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseGetStoreLayoutCall<'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, StoreLayout)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.getStoreLayout", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseGetStoreLayoutCall<'a, C, A> { + self._enterprise_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) -> EnterpriseGetStoreLayoutCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseGetStoreLayoutCall<'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) -> EnterpriseGetStoreLayoutCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Completes the signup flow, by specifying the Completion token and Enterprise token. This request must not be called multiple times for a given Enterprise Token. +/// +/// A builder for the *completeSignup* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().complete_signup() +/// .enterprise_token("ea") +/// .completion_token("gubergren") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseCompleteSignupCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_token: Option, + _completion_token: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseCompleteSignupCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseCompleteSignupCall<'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, Enterprise)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.completeSignup", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._enterprise_token { + params.push(("enterpriseToken", value.to_string())); + } + if let Some(value) = self._completion_token { + params.push(("completionToken", value.to_string())); + } + for &field in ["alt", "enterpriseToken", "completionToken"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/completeSignup".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)); + } + + + + 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) + } + } + } + } + + + /// The Enterprise token appended to the Callback URL. + /// + /// Sets the *enterprise token* query property to the given value. + pub fn enterprise_token(mut self, new_value: &str) -> EnterpriseCompleteSignupCall<'a, C, A> { + self._enterprise_token = Some(new_value.to_string()); + self + } + /// The Completion token initially returned by GenerateSignupUrl. + /// + /// Sets the *completion token* query property to the given value. + pub fn completion_token(mut self, new_value: &str) -> EnterpriseCompleteSignupCall<'a, C, A> { + self._completion_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) -> EnterpriseCompleteSignupCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseCompleteSignupCall<'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) -> EnterpriseCompleteSignupCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a service account and credentials. The service account can be bound to the enterprise by calling setAccount. The service account is unique to this enterprise and EMM, and will be deleted if the enterprise is unbound. The credentials contain private key data and are not stored server-side. +/// +/// This method can only be called after calling Enterprises.Enroll or Enterprises.CompleteSignup, and before Enterprises.SetAccount; at other times it will return an error. +/// +/// Subsequent calls after the first will generate a new, unique set of credentials, and invalidate the previously generated credentials. +/// +/// Once the service account is bound to the enterprise, it can be managed using the serviceAccountKeys resource. +/// +/// A builder for the *getServiceAccount* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().get_service_account("enterpriseId") +/// .key_type("eos") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseGetServiceAccountCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _key_type: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseGetServiceAccountCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseGetServiceAccountCall<'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, ServiceAccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.getServiceAccount", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + if let Some(value) = self._key_type { + params.push(("keyType", value.to_string())); + } + for &field in ["alt", "enterpriseId", "keyType"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/serviceAccount".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseGetServiceAccountCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The type of credential to return with the service account. Required. + /// + /// Sets the *key type* query property to the given value. + pub fn key_type(mut self, new_value: &str) -> EnterpriseGetServiceAccountCall<'a, C, A> { + self._key_type = 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) -> EnterpriseGetServiceAccountCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseGetServiceAccountCall<'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) -> EnterpriseGetServiceAccountCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Acknowledges notifications that were received from Enterprises.PullNotificationSet to prevent subsequent calls from returning the same notifications. +/// +/// A builder for the *acknowledgeNotificationSet* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().acknowledge_notification_set() +/// .notification_set_id("tempor") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseAcknowledgeNotificationSetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _notification_set_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseAcknowledgeNotificationSetCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseAcknowledgeNotificationSetCall<'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: "androidenterprise.enterprises.acknowledgeNotificationSet", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + if let Some(value) = self._notification_set_id { + params.push(("notificationSetId", value.to_string())); + } + for &field in ["notificationSetId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/acknowledgeNotificationSet".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)); + } + + + + 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 = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The notification set ID as returned by Enterprises.PullNotificationSet. This must be provided. + /// + /// Sets the *notification set id* query property to the given value. + pub fn notification_set_id(mut self, new_value: &str) -> EnterpriseAcknowledgeNotificationSetCall<'a, C, A> { + self._notification_set_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) -> EnterpriseAcknowledgeNotificationSetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseAcknowledgeNotificationSetCall<'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) -> EnterpriseAcknowledgeNotificationSetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Unenrolls an enterprise from the calling EMM. +/// +/// A builder for the *unenroll* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().unenroll("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseUnenrollCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseUnenrollCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseUnenrollCall<'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: "androidenterprise.enterprises.unenroll", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/unenroll".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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 = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseUnenrollCall<'a, C, A> { + self._enterprise_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) -> EnterpriseUnenrollCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseUnenrollCall<'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) -> EnterpriseUnenrollCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Sends a test push notification to validate the EMM integration with the Google Cloud Pub/Sub service for this enterprise. +/// +/// A builder for the *sendTestPushNotification* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().send_test_push_notification("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseSendTestPushNotificationCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseSendTestPushNotificationCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseSendTestPushNotificationCall<'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, EnterprisesSendTestPushNotificationResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.sendTestPushNotification", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/sendTestPushNotification".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { + self._enterprise_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) -> EnterpriseSendTestPushNotificationCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseSendTestPushNotificationCall<'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) -> EnterpriseSendTestPushNotificationCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the name and domain of an enterprise. +/// +/// A builder for the *get* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.enterprises().get("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct EnterpriseGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EnterpriseGetCall<'a, C, A> {} + +impl<'a, C, A> EnterpriseGetCall<'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, Enterprise)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EnterpriseGetCall<'a, C, A> { + self._enterprise_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) -> EnterpriseGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EnterpriseGetCall<'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) -> EnterpriseGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Deletes the binding between the EMM and enterprise. This is now deprecated; use this to unenroll customers that were previously enrolled with the 'insert' call, then enroll them again with the 'enroll' call. /// /// A builder for the *delete* method supported by a *enterprise* resource. @@ -12203,10 +17425,10 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, } -/// Deletes a cluster. +/// Generates a sign-up URL. /// -/// A builder for the *delete* method supported by a *storelayoutcluster* resource. -/// It is not used directly, but through a `StorelayoutclusterMethods` instance. +/// A builder for the *generateSignupUrl* method supported by a *enterprise* resource. +/// It is not used directly, but through a `EnterpriseMethods` instance. /// /// # Example /// @@ -12229,29 +17451,28 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.storelayoutclusters().delete("enterpriseId", "pageId", "clusterId") +/// let result = hub.enterprises().generate_signup_url() +/// .callback_url("dolores") /// .doit(); /// # } /// ``` -pub struct StorelayoutclusterDeleteCall<'a, C, A> +pub struct EnterpriseGenerateSignupUrlCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, - _enterprise_id: String, - _page_id: String, - _cluster_id: String, + _callback_url: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for StorelayoutclusterDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for EnterpriseGenerateSignupUrlCall<'a, C, A> {} -impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> EnterpriseGenerateSignupUrlCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, SignupInfo)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -12259,13 +17480,13 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutclusters.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("pageId", self._page_id.to_string())); - params.push(("clusterId", self._cluster_id.to_string())); - for &field in ["enterpriseId", "pageId", "clusterId"].iter() { + dlg.begin(MethodInfo { id: "androidenterprise.enterprises.generateSignupUrl", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._callback_url { + params.push(("callbackUrl", value.to_string())); + } + for &field in ["alt", "callbackUrl"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12275,33 +17496,13 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut = 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 ["clusterId", "pageId", "enterpriseId"].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('?'); @@ -12326,7 +17527,7 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -12369,34 +17580,12 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut StorelayoutclusterDeleteCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the page. - /// - /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { - self._page_id = new_value.to_string(); - self - } - /// The ID of the cluster. - /// - /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { - self._cluster_id = new_value.to_string(); + /// Sets the *callback url* query property to the given value. + pub fn callback_url(mut self, new_value: &str) -> EnterpriseGenerateSignupUrlCall<'a, C, A> { + self._callback_url = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -12405,7 +17594,7 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut StorelayoutclusterDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> EnterpriseGenerateSignupUrlCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -12426,7 +17615,7 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> StorelayoutclusterDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> EnterpriseGenerateSignupUrlCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -12443,7 +17632,254 @@ impl<'a, C, A> StorelayoutclusterDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> StorelayoutclusterDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> EnterpriseGenerateSignupUrlCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the details of all clusters on the specified page. +/// +/// A builder for the *list* method supported by a *storelayoutcluster* resource. +/// It is not used directly, but through a `StorelayoutclusterMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.storelayoutclusters().list("enterpriseId", "pageId") +/// .doit(); +/// # } +/// ``` +pub struct StorelayoutclusterListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _page_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for StorelayoutclusterListCall<'a, C, A> {} + +impl<'a, C, A> StorelayoutclusterListCall<'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, StoreLayoutClustersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.storelayoutclusters.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("pageId", self._page_id.to_string())); + for &field in ["alt", "enterpriseId", "pageId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout/pages/{pageId}/clusters".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{pageId}", "pageId")].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 ["pageId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutclusterListCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the page. + /// + /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutclusterListCall<'a, C, A> { + self._page_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) -> StorelayoutclusterListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> StorelayoutclusterListCall<'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) -> StorelayoutclusterListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -13031,253 +18467,6 @@ impl<'a, C, A> StorelayoutclusterUpdateCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = AndroidEnterprise::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.storelayoutclusters().list("enterpriseId", "pageId") -/// .doit(); -/// # } -/// ``` -pub struct StorelayoutclusterListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _page_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for StorelayoutclusterListCall<'a, C, A> {} - -impl<'a, C, A> StorelayoutclusterListCall<'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, StoreLayoutClustersListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.storelayoutclusters.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("pageId", self._page_id.to_string())); - for &field in ["alt", "enterpriseId", "pageId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout/pages/{pageId}/clusters".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{pageId}", "pageId")].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 ["pageId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutclusterListCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the page. - /// - /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutclusterListCall<'a, C, A> { - self._page_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) -> StorelayoutclusterListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> StorelayoutclusterListCall<'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) -> StorelayoutclusterListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Retrieves details of a cluster. /// /// A builder for the *get* method supported by a *storelayoutcluster* resource. @@ -13815,10 +19004,10 @@ impl<'a, C, A> StorelayoutclusterInsertCall<'a, C, A> where C: BorrowMut StorelayoutclusterInsertCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.storelayoutclusters().delete("enterpriseId", "pageId", "clusterId") +/// .doit(); +/// # } +/// ``` +pub struct StorelayoutclusterDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _page_id: String, + _cluster_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for StorelayoutclusterDeleteCall<'a, C, A> {} + +impl<'a, C, A> StorelayoutclusterDeleteCall<'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: "androidenterprise.storelayoutclusters.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("pageId", self._page_id.to_string())); + params.push(("clusterId", self._cluster_id.to_string())); + for &field in ["enterpriseId", "pageId", "clusterId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/storeLayout/pages/{pageId}/clusters/{clusterId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{pageId}", "pageId"), ("{clusterId}", "clusterId")].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 ["clusterId", "pageId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the page. + /// + /// Sets the *page 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 page_id(mut self, new_value: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { + self._page_id = new_value.to_string(); + self + } + /// The ID of the cluster. + /// + /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> StorelayoutclusterDeleteCall<'a, C, A> { + self._cluster_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) -> StorelayoutclusterDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> StorelayoutclusterDeleteCall<'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) -> StorelayoutclusterDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the Android app permissions required by this app. +/// +/// A builder for the *getPermissions* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.products().get_permissions("enterpriseId", "productId") +/// .doit(); +/// # } +/// ``` +pub struct ProductGetPermissionCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _product_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProductGetPermissionCall<'a, C, A> {} + +impl<'a, C, A> ProductGetPermissionCall<'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, ProductPermissions)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.products.getPermissions", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("productId", self._product_id.to_string())); + for &field in ["alt", "enterpriseId", "productId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/permissions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGetPermissionCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the product. + /// + /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGetPermissionCall<'a, C, A> { + self._product_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) -> ProductGetPermissionCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProductGetPermissionCall<'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) -> ProductGetPermissionCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Unapproves the specified product (and the relevant app permissions, if any) +/// +/// A builder for the *unapprove* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.products().unapprove("enterpriseId", "productId") +/// .doit(); +/// # } +/// ``` +pub struct ProductUnapproveCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _product_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProductUnapproveCall<'a, C, A> {} + +impl<'a, C, A> ProductUnapproveCall<'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: "androidenterprise.products.unapprove", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("productId", self._product_id.to_string())); + for &field in ["enterpriseId", "productId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/unapprove".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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 = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductUnapproveCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the product. + /// + /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductUnapproveCall<'a, C, A> { + self._product_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) -> ProductUnapproveCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProductUnapproveCall<'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) -> ProductUnapproveCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Approves the specified product and the relevant app permissions, if any. The maximum number of products that you can approve per enterprise customer is 1,000. +/// +/// To learn how to use Google Play for Work to design and create a store layout to display approved products to your users, see Store Layout Design. +/// +/// A builder for the *approve* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ProductsApproveRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -13842,33 +19764,34 @@ impl<'a, C, A> StorelayoutclusterInsertCall<'a, C, A> where C: BorrowMut +pub struct ProductApproveCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, - _request: Collection, + _request: ProductsApproveRequest, _enterprise_id: String, + _product_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CollectionInsertCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductApproveCall<'a, C, A> {} -impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductApproveCall<'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, Collection)> { + pub fn doit(mut self) -> Result { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -13876,11 +19799,12 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.insert", + dlg.begin(MethodInfo { id: "androidenterprise.products.approve", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { + params.push(("productId", self._product_id.to_string())); + for &field in ["enterpriseId", "productId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13890,14 +19814,13 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, params.push((&name, value.clone())); } - params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/approve".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].iter() { + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -13908,8 +19831,8 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, 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 ["enterpriseId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["productId", "enterpriseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -13990,17 +19913,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, 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)); - } - } - }; + let result_value = res; dlg.finished(true); return Ok(result_value) @@ -14015,7 +19928,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// /// 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: Collection) -> CollectionInsertCall<'a, C, A> { + pub fn request(mut self, new_value: ProductsApproveRequest) -> ProductApproveCall<'a, C, A> { self._request = new_value; self } @@ -14025,17 +19938,27 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn enterprise_id(mut self, new_value: &str) -> CollectionInsertCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> ProductApproveCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } + /// The ID of the product. + /// + /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductApproveCall<'a, C, A> { + self._product_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) -> CollectionInsertCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductApproveCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14056,7 +19979,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// * *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) -> CollectionInsertCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductApproveCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -14073,7 +19996,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// 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) -> CollectionInsertCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductApproveCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -14081,10 +20004,12 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, } -/// Updates a collection. This method supports patch semantics. +/// This method has been deprecated. To programmatically approve applications, you must use the iframe mechanism via the generateApprovalUrl and approve methods of the Products resource. For more information, see the Play EMM API usage requirements. +/// +/// The updatePermissions method (deprecated) updates the set of Android app permissions for this app that have been accepted by the enterprise. /// -/// A builder for the *patch* method supported by a *collection* resource. -/// It is not used directly, but through a `CollectionMethods` instance. +/// A builder for the *updatePermissions* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. /// /// # Example /// @@ -14094,7 +20019,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_androidenterprise1 as androidenterprise1; -/// use androidenterprise1::Collection; +/// use androidenterprise1::ProductPermissions; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -14108,34 +20033,34 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// // 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 = Collection::default(); +/// let mut req = ProductPermissions::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.collections().patch(req, "enterpriseId", "collectionId") +/// let result = hub.products().update_permissions(req, "enterpriseId", "productId") /// .doit(); /// # } /// ``` -pub struct CollectionPatchCall<'a, C, A> +pub struct ProductUpdatePermissionCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, - _request: Collection, + _request: ProductPermissions, _enterprise_id: String, - _collection_id: String, + _product_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CollectionPatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductUpdatePermissionCall<'a, C, A> {} -impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductUpdatePermissionCall<'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, Collection)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProductPermissions)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -14143,290 +20068,12 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("collectionId", self._collection_id.to_string())); - for &field in ["alt", "enterpriseId", "collectionId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].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 ["collectionId", "enterpriseId"].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: Collection) -> CollectionPatchCall<'a, C, A> { - self._request = new_value; - self - } - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionPatchCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the collection. - /// - /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionPatchCall<'a, C, A> { - self._collection_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) -> CollectionPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> CollectionPatchCall<'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) -> CollectionPatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a collection. -/// -/// A builder for the *update* method supported by a *collection* resource. -/// It is not used directly, but through a `CollectionMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// use androidenterprise1::Collection; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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 = Collection::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.collections().update(req, "enterpriseId", "collectionId") -/// .doit(); -/// # } -/// ``` -pub struct CollectionUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _request: Collection, - _enterprise_id: String, - _collection_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for CollectionUpdateCall<'a, C, A> {} - -impl<'a, C, A> CollectionUpdateCall<'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, Collection)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.update", + dlg.begin(MethodInfo { id: "androidenterprise.products.updatePermissions", http_method: hyper::method::Method::Put }); let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("collectionId", self._collection_id.to_string())); - for &field in ["alt", "enterpriseId", "collectionId"].iter() { + params.push(("productId", self._product_id.to_string())); + for &field in ["alt", "enterpriseId", "productId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14438,12 +20085,12 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/permissions".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].iter() { + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -14455,7 +20102,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["collectionId", "enterpriseId"].iter() { + for param_name in ["productId", "enterpriseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -14561,7 +20208,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// /// 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: Collection) -> CollectionUpdateCall<'a, C, A> { + pub fn request(mut self, new_value: ProductPermissions) -> ProductUpdatePermissionCall<'a, C, A> { self._request = new_value; self } @@ -14571,18 +20218,18 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn enterprise_id(mut self, new_value: &str) -> CollectionUpdateCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> ProductUpdatePermissionCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } - /// The ID of the collection. + /// The ID of the product. /// - /// Sets the *collection id* path property to the given value. + /// Sets the *product 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 collection_id(mut self, new_value: &str) -> CollectionUpdateCall<'a, C, A> { - self._collection_id = new_value.to_string(); + pub fn product_id(mut self, new_value: &str) -> ProductUpdatePermissionCall<'a, C, A> { + self._product_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -14591,7 +20238,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CollectionUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductUpdatePermissionCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14612,7 +20259,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// * *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) -> CollectionUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductUpdatePermissionCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -14629,7 +20276,7 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// 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) -> CollectionUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductUpdatePermissionCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -14637,10 +20284,10 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, } -/// Retrieves the IDs of all the collections for an enterprise. +/// Retrieves the schema that defines the configurable properties for this product. All products have a schema, but this schema may be empty if no managed configurations have been defined. This schema can be used to populate a UI that allows an administrator to configure the product. To apply a managed configuration based on the schema obtained using this API, see Managed Configurations through Play. /// -/// A builder for the *list* method supported by a *collection* resource. -/// It is not used directly, but through a `CollectionMethods` instance. +/// A builder for the *getAppRestrictionsSchema* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. /// /// # Example /// @@ -14663,27 +20310,30 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.collections().list("enterpriseId") +/// let result = hub.products().get_app_restrictions_schema("enterpriseId", "productId") +/// .language("invidunt") /// .doit(); /// # } /// ``` -pub struct CollectionListCall<'a, C, A> +pub struct ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, _enterprise_id: String, + _product_id: String, + _language: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CollectionListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductGetAppRestrictionsSchemaCall<'a, C, A> {} -impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'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, CollectionsListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, AppRestrictionsSchema)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -14691,11 +20341,15 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.list", + dlg.begin(MethodInfo { id: "androidenterprise.products.getAppRestrictionsSchema", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - for &field in ["alt", "enterpriseId"].iter() { + params.push(("productId", self._product_id.to_string())); + if let Some(value) = self._language { + params.push(("language", value.to_string())); + } + for &field in ["alt", "enterpriseId", "productId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14707,7 +20361,284 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/appRestrictionsSchema".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the product. + /// + /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { + self._product_id = new_value.to_string(); + self + } + /// The BCP47 tag for the user's preferred language (e.g. "en-US", "de"). + /// + /// Sets the *language* query property to the given value. + pub fn language(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { + self._language = 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) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProductGetAppRestrictionsSchemaCall<'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) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Finds approved products that match a query, or all approved products if there is no query. +/// +/// A builder for the *list* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.products().list("enterpriseId") +/// .token("Lorem") +/// .query("clita") +/// .max_results(64) +/// .language("eirmod") +/// .approved(false) +/// .doit(); +/// # } +/// ``` +pub struct ProductListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _token: Option, + _query: Option, + _max_results: Option, + _language: Option, + _approved: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProductListCall<'a, C, A> {} + +impl<'a, C, A> ProductListCall<'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, ProductsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.products.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + if let Some(value) = self._token { + params.push(("token", value.to_string())); + } + if let Some(value) = self._query { + params.push(("query", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._language { + params.push(("language", value.to_string())); + } + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + for &field in ["alt", "enterpriseId", "token", "query", "maxResults", "language", "approved"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -14816,17 +20747,52 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn enterprise_id(mut self, new_value: &str) -> CollectionListCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> ProductListCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } + /// A pagination token is contained in a request’s response when there are more products. The token can be used in a subsequent request to obtain more products, and so forth. This parameter cannot be used in the initial request. + /// + /// Sets the *token* query property to the given value. + pub fn token(mut self, new_value: &str) -> ProductListCall<'a, C, A> { + self._token = Some(new_value.to_string()); + self + } + /// The search query as typed in the Google Play Store search box. If omitted, all approved apps will be returned (using the pagination parameters), including apps that are not available in the store (e.g. unpublished apps). + /// + /// Sets the *query* query property to the given value. + pub fn query(mut self, new_value: &str) -> ProductListCall<'a, C, A> { + self._query = Some(new_value.to_string()); + self + } + /// Specifies the maximum number of products that can be returned per request. If not specified, uses a default value of 100, which is also the maximum retrievable within a single response. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> ProductListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// The BCP47 tag for the user's preferred language (e.g. "en-US", "de"). Results are returned in the language best matching the preferred language. + /// + /// Sets the *language* query property to the given value. + pub fn language(mut self, new_value: &str) -> ProductListCall<'a, C, A> { + self._language = Some(new_value.to_string()); + self + } + /// Specifies whether to search among all products (false) or among only products that have been approved (true). Only "true" is supported, and should be specified. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> ProductListCall<'a, C, A> { + self._approved = 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) -> CollectionListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14847,7 +20813,7 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A /// * *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) -> CollectionListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -14864,7 +20830,7 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A /// 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) -> CollectionListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -14872,10 +20838,10 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A } -/// Deletes a collection. +/// Retrieves details of a product for display to an enterprise admin. /// -/// A builder for the *delete* method supported by a *collection* resource. -/// It is not used directly, but through a `CollectionMethods` instance. +/// A builder for the *get* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. /// /// # Example /// @@ -14898,28 +20864,30 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.collections().delete("enterpriseId", "collectionId") +/// let result = hub.products().get("enterpriseId", "productId") +/// .language("sed") /// .doit(); /// # } /// ``` -pub struct CollectionDeleteCall<'a, C, A> +pub struct ProductGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, _enterprise_id: String, - _collection_id: String, + _product_id: String, + _language: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CollectionDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductGetCall<'a, C, A> {} -impl<'a, C, A> CollectionDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, Product)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -14927,248 +20895,15 @@ impl<'a, C, A> CollectionDeleteCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("collectionId", self._collection_id.to_string())); - for &field in ["enterpriseId", "collectionId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].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 ["collectionId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionDeleteCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the collection. - /// - /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionDeleteCall<'a, C, A> { - self._collection_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) -> CollectionDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> CollectionDeleteCall<'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) -> CollectionDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the details of a collection. -/// -/// A builder for the *get* method supported by a *collection* resource. -/// It is not used directly, but through a `CollectionMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.collections().get("enterpriseId", "collectionId") -/// .doit(); -/// # } -/// ``` -pub struct CollectionGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _collection_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for CollectionGetCall<'a, C, A> {} - -impl<'a, C, A> CollectionGetCall<'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, Collection)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.collections.get", + dlg.begin(MethodInfo { id: "androidenterprise.products.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("collectionId", self._collection_id.to_string())); - for &field in ["alt", "enterpriseId", "collectionId"].iter() { + params.push(("productId", self._product_id.to_string())); + if let Some(value) = self._language { + params.push(("language", value.to_string())); + } + for &field in ["alt", "enterpriseId", "productId", "language"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15180,12 +20915,12 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].iter() { + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -15197,7 +20932,7 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["collectionId", "enterpriseId"].iter() { + for param_name in ["productId", "enterpriseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -15289,18 +21024,25 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn enterprise_id(mut self, new_value: &str) -> CollectionGetCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } - /// The ID of the collection. + /// The ID of the product, e.g. "app:com.google.android.gm". /// - /// Sets the *collection id* path property to the given value. + /// Sets the *product 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 collection_id(mut self, new_value: &str) -> CollectionGetCall<'a, C, A> { - self._collection_id = new_value.to_string(); + pub fn product_id(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { + self._product_id = new_value.to_string(); + self + } + /// The BCP47 tag for the user's preferred language (e.g. "en-US", "de"). + /// + /// Sets the *language* query property to the given value. + pub fn language(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { + self._language = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -15309,7 +21051,7 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CollectionGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -15330,7 +21072,7 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: /// * *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) -> CollectionGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -15347,7 +21089,1602 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: /// 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) -> CollectionGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates a URL that can be rendered in an iframe to display the permissions (if any) of a product. An enterprise admin must view these permissions and accept them on behalf of their organization in order to approve that product. +/// +/// Admins should accept the displayed permissions by interacting with a separate UI element in the EMM console, which in turn should trigger the use of this URL as the approvalUrlInfo.approvalUrl property in a Products.approve call to approve the product. This URL can only be used to display permissions for up to 1 day. +/// +/// A builder for the *generateApprovalUrl* method supported by a *product* resource. +/// It is not used directly, but through a `ProductMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.products().generate_approval_url("enterpriseId", "productId") +/// .language_code("elitr") +/// .doit(); +/// # } +/// ``` +pub struct ProductGenerateApprovalUrlCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _product_id: String, + _language_code: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProductGenerateApprovalUrlCall<'a, C, A> {} + +impl<'a, C, A> ProductGenerateApprovalUrlCall<'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, ProductsGenerateApprovalUrlResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.products.generateApprovalUrl", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("productId", self._product_id.to_string())); + if let Some(value) = self._language_code { + params.push(("languageCode", value.to_string())); + } + for &field in ["alt", "enterpriseId", "productId", "languageCode"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/generateApprovalUrl".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the product. + /// + /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { + self._product_id = new_value.to_string(); + self + } + /// The BCP 47 language code used for permission names and descriptions in the returned iframe, for instance "en-US". + /// + /// Sets the *language code* query property to the given value. + pub fn language_code(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { + self._language_code = 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) -> ProductGenerateApprovalUrlCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProductGenerateApprovalUrlCall<'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) -> ProductGenerateApprovalUrlCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Adds or updates a per-user managed configuration for an app for the specified user. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *managedconfigurationsforuser* resource. +/// It is not used directly, but through a `ManagedconfigurationsforuserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ManagedConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = ManagedConfiguration::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.managedconfigurationsforuser().patch(req, "enterpriseId", "userId", "managedConfigurationForUserId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: ManagedConfiguration, + _enterprise_id: String, + _user_id: String, + _managed_configuration_for_user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsforuserPatchCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserPatchCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsforuser.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("managedConfigurationForUserId", self._managed_configuration_for_user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "managedConfigurationForUserId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/managedConfigurationsForUser/{managedConfigurationForUserId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{managedConfigurationForUserId}", "managedConfigurationForUserId")].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 ["managedConfigurationForUserId", "userId", "enterpriseId"].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: ManagedConfiguration) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for user 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 managed_configuration_for_user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + self._managed_configuration_for_user_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) -> ManagedconfigurationsforuserPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsforuserPatchCall<'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) -> ManagedconfigurationsforuserPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all the per-user managed configurations for the specified user. Only the ID is set. +/// +/// A builder for the *list* method supported by a *managedconfigurationsforuser* resource. +/// It is not used directly, but through a `ManagedconfigurationsforuserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsforuser().list("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsforuserListCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserListCall<'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, ManagedConfigurationsForUserListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsforuser.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/managedConfigurationsForUser".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsforuserListCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserListCall<'a, C, A> { + self._user_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) -> ManagedconfigurationsforuserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsforuserListCall<'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) -> ManagedconfigurationsforuserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Removes a per-user managed configuration for an app for the specified user. +/// +/// A builder for the *delete* method supported by a *managedconfigurationsforuser* resource. +/// It is not used directly, but through a `ManagedconfigurationsforuserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsforuser().delete("enterpriseId", "userId", "managedConfigurationForUserId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _managed_configuration_for_user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsforuserDeleteCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserDeleteCall<'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: "androidenterprise.managedconfigurationsforuser.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("managedConfigurationForUserId", self._managed_configuration_for_user_id.to_string())); + for &field in ["enterpriseId", "userId", "managedConfigurationForUserId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/managedConfigurationsForUser/{managedConfigurationForUserId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{managedConfigurationForUserId}", "managedConfigurationForUserId")].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 ["managedConfigurationForUserId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for user 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 managed_configuration_for_user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> { + self._managed_configuration_for_user_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) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsforuserDeleteCall<'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) -> ManagedconfigurationsforuserDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Adds or updates a per-user managed configuration for an app for the specified user. +/// +/// A builder for the *update* method supported by a *managedconfigurationsforuser* resource. +/// It is not used directly, but through a `ManagedconfigurationsforuserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ManagedConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = ManagedConfiguration::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.managedconfigurationsforuser().update(req, "enterpriseId", "userId", "managedConfigurationForUserId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: ManagedConfiguration, + _enterprise_id: String, + _user_id: String, + _managed_configuration_for_user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsforuserUpdateCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserUpdateCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsforuser.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("managedConfigurationForUserId", self._managed_configuration_for_user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "managedConfigurationForUserId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/managedConfigurationsForUser/{managedConfigurationForUserId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{managedConfigurationForUserId}", "managedConfigurationForUserId")].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 ["managedConfigurationForUserId", "userId", "enterpriseId"].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: ManagedConfiguration) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for user 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 managed_configuration_for_user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + self._managed_configuration_for_user_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) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsforuserUpdateCall<'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) -> ManagedconfigurationsforuserUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves details of a per-user managed configuration for an app for the specified user. +/// +/// A builder for the *get* method supported by a *managedconfigurationsforuser* resource. +/// It is not used directly, but through a `ManagedconfigurationsforuserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.managedconfigurationsforuser().get("enterpriseId", "userId", "managedConfigurationForUserId") +/// .doit(); +/// # } +/// ``` +pub struct ManagedconfigurationsforuserGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _managed_configuration_for_user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ManagedconfigurationsforuserGetCall<'a, C, A> {} + +impl<'a, C, A> ManagedconfigurationsforuserGetCall<'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, ManagedConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.managedconfigurationsforuser.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("managedConfigurationForUserId", self._managed_configuration_for_user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId", "managedConfigurationForUserId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/managedConfigurationsForUser/{managedConfigurationForUserId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{managedConfigurationForUserId}", "managedConfigurationForUserId")].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 ["managedConfigurationForUserId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ManagedconfigurationsforuserGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the managed configuration (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *managed configuration for user 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 managed_configuration_for_user_id(mut self, new_value: &str) -> ManagedconfigurationsforuserGetCall<'a, C, A> { + self._managed_configuration_for_user_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) -> ManagedconfigurationsforuserGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ManagedconfigurationsforuserGetCall<'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) -> ManagedconfigurationsforuserGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -15602,6 +22939,253 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidEnterprise::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.entitlements().list("enterpriseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct EntitlementListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EntitlementListCall<'a, C, A> {} + +impl<'a, C, A> EntitlementListCall<'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, EntitlementsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.entitlements.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "enterpriseId", "userId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/entitlements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EntitlementListCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> EntitlementListCall<'a, C, A> { + self._user_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) -> EntitlementListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EntitlementListCall<'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) -> EntitlementListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Adds or updates an entitlement to an app for a user. /// /// A builder for the *update* method supported by a *entitlement* resource. @@ -15635,7 +23219,7 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut EntitlementUpdateCall<'a, C, A> where C: BorrowMut } -/// List of all entitlements for the specified user. Only the ID is set. -/// -/// A builder for the *list* method supported by a *entitlement* resource. -/// It is not used directly, but through a `EntitlementMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.entitlements().list("enterpriseId", "userId") -/// .doit(); -/// # } -/// ``` -pub struct EntitlementListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _user_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EntitlementListCall<'a, C, A> {} - -impl<'a, C, A> EntitlementListCall<'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, EntitlementsListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.entitlements.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("userId", self._user_id.to_string())); - for &field in ["alt", "enterpriseId", "userId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/entitlements".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId")].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 ["userId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EntitlementListCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> EntitlementListCall<'a, C, A> { - self._user_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) -> EntitlementListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EntitlementListCall<'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) -> EntitlementListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Retrieves details of an entitlement. /// /// A builder for the *get* method supported by a *entitlement* resource. @@ -16410,6 +23747,254 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A } +/// Removes an entitlement to an app for a user and uninstalls it. +/// +/// A builder for the *delete* method supported by a *entitlement* resource. +/// It is not used directly, but through a `EntitlementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.entitlements().delete("enterpriseId", "userId", "entitlementId") +/// .doit(); +/// # } +/// ``` +pub struct EntitlementDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _user_id: String, + _entitlement_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EntitlementDeleteCall<'a, C, A> {} + +impl<'a, C, A> EntitlementDeleteCall<'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: "androidenterprise.entitlements.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("userId", self._user_id.to_string())); + params.push(("entitlementId", self._entitlement_id.to_string())); + for &field in ["enterpriseId", "userId", "entitlementId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/entitlements/{entitlementId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{entitlementId}", "entitlementId")].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 ["entitlementId", "userId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the entitlement (a product ID), e.g. "app:com.google.android.gm". + /// + /// Sets the *entitlement 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 entitlement_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { + self._entitlement_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) -> EntitlementDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EntitlementDeleteCall<'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) -> EntitlementDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Adds or updates an entitlement to an app for a user. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *entitlement* resource. @@ -16712,10 +24297,10 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, } -/// Removes an entitlement to an app for a user and uninstalls it. +/// Updates a collection. This method supports patch semantics. /// -/// A builder for the *delete* method supported by a *entitlement* resource. -/// It is not used directly, but through a `EntitlementMethods` instance. +/// A builder for the *patch* method supported by a *collection* resource. +/// It is not used directly, but through a `CollectionMethods` instance. /// /// # Example /// @@ -16725,502 +24310,7 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.entitlements().delete("enterpriseId", "userId", "entitlementId") -/// .doit(); -/// # } -/// ``` -pub struct EntitlementDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _user_id: String, - _entitlement_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for EntitlementDeleteCall<'a, C, A> {} - -impl<'a, C, A> EntitlementDeleteCall<'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: "androidenterprise.entitlements.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("userId", self._user_id.to_string())); - params.push(("entitlementId", self._entitlement_id.to_string())); - for &field in ["enterpriseId", "userId", "entitlementId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/users/{userId}/entitlements/{entitlementId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{userId}", "userId"), ("{entitlementId}", "entitlementId")].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 ["entitlementId", "userId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { - self._user_id = new_value.to_string(); - self - } - /// The ID of the entitlement (a product ID), e.g. "app:com.google.android.gm". - /// - /// Sets the *entitlement 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 entitlement_id(mut self, new_value: &str) -> EntitlementDeleteCall<'a, C, A> { - self._entitlement_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) -> EntitlementDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> EntitlementDeleteCall<'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) -> EntitlementDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the Android app permissions required by this app. -/// -/// A builder for the *getPermissions* method supported by a *product* resource. -/// It is not used directly, but through a `ProductMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.products().get_permissions("enterpriseId", "productId") -/// .doit(); -/// # } -/// ``` -pub struct ProductGetPermissionCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _product_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProductGetPermissionCall<'a, C, A> {} - -impl<'a, C, A> ProductGetPermissionCall<'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, ProductPermissions)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.products.getPermissions", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - for &field in ["alt", "enterpriseId", "productId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/permissions".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGetPermissionCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product. - /// - /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGetPermissionCall<'a, C, A> { - self._product_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) -> ProductGetPermissionCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProductGetPermissionCall<'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) -> ProductGetPermissionCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Approves the specified product (and the relevant app permissions, if any). -/// -/// A builder for the *approve* method supported by a *product* resource. -/// It is not used directly, but through a `ProductMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// use androidenterprise1::ProductsApproveRequest; +/// use androidenterprise1::Collection; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -17234,34 +24324,34 @@ impl<'a, C, A> ProductGetPermissionCall<'a, C, A> where C: BorrowMut +pub struct CollectionPatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, - _request: ProductsApproveRequest, + _request: Collection, _enterprise_id: String, - _product_id: String, + _collection_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProductApproveCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CollectionPatchCall<'a, C, A> {} -impl<'a, C, A> ProductApproveCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, Collection)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -17269,12 +24359,12 @@ impl<'a, C, A> ProductApproveCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.products.approve", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "androidenterprise.collections.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - for &field in ["enterpriseId", "productId"].iter() { + params.push(("collectionId", self._collection_id.to_string())); + for &field in ["alt", "enterpriseId", "collectionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17284,13 +24374,14 @@ impl<'a, C, A> ProductApproveCall<'a, C, A> where C: BorrowMut, A params.push((&name, value.clone())); } + params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/approve".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].iter() { + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -17302,7 +24393,7 @@ impl<'a, C, A> ProductApproveCall<'a, C, A> where C: BorrowMut, A } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["productId", "enterpriseId"].iter() { + for param_name in ["collectionId", "enterpriseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -17347,795 +24438,7 @@ impl<'a, C, A> ProductApproveCall<'a, C, A> where C: BorrowMut, A 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 = res; - - 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: ProductsApproveRequest) -> ProductApproveCall<'a, C, A> { - self._request = new_value; - self - } - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductApproveCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product. - /// - /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductApproveCall<'a, C, A> { - self._product_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) -> ProductApproveCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProductApproveCall<'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) -> ProductApproveCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the schema defining app restrictions configurable for this product. All products have a schema, but this may be empty if no app restrictions are defined. -/// -/// A builder for the *getAppRestrictionsSchema* method supported by a *product* resource. -/// It is not used directly, but through a `ProductMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.products().get_app_restrictions_schema("enterpriseId", "productId") -/// .language("est") -/// .doit(); -/// # } -/// ``` -pub struct ProductGetAppRestrictionsSchemaCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _product_id: String, - _language: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProductGetAppRestrictionsSchemaCall<'a, C, A> {} - -impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'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, AppRestrictionsSchema)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.products.getAppRestrictionsSchema", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - if let Some(value) = self._language { - params.push(("language", value.to_string())); - } - for &field in ["alt", "enterpriseId", "productId", "language"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/appRestrictionsSchema".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product. - /// - /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { - self._product_id = new_value.to_string(); - self - } - /// The BCP47 tag for the user's preferred language (e.g. "en-US", "de"). - /// - /// Sets the *language* query property to the given value. - pub fn language(mut self, new_value: &str) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { - self._language = 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) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProductGetAppRestrictionsSchemaCall<'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) -> ProductGetAppRestrictionsSchemaCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves details of a product for display to an enterprise admin. -/// -/// A builder for the *get* method supported by a *product* resource. -/// It is not used directly, but through a `ProductMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.products().get("enterpriseId", "productId") -/// .language("ut") -/// .doit(); -/// # } -/// ``` -pub struct ProductGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _product_id: String, - _language: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProductGetCall<'a, C, A> {} - -impl<'a, C, A> ProductGetCall<'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, Product)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.products.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - if let Some(value) = self._language { - params.push(("language", value.to_string())); - } - for &field in ["alt", "enterpriseId", "productId", "language"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product, e.g. "app:com.google.android.gm". - /// - /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { - self._product_id = new_value.to_string(); - self - } - /// The BCP47 tag for the user's preferred language (e.g. "en-US", "de"). - /// - /// Sets the *language* query property to the given value. - pub fn language(mut self, new_value: &str) -> ProductGetCall<'a, C, A> { - self._language = 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) -> ProductGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProductGetCall<'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) -> ProductGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// This method has been deprecated. To programmatically approve applications, you must use the iframe mechanism via the generateApprovalUrl and approve methods of the Products resource. For more information, see the Play EMM API usage requirements. -/// -/// The updatePermissions method (deprecated) updates the set of Android app permissions for this app that have been accepted by the enterprise. -/// -/// A builder for the *updatePermissions* method supported by a *product* resource. -/// It is not used directly, but through a `ProductMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// use androidenterprise1::ProductPermissions; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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 = ProductPermissions::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.products().update_permissions(req, "enterpriseId", "productId") -/// .doit(); -/// # } -/// ``` -pub struct ProductUpdatePermissionCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _request: ProductPermissions, - _enterprise_id: String, - _product_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProductUpdatePermissionCall<'a, C, A> {} - -impl<'a, C, A> ProductUpdatePermissionCall<'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, ProductPermissions)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.products.updatePermissions", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - for &field in ["alt", "enterpriseId", "productId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/permissions".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) + 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())) @@ -18196,7 +24499,7 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut ProductUpdatePermissionCall<'a, C, A> { + pub fn request(mut self, new_value: Collection) -> CollectionPatchCall<'a, C, A> { self._request = new_value; self } @@ -18206,18 +24509,18 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut ProductUpdatePermissionCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> CollectionPatchCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } - /// The ID of the product. + /// The ID of the collection. /// - /// Sets the *product id* path property to the given value. + /// Sets the *collection 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 product_id(mut self, new_value: &str) -> ProductUpdatePermissionCall<'a, C, A> { - self._product_id = new_value.to_string(); + pub fn collection_id(mut self, new_value: &str) -> CollectionPatchCall<'a, C, A> { + self._collection_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -18226,7 +24529,7 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut ProductUpdatePermissionCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CollectionPatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -18247,7 +24550,7 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProductUpdatePermissionCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CollectionPatchCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -18264,7 +24567,7 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProductUpdatePermissionCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CollectionPatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -18272,12 +24575,10 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _product_id: String, - _language_code: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProductGenerateApprovalUrlCall<'a, C, A> {} - -impl<'a, C, A> ProductGenerateApprovalUrlCall<'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, ProductsGenerateApprovalUrlResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.products.generateApprovalUrl", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("productId", self._product_id.to_string())); - if let Some(value) = self._language_code { - params.push(("languageCode", value.to_string())); - } - for &field in ["alt", "enterpriseId", "productId", "languageCode"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/products/{productId}/generateApprovalUrl".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{productId}", "productId")].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 ["productId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product. - /// - /// Sets the *product 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 product_id(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { - self._product_id = new_value.to_string(); - self - } - /// The BCP 47 language code used for permission names and descriptions in the returned iframe, for instance "en-US". - /// - /// Sets the *language code* query property to the given value. - pub fn language_code(mut self, new_value: &str) -> ProductGenerateApprovalUrlCall<'a, C, A> { - self._language_code = 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) -> ProductGenerateApprovalUrlCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProductGenerateApprovalUrlCall<'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) -> ProductGenerateApprovalUrlCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves details of an enterprise's group license for a product. -/// -/// A builder for the *get* method supported by a *grouplicense* resource. -/// It is not used directly, but through a `GrouplicenseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.grouplicenses().get("enterpriseId", "groupLicenseId") -/// .doit(); -/// # } -/// ``` -pub struct GrouplicenseGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a AndroidEnterprise, - _enterprise_id: String, - _group_license_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for GrouplicenseGetCall<'a, C, A> {} - -impl<'a, C, A> GrouplicenseGetCall<'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, GroupLicense)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "androidenterprise.grouplicenses.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("enterpriseId", self._enterprise_id.to_string())); - params.push(("groupLicenseId", self._group_license_id.to_string())); - for &field in ["alt", "enterpriseId", "groupLicenseId"].iter() { - if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/groupLicenses/{groupLicenseId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{groupLicenseId}", "groupLicenseId")].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 ["groupLicenseId", "enterpriseId"].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) - } - } - } - } - - - /// The ID of the enterprise. - /// - /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> GrouplicenseGetCall<'a, C, A> { - self._enterprise_id = new_value.to_string(); - self - } - /// The ID of the product the group license is for, e.g. "app:com.google.android.gm". - /// - /// Sets the *group license 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 group_license_id(mut self, new_value: &str) -> GrouplicenseGetCall<'a, C, A> { - self._group_license_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) -> GrouplicenseGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> GrouplicenseGetCall<'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) -> GrouplicenseGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves IDs of all products for which the enterprise has a group license. -/// -/// A builder for the *list* method supported by a *grouplicense* resource. -/// It is not used directly, but through a `GrouplicenseMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_androidenterprise1 as androidenterprise1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use androidenterprise1::AndroidEnterprise; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = AndroidEnterprise::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.grouplicenses().list("enterpriseId") -/// .doit(); -/// # } -/// ``` -pub struct GrouplicenseListCall<'a, C, A> +pub struct CollectionListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AndroidEnterprise, @@ -18820,13 +24615,13 @@ pub struct GrouplicenseListCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for GrouplicenseListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CollectionListCall<'a, C, A> {} -impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CollectionListCall<'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, GroupLicensesListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, CollectionsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -18834,7 +24629,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "androidenterprise.grouplicenses.list", + dlg.begin(MethodInfo { id: "androidenterprise.collections.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("enterpriseId", self._enterprise_id.to_string())); @@ -18850,7 +24645,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/groupLicenses".to_string(); + let mut url = "https://www.googleapis.com/androidenterprise/v1/enterprises/{enterpriseId}/collections".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -18959,7 +24754,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn enterprise_id(mut self, new_value: &str) -> GrouplicenseListCall<'a, C, A> { + pub fn enterprise_id(mut self, new_value: &str) -> CollectionListCall<'a, C, A> { self._enterprise_id = new_value.to_string(); self } @@ -18969,7 +24764,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> GrouplicenseListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CollectionListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -18990,7 +24785,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, /// * *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) -> GrouplicenseListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CollectionListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -19007,7 +24802,1773 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, /// 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) -> GrouplicenseListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CollectionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the details of a collection. +/// +/// A builder for the *get* method supported by a *collection* resource. +/// It is not used directly, but through a `CollectionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.collections().get("enterpriseId", "collectionId") +/// .doit(); +/// # } +/// ``` +pub struct CollectionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _collection_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CollectionGetCall<'a, C, A> {} + +impl<'a, C, A> CollectionGetCall<'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, Collection)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.collections.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("collectionId", self._collection_id.to_string())); + for &field in ["alt", "enterpriseId", "collectionId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].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 ["collectionId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionGetCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the collection. + /// + /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionGetCall<'a, C, A> { + self._collection_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) -> CollectionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CollectionGetCall<'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) -> CollectionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a collection. +/// +/// A builder for the *delete* method supported by a *collection* resource. +/// It is not used directly, but through a `CollectionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.collections().delete("enterpriseId", "collectionId") +/// .doit(); +/// # } +/// ``` +pub struct CollectionDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _collection_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CollectionDeleteCall<'a, C, A> {} + +impl<'a, C, A> CollectionDeleteCall<'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: "androidenterprise.collections.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("collectionId", self._collection_id.to_string())); + for &field in ["enterpriseId", "collectionId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].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 ["collectionId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the collection. + /// + /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionDeleteCall<'a, C, A> { + self._collection_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) -> CollectionDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CollectionDeleteCall<'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) -> CollectionDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a new collection. +/// +/// A builder for the *insert* method supported by a *collection* resource. +/// It is not used directly, but through a `CollectionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::Collection; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = Collection::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.collections().insert(req, "enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct CollectionInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: Collection, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CollectionInsertCall<'a, C, A> {} + +impl<'a, C, A> CollectionInsertCall<'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, Collection)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.collections.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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: Collection) -> CollectionInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionInsertCall<'a, C, A> { + self._enterprise_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) -> CollectionInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CollectionInsertCall<'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) -> CollectionInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a collection. +/// +/// A builder for the *update* method supported by a *collection* resource. +/// It is not used directly, but through a `CollectionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::Collection; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = Collection::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.collections().update(req, "enterpriseId", "collectionId") +/// .doit(); +/// # } +/// ``` +pub struct CollectionUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: Collection, + _enterprise_id: String, + _collection_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CollectionUpdateCall<'a, C, A> {} + +impl<'a, C, A> CollectionUpdateCall<'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, Collection)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.collections.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("collectionId", self._collection_id.to_string())); + for &field in ["alt", "enterpriseId", "collectionId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/collections/{collectionId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{collectionId}", "collectionId")].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 ["collectionId", "enterpriseId"].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: Collection) -> CollectionUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> CollectionUpdateCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the collection. + /// + /// Sets the *collection 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 collection_id(mut self, new_value: &str) -> CollectionUpdateCall<'a, C, A> { + self._collection_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) -> CollectionUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CollectionUpdateCall<'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) -> CollectionUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all active credentials for the service account associated with this enterprise. Only the ID and key type are returned. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. +/// +/// A builder for the *list* method supported by a *serviceaccountkey* resource. +/// It is not used directly, but through a `ServiceaccountkeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.serviceaccountkeys().list("enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct ServiceaccountkeyListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ServiceaccountkeyListCall<'a, C, A> {} + +impl<'a, C, A> ServiceaccountkeyListCall<'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, ServiceAccountKeysListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.serviceaccountkeys.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/serviceAccountKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ServiceaccountkeyListCall<'a, C, A> { + self._enterprise_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) -> ServiceaccountkeyListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ServiceaccountkeyListCall<'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) -> ServiceaccountkeyListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates new credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. +/// +/// Only the type of the key should be populated in the resource to be inserted. +/// +/// A builder for the *insert* method supported by a *serviceaccountkey* resource. +/// It is not used directly, but through a `ServiceaccountkeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// use androidenterprise1::ServiceAccountKey; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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 = ServiceAccountKey::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.serviceaccountkeys().insert(req, "enterpriseId") +/// .doit(); +/// # } +/// ``` +pub struct ServiceaccountkeyInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _request: ServiceAccountKey, + _enterprise_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ServiceaccountkeyInsertCall<'a, C, A> {} + +impl<'a, C, A> ServiceaccountkeyInsertCall<'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, ServiceAccountKey)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidenterprise.serviceaccountkeys.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + for &field in ["alt", "enterpriseId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/serviceAccountKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId")].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 ["enterpriseId"].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: ServiceAccountKey) -> ServiceaccountkeyInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ServiceaccountkeyInsertCall<'a, C, A> { + self._enterprise_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) -> ServiceaccountkeyInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ServiceaccountkeyInsertCall<'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) -> ServiceaccountkeyInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Removes and invalidates the specified credentials for the service account associated with this enterprise. The calling service account must have been retrieved by calling Enterprises.GetServiceAccount and must have been set as the enterprise service account by calling Enterprises.SetAccount. +/// +/// A builder for the *delete* method supported by a *serviceaccountkey* resource. +/// It is not used directly, but through a `ServiceaccountkeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidenterprise1 as androidenterprise1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidenterprise1::AndroidEnterprise; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidEnterprise::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.serviceaccountkeys().delete("enterpriseId", "keyId") +/// .doit(); +/// # } +/// ``` +pub struct ServiceaccountkeyDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidEnterprise, + _enterprise_id: String, + _key_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ServiceaccountkeyDeleteCall<'a, C, A> {} + +impl<'a, C, A> ServiceaccountkeyDeleteCall<'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: "androidenterprise.serviceaccountkeys.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("enterpriseId", self._enterprise_id.to_string())); + params.push(("keyId", self._key_id.to_string())); + for &field in ["enterpriseId", "keyId"].iter() { + if self._additional_params.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/androidenterprise/v1/enterprises/{enterpriseId}/serviceAccountKeys/{keyId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{enterpriseId}", "enterpriseId"), ("{keyId}", "keyId")].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 ["keyId", "enterpriseId"].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) + } + } + } + } + + + /// The ID of the enterprise. + /// + /// Sets the *enterprise 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 enterprise_id(mut self, new_value: &str) -> ServiceaccountkeyDeleteCall<'a, C, A> { + self._enterprise_id = new_value.to_string(); + self + } + /// The ID of the key. + /// + /// Sets the *key 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 key_id(mut self, new_value: &str) -> ServiceaccountkeyDeleteCall<'a, C, A> { + self._key_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) -> ServiceaccountkeyDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ServiceaccountkeyDeleteCall<'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) -> ServiceaccountkeyDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -19042,7 +26603,7 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().get("permissionId") -/// .language("dolor") +/// .language("dolores") /// .doit(); /// # } /// ``` diff --git a/gen/androidpublisher2-cli/Cargo.toml b/gen/androidpublisher2-cli/Cargo.toml index 2daf905985..8687716967 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+20160324" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "androidpublisher2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-androidpublisher2/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-androidpublisher2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-androidpublisher2] diff --git a/gen/androidpublisher2-cli/README.md b/gen/androidpublisher2-cli/README.md index 01e9ecf592..d31497757a 100644 --- a/gen/androidpublisher2-cli/README.md +++ b/gen/androidpublisher2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Android Publisher* API at revision *20160324*. 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 *0.3.6*. ```bash androidpublisher2 [options] @@ -84,6 +84,10 @@ androidpublisher2 [options] subscriptions-get [-p ]... [-o ] subscriptions-refund [-p ]... subscriptions-revoke [-p ]... + reviews + get [-p ]... [-o ] + list [-p ]... [-o ] + reply (-r )... [-p ]... [-o ] androidpublisher2 --help Configuration: diff --git a/gen/androidpublisher2-cli/mkdocs.yml b/gen/androidpublisher2-cli/mkdocs.yml index 5ee8e93748..e65c73859d 100644 --- a/gen/androidpublisher2-cli/mkdocs.yml +++ b/gen/androidpublisher2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Android Publisher v0.3.6+20160324 +site_name: Android Publisher v0.3.6+20160817 site_url: http://byron.github.io/google-apis-rs/google-androidpublisher2-cli site_description: Write integrating applications with bcore @@ -61,6 +61,9 @@ pages: - ['purchases_subscriptions-get.md', 'Purchases', 'Subscriptions Get'] - ['purchases_subscriptions-refund.md', 'Purchases', 'Subscriptions Refund'] - ['purchases_subscriptions-revoke.md', 'Purchases', 'Subscriptions Revoke'] +- ['reviews_get.md', 'Reviews', 'Get'] +- ['reviews_list.md', 'Reviews', 'List'] +- ['reviews_reply.md', 'Reviews', 'Reply'] theme: readthedocs diff --git a/gen/androidpublisher2-cli/src/main.rs b/gen/androidpublisher2-cli/src/main.rs index 7728d107f5..5de1383890 100644 --- a/gen/androidpublisher2-cli/src/main.rs +++ b/gen/androidpublisher2-cli/src/main.rs @@ -3424,6 +3424,205 @@ impl<'n> Engine<'n> { } } + fn _reviews_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reviews().get(opt.value_of("package-name").unwrap_or(""), opt.value_of("review-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 _reviews_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reviews().list(opt.value_of("package-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 { + "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 _reviews_reply(&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()[..] { + "reply-text" => Some(("replyText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["reply-text"]); + 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::ReviewsReplyRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.reviews().reply(request, opt.value_of("package-name").unwrap_or(""), opt.value_of("review-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(()); @@ -3617,6 +3816,23 @@ impl<'n> Engine<'n> { } } }, + ("reviews", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._reviews_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._reviews_list(opt, dry_run, &mut err); + }, + ("reply", Some(opt)) => { + call_result = self._reviews_reply(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("reviews".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, _ => { err.issues.push(CLIError::MissingCommandError); writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); @@ -5462,11 +5678,98 @@ fn main() { ]), ]), + ("reviews", "methods: 'get', 'list' and 'reply'", vec![ + ("get", + Some(r##"Returns a single review."##), + "Details at http://byron.github.io/google-apis-rs/google_androidpublisher2_cli/reviews_get", + vec![ + (Some(r##"package-name"##), + None, + Some(r##"Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame"."##), + Some(true), + Some(false)), + + (Some(r##"review-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)), + ]), + ("list", + Some(r##"Returns a list of reviews."##), + "Details at http://byron.github.io/google-apis-rs/google_androidpublisher2_cli/reviews_list", + vec![ + (Some(r##"package-name"##), + None, + Some(r##"Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame"."##), + 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)), + ]), + ("reply", + Some(r##"Reply to a single review, or update an existing reply."##), + "Details at http://byron.github.io/google-apis-rs/google_androidpublisher2_cli/reviews_reply", + vec![ + (Some(r##"package-name"##), + None, + Some(r##"Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame"."##), + Some(true), + Some(false)), + + (Some(r##"review-id"##), + None, + None, + 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("androidpublisher2") .author("Sebastian Thiel ") - .version("0.3.6+20160324") + .version("0.3.6+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/androidpublisher2/Cargo.toml b/gen/androidpublisher2/Cargo.toml index 3271a88eb1..140397d173 100644 --- a/gen/androidpublisher2/Cargo.toml +++ b/gen/androidpublisher2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-androidpublisher2" -version = "0.1.14+20160324" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/androidpublisher2/README.md b/gen/androidpublisher2/README.md index 0f504cb6c4..487b0be245 100644 --- a/gen/androidpublisher2/README.md +++ b/gen/androidpublisher2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-androidpublisher2` library allows access to all features of the *Google Android Publisher* service. -This documentation was generated from *Android Publisher* crate version *0.1.14+20160324*, where *20160324* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Android Publisher* crate version *0.1.14+20160817*, where *20160817* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Android Publisher* *v2* API can be found at the [official documentation site](https://developers.google.com/android-publisher). @@ -21,6 +21,8 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*batch*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductBatchCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.InappproductUpdateCall.html) * purchases * [*products get*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseProductGetCall.html), [*subscriptions cancel*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseSubscriptionCancelCall.html), [*subscriptions defer*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseSubscriptionDeferCall.html), [*subscriptions get*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseSubscriptionGetCall.html), [*subscriptions refund*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseSubscriptionRefundCall.html) and [*subscriptions revoke*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.PurchaseSubscriptionRevokeCall.html) +* [reviews](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.Review.html) + * [*get*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.ReviewGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.ReviewListCall.html) and [*reply*](http://byron.github.io/google-apis-rs/google_androidpublisher2/struct.ReviewReplyCall.html) Upload supported by ... diff --git a/gen/androidpublisher2/src/lib.rs b/gen/androidpublisher2/src/lib.rs index a2c10d502b..b06c703604 100644 --- a/gen/androidpublisher2/src/lib.rs +++ b/gen/androidpublisher2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Android Publisher* crate version *0.1.14+20160324*, where *20160324* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Android Publisher* crate version *0.1.14+20160817*, where *20160817* is the exact revision of the *androidpublisher:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Android Publisher* *v2* API can be found at the //! [official documentation site](https://developers.google.com/android-publisher). @@ -19,6 +19,8 @@ //! * [*batch*](struct.InappproductBatchCall.html), [*delete*](struct.InappproductDeleteCall.html), [*get*](struct.InappproductGetCall.html), [*insert*](struct.InappproductInsertCall.html), [*list*](struct.InappproductListCall.html), [*patch*](struct.InappproductPatchCall.html) and [*update*](struct.InappproductUpdateCall.html) //! * purchases //! * [*products get*](struct.PurchaseProductGetCall.html), [*subscriptions cancel*](struct.PurchaseSubscriptionCancelCall.html), [*subscriptions defer*](struct.PurchaseSubscriptionDeferCall.html), [*subscriptions get*](struct.PurchaseSubscriptionGetCall.html), [*subscriptions refund*](struct.PurchaseSubscriptionRefundCall.html) and [*subscriptions revoke*](struct.PurchaseSubscriptionRevokeCall.html) +//! * [reviews](struct.Review.html) +//! * [*get*](struct.ReviewGetCall.html), [*list*](struct.ReviewListCall.html) and [*reply*](struct.ReviewReplyCall.html) //! //! //! Upload supported by ... diff --git a/gen/androidpublisher2/src/lib.rs.in b/gen/androidpublisher2/src/lib.rs.in index 5ed188e61e..d591139b6b 100644 --- a/gen/androidpublisher2/src/lib.rs.in +++ b/gen/androidpublisher2/src/lib.rs.in @@ -150,6 +150,9 @@ impl<'a, C, A> AndroidPublisher pub fn purchases(&'a self) -> PurchaseMethods<'a, C, A> { PurchaseMethods { hub: &self } } + pub fn reviews(&'a self) -> ReviewMethods<'a, C, A> { + ReviewMethods { 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`. @@ -166,6 +169,25 @@ impl<'a, C, A> AndroidPublisher // ############ // SCHEMAS ### // ########## +/// 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*). +/// +/// * [subscriptions defer purchases](struct.PurchaseSubscriptionDeferCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SubscriptionPurchasesDeferRequest { + /// The information about the new desired expiry time for the subscription. + #[serde(rename="deferralInfo")] + pub deferral_info: Option, +} + +impl RequestValue for SubscriptionPurchasesDeferRequest {} + + /// An Entitlement resource indicates a user's current entitlement to an inapp item or subscription. /// /// # Activities @@ -214,6 +236,33 @@ pub struct ApksListResponse { impl ResponseResult for ApksListResponse {} +/// 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 reviews](struct.ReviewGetCall.html) (response) +/// * [reply reviews](struct.ReviewReplyCall.html) (none) +/// * [list reviews](struct.ReviewListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Review { + /// The name of the user who wrote the review. + #[serde(rename="authorName")] + pub author_name: Option, + /// Unique identifier for this review. + #[serde(rename="reviewId")] + pub review_id: Option, + /// A repeated field containing comments for the review. + pub comments: Option>, +} + +impl Resource for Review {} +impl ResponseResult for Review {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -227,6 +276,30 @@ pub struct InappproductsUpdateResponse { impl Part for InappproductsUpdateResponse {} +/// 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 reviews](struct.ReviewListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReviewsListResponse { + /// no description provided + pub reviews: Option>, + /// no description provided + #[serde(rename="tokenPagination")] + pub token_pagination: Option, + /// no description provided + #[serde(rename="pageInfo")] + pub page_info: Option, +} + +impl ResponseResult for ReviewsListResponse {} + + /// There is no detailed description. /// /// # Activities @@ -322,7 +395,7 @@ pub struct SubscriptionDeferralInfo { /// The expected expiry time for the subscription. If the current expiry time for the subscription is not the value specified here, the deferral will not occur. #[serde(rename="expectedExpiryTimeMillis")] pub expected_expiry_time_millis: Option, - /// The desired next expiry time for the subscription in milliseconds since Epoch. The given time must be after the current expiry time for the subscription. + /// The desired next expiry time to assign to the subscription, in milliseconds since the Epoch. The given time must be later/greater than the current expiry time for the subscription. #[serde(rename="desiredExpiryTimeMillis")] pub desired_expiry_time_millis: Option, } @@ -473,48 +546,30 @@ impl ResponseResult for ImagesDeleteAllResponse {} /// 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*). /// -/// * [tracks update edits](struct.EditTrackUpdateCall.html) (request|response) -/// * [tracks patch edits](struct.EditTrackPatchCall.html) (request|response) -/// * [tracks get edits](struct.EditTrackGetCall.html) (response) +/// * [reply reviews](struct.ReviewReplyCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Track { +pub struct ReviewsReplyResponse { /// no description provided - pub track: Option, - /// no description provided - #[serde(rename="userFraction")] - pub user_fraction: Option, - /// no description provided - #[serde(rename="versionCodes")] - pub version_codes: Option>, + pub result: Option, } -impl RequestValue for Track {} -impl ResponseResult for Track {} +impl ResponseResult for ReviewsReplyResponse {} /// 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 entitlements](struct.EntitlementListCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct EntitlementsListResponse { +pub struct Timestamp { /// no description provided - #[serde(rename="tokenPagination")] - pub token_pagination: Option, + pub nanos: Option, /// no description provided - #[serde(rename="pageInfo")] - pub page_info: Option, - /// no description provided - pub resources: Option>, + pub seconds: Option, } -impl ResponseResult for EntitlementsListResponse {} +impl Part for Timestamp {} /// There is no detailed description. @@ -539,16 +594,16 @@ impl Part for InAppProductListing {} /// 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*). /// -/// * [subscriptions defer purchases](struct.PurchaseSubscriptionDeferCall.html) (request) +/// * [reply reviews](struct.ReviewReplyCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SubscriptionPurchasesDeferRequest { - /// The information about the new desired expiry time for the subscription. - #[serde(rename="deferralInfo")] - pub deferral_info: Option, +pub struct ReviewsReplyRequest { + /// The text to set as the reply. Replies of more than approximately 350 characters will be rejected. HTML tags will be stripped. + #[serde(rename="replyText")] + pub reply_text: Option, } -impl RequestValue for SubscriptionPurchasesDeferRequest {} +impl RequestValue for ReviewsReplyRequest {} /// There is no detailed description. @@ -669,6 +724,39 @@ pub struct InappproductsBatchResponseEntry { impl Part for InappproductsBatchResponseEntry {} +/// 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 UserComment { + /// Integer version code of the app as installed at the time the review was written. May be absent. + #[serde(rename="appVersionCode")] + pub app_version_code: Option, + /// Language code for the reviewer. This is taken from the device settings so is not guaranteed to match the language the review is written in. May be absent. + #[serde(rename="reviewerLanguage")] + pub reviewer_language: Option, + /// The last time at which this comment was updated. + #[serde(rename="lastModified")] + pub last_modified: Option, + /// The star rating associated with the review, from 1 to 5. + #[serde(rename="starRating")] + pub star_rating: Option, + /// The content of the comment, i.e. review body. In some cases users have been able to write a review with separate title and body; in those cases the title and body are concatenated and separated by a tab character. + pub text: Option, + /// Codename for the reviewer's device, e.g. klte, flounder. May be absent. + pub device: Option, + /// Integer Android SDK version of the user's device at the time the review was written, e.g. 23 is Marshmallow. May be absent. + #[serde(rename="androidOsVersion")] + pub android_os_version: Option, + /// String version name of the app as installed at the time the review was written. May be absent. + #[serde(rename="appVersionName")] + pub app_version_name: Option, +} + +impl Part for UserComment {} + + /// Represents an edit of an app. An edit allows clients to make multiple changes before committing them in one operation. /// /// # Activities @@ -850,6 +938,22 @@ impl RequestValue for ApkListing {} impl ResponseResult for ApkListing {} +/// 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 DeveloperComment { + /// The last time at which this comment was updated. + #[serde(rename="lastModified")] + pub last_modified: Option, + /// The content of the comment, i.e. reply body. + pub text: Option, +} + +impl Part for DeveloperComment {} + + /// There is no detailed description. /// /// # Activities @@ -919,6 +1023,47 @@ pub struct ApksAddExternallyHostedResponse { impl ResponseResult for ApksAddExternallyHostedResponse {} +/// 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 Comment { + /// A comment from a developer. + #[serde(rename="developerComment")] + pub developer_comment: Option, + /// A comment from a user. + #[serde(rename="userComment")] + pub user_comment: Option, +} + +impl Part for Comment {} + + +/// 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 entitlements](struct.EntitlementListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EntitlementsListResponse { + /// no description provided + #[serde(rename="tokenPagination")] + pub token_pagination: Option, + /// no description provided + #[serde(rename="pageInfo")] + pub page_info: Option, + /// no description provided + pub resources: Option>, +} + +impl ResponseResult for EntitlementsListResponse {} + + /// A SubscriptionPurchase resource indicates the status of a user's subscription purchase. /// /// # Activities @@ -949,18 +1094,18 @@ pub struct SubscriptionPurchase { /// ISO 4217 currency code for the subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP". #[serde(rename="priceCurrencyCode")] pub price_currency_code: Option, - /// Time at which the subscription will expire, in milliseconds since Epoch. + /// Time at which the subscription will expire, in milliseconds since the Epoch. #[serde(rename="expiryTimeMillis")] pub expiry_time_millis: Option, - /// The cancel reason of the subscription, if the subscription is not auto renewing. Possible values are: + /// The reason why a subscription was cancelled or is not auto-renewing. Possible values are: /// - User cancelled the subscription /// - Subscription was cancelled by the system, for example because of a billing problem #[serde(rename="cancelReason")] pub cancel_reason: Option, - /// Time at which the subscription was granted, in milliseconds since Epoch. + /// Time at which the subscription was granted, in milliseconds since the Epoch. #[serde(rename="startTimeMillis")] pub start_time_millis: Option, - /// Price of the subscription, not including tax. Price is expressed in micro-units, where 1,000,000 micro-units equal one unit of the currency. For example, if the subscription price is €1.99, price_amount_micros is 1990000. + /// Price of the subscription, not including tax. Price is expressed in micro-units, where 1,000,000 micro-units represents one unit of the currency. For example, if the subscription price is €1.99, price_amount_micros is 1990000. #[serde(rename="priceAmountMicros")] pub price_amount_micros: Option, } @@ -1073,6 +1218,50 @@ pub struct Apk { impl ResponseResult for Apk {} +/// 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 ReviewReplyResult { + /// The reply text that was applied. + #[serde(rename="replyText")] + pub reply_text: Option, + /// The time at which the reply took effect. + #[serde(rename="lastEdited")] + pub last_edited: Option, +} + +impl Part for ReviewReplyResult {} + + +/// 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*). +/// +/// * [tracks update edits](struct.EditTrackUpdateCall.html) (request|response) +/// * [tracks patch edits](struct.EditTrackPatchCall.html) (request|response) +/// * [tracks get edits](struct.EditTrackGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Track { + /// no description provided + pub track: Option, + /// no description provided + #[serde(rename="userFraction")] + pub user_fraction: Option, + /// no description provided + #[serde(rename="versionCodes")] + pub version_codes: Option>, +} + +impl RequestValue for Track {} +impl ResponseResult for Track {} + + /// There is no detailed description. /// /// # Activities @@ -2261,6 +2450,107 @@ impl<'a, C, A> EditMethods<'a, C, A> { +/// A builder providing access to all methods supported on *review* resources. +/// It is not used directly, but through the `AndroidPublisher` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_androidpublisher2 as androidpublisher2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use androidpublisher2::AndroidPublisher; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = AndroidPublisher::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)` and `reply(...)` +/// // to build up your call. +/// let rb = hub.reviews(); +/// # } +/// ``` +pub struct ReviewMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidPublisher, +} + +impl<'a, C, A> MethodsBuilder for ReviewMethods<'a, C, A> {} + +impl<'a, C, A> ReviewMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Reply to a single review, or update an existing reply. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + /// * `reviewId` - No description provided. + pub fn reply(&self, request: ReviewsReplyRequest, package_name: &str, review_id: &str) -> ReviewReplyCall<'a, C, A> { + ReviewReplyCall { + hub: self.hub, + _request: request, + _package_name: package_name.to_string(), + _review_id: review_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a single review. + /// + /// # Arguments + /// + /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + /// * `reviewId` - No description provided. + pub fn get(&self, package_name: &str, review_id: &str) -> ReviewGetCall<'a, C, A> { + ReviewGetCall { + hub: self.hub, + _package_name: package_name.to_string(), + _review_id: review_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of reviews. + /// + /// # Arguments + /// + /// * `packageName` - Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + pub fn list(&self, package_name: &str) -> ReviewListCall<'a, C, A> { + ReviewListCall { + hub: self.hub, + _package_name: package_name.to_string(), + _token: Default::default(), + _start_index: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *inappproduct* resources. /// It is not used directly, but through the `AndroidPublisher` hub. /// @@ -14746,6 +15036,797 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = AndroidPublisher::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 = ReviewsReplyRequest::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.reviews().reply(req, "packageName", "reviewId") +/// .doit(); +/// # } +/// ``` +pub struct ReviewReplyCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidPublisher, + _request: ReviewsReplyRequest, + _package_name: String, + _review_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReviewReplyCall<'a, C, A> {} + +impl<'a, C, A> ReviewReplyCall<'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, ReviewsReplyResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidpublisher.reviews.reply", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("packageName", self._package_name.to_string())); + params.push(("reviewId", self._review_id.to_string())); + for &field in ["alt", "packageName", "reviewId"].iter() { + if self._additional_params.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/androidpublisher/v2/applications/{packageName}/reviews/{reviewId}:reply".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].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 ["reviewId", "packageName"].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: ReviewsReplyRequest) -> ReviewReplyCall<'a, C, A> { + self._request = new_value; + self + } + /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + /// + /// Sets the *package name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn package_name(mut self, new_value: &str) -> ReviewReplyCall<'a, C, A> { + self._package_name = new_value.to_string(); + self + } + /// + /// Sets the *review 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 review_id(mut self, new_value: &str) -> ReviewReplyCall<'a, C, A> { + self._review_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) -> ReviewReplyCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReviewReplyCall<'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) -> ReviewReplyCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a single review. +/// +/// A builder for the *get* method supported by a *review* resource. +/// It is not used directly, but through a `ReviewMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidpublisher2 as androidpublisher2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidpublisher2::AndroidPublisher; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidPublisher::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.reviews().get("packageName", "reviewId") +/// .doit(); +/// # } +/// ``` +pub struct ReviewGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidPublisher, + _package_name: String, + _review_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReviewGetCall<'a, C, A> {} + +impl<'a, C, A> ReviewGetCall<'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, Review)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidpublisher.reviews.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("packageName", self._package_name.to_string())); + params.push(("reviewId", self._review_id.to_string())); + for &field in ["alt", "packageName", "reviewId"].iter() { + if self._additional_params.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/androidpublisher/v2/applications/{packageName}/reviews/{reviewId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{packageName}", "packageName"), ("{reviewId}", "reviewId")].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 ["reviewId", "packageName"].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) + } + } + } + } + + + /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + /// + /// Sets the *package name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn package_name(mut self, new_value: &str) -> ReviewGetCall<'a, C, A> { + self._package_name = new_value.to_string(); + self + } + /// + /// Sets the *review 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 review_id(mut self, new_value: &str) -> ReviewGetCall<'a, C, A> { + self._review_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) -> ReviewGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReviewGetCall<'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) -> ReviewGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a list of reviews. +/// +/// A builder for the *list* method supported by a *review* resource. +/// It is not used directly, but through a `ReviewMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_androidpublisher2 as androidpublisher2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use androidpublisher2::AndroidPublisher; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = AndroidPublisher::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.reviews().list("packageName") +/// .token("Lorem") +/// .start_index(38) +/// .max_results(64) +/// .doit(); +/// # } +/// ``` +pub struct ReviewListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a AndroidPublisher, + _package_name: String, + _token: Option, + _start_index: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReviewListCall<'a, C, A> {} + +impl<'a, C, A> ReviewListCall<'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, ReviewsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "androidpublisher.reviews.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("packageName", self._package_name.to_string())); + 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", "packageName", "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/androidpublisher/v2/applications/{packageName}/reviews".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{packageName}", "packageName")].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 ["packageName"].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) + } + } + } + } + + + /// Unique identifier for the Android app for which we want reviews; for example, "com.spiffygame". + /// + /// Sets the *package name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn package_name(mut self, new_value: &str) -> ReviewListCall<'a, C, A> { + self._package_name = new_value.to_string(); + self + } + /// + /// Sets the *token* query property to the given value. + pub fn token(mut self, new_value: &str) -> ReviewListCall<'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) -> ReviewListCall<'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) -> ReviewListCall<'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) -> ReviewListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReviewListCall<'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) -> ReviewListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// A builder for the *batch* method supported by a *inappproduct* resource. /// It is not used directly, but through a `InappproductMethods` instance. /// @@ -15004,9 +16085,9 @@ impl<'a, C, A> InappproductBatchCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().list("packageName") -/// .token("diam") -/// .start_index(39) -/// .max_results(14) +/// .token("At") +/// .start_index(5) +/// .max_results(79) /// .doit(); /// # } /// ``` @@ -16038,7 +17119,7 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inappproducts().update(req, "packageName", "sku") -/// .auto_convert_missing_prices(false) +/// .auto_convert_missing_prices(true) /// .doit(); /// # } /// ``` @@ -16328,7 +17409,7 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut"] +description = "A complete library to interact with appengine (protocol v1)" +repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1-cli" +homepage = "https://cloud.google.com/appengine/docs/admin-api/" +documentation = "http://byron.github.io/google-apis-rs/google_appengine1_cli" +license = "MIT" +keywords = ["appengine", "google", "cli"] + +[[bin]] +name = "appengine1" + +[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.4" +yup-hyper-mock = "^1.0" +clap = "^2.0" + +[features] +default = ["with-serde-codegen"] +nightly = ["serde_macros","yup-oauth2/nightly","google-appengine1/nightly"] +with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appengine1/with-serde-codegen"] + +[build-dependencies] +serde_codegen = { version = "^ 0.8", optional = true } + + +[dependencies.google-appengine1] +path = "../appengine1" +optional = true +default-features = false diff --git a/gen/appengine1-cli/LICENSE.md b/gen/appengine1-cli/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/appengine1-cli/LICENSE.md @@ -0,0 +1,30 @@ + +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/appengine1-cli/README.md b/gen/appengine1-cli/README.md new file mode 100644 index 0000000000..21973d7aed --- /dev/null +++ b/gen/appengine1-cli/README.md @@ -0,0 +1,131 @@ + +The `appengine1` command-line interface *(CLI)* allows to use most features of the *Google appengine* 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 *appengine* API can be found at the +[official documentation site](https://cloud.google.com/appengine/docs/admin-api/). + +# 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/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) + +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*. + +```bash +appengine1 [options] + apps + get [-p ]... [-o ] + locations-get [-p ]... [-o ] + locations-list [-p ]... [-o ] + operations-get [-p ]... [-o ] + operations-list [-p ]... [-o ] + repair (-r )... [-p ]... [-o ] + services-delete [-p ]... [-o ] + services-get [-p ]... [-o ] + services-list [-p ]... [-o ] + services-patch (-r )... [-p ]... [-o ] + services-versions-create (-r )... [-p ]... [-o ] + services-versions-delete [-p ]... [-o ] + services-versions-get [-p ]... [-o ] + services-versions-instances-debug (-r )... [-p ]... [-o ] + services-versions-instances-delete [-p ]... [-o ] + services-versions-instances-get [-p ]... [-o ] + services-versions-instances-list [-p ]... [-o ] + services-versions-list [-p ]... [-o ] + services-versions-patch (-r )... [-p ]... [-o ] + appengine1 --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 `appengine1-`. 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/appengine1-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/appengine1-secret.json`, assuming that the required *appengine* 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. `appengine1 --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/appengine1-cli/mkdocs.yml b/gen/appengine1-cli/mkdocs.yml new file mode 100644 index 0000000000..2a81e86024 --- /dev/null +++ b/gen/appengine1-cli/mkdocs.yml @@ -0,0 +1,35 @@ +site_name: appengine v0.3.6+20160802 +site_url: http://byron.github.io/google-apis-rs/google-appengine1-cli +site_description: Write integrating applications with bcore + +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1-cli + +docs_dir: docs +site_dir: build_html + +pages: +- ['index.md', 'Home'] +- ['apps_get.md', 'Apps', 'Get'] +- ['apps_locations-get.md', 'Apps', 'Locations Get'] +- ['apps_locations-list.md', 'Apps', 'Locations List'] +- ['apps_operations-get.md', 'Apps', 'Operations Get'] +- ['apps_operations-list.md', 'Apps', 'Operations List'] +- ['apps_repair.md', 'Apps', 'Repair'] +- ['apps_services-delete.md', 'Apps', 'Services Delete'] +- ['apps_services-get.md', 'Apps', 'Services Get'] +- ['apps_services-list.md', 'Apps', 'Services List'] +- ['apps_services-patch.md', 'Apps', 'Services Patch'] +- ['apps_services-versions-create.md', 'Apps', 'Services Versions Create'] +- ['apps_services-versions-delete.md', 'Apps', 'Services Versions Delete'] +- ['apps_services-versions-get.md', 'Apps', 'Services Versions Get'] +- ['apps_services-versions-instances-debug.md', 'Apps', 'Services Versions Instances Debug'] +- ['apps_services-versions-instances-delete.md', 'Apps', 'Services Versions Instances Delete'] +- ['apps_services-versions-instances-get.md', 'Apps', 'Services Versions Instances Get'] +- ['apps_services-versions-instances-list.md', 'Apps', 'Services Versions Instances List'] +- ['apps_services-versions-list.md', 'Apps', 'Services Versions List'] +- ['apps_services-versions-patch.md', 'Apps', 'Services Versions Patch'] + +theme: readthedocs + +copyright: Copyright © 2015-2016, `Sebastian Thiel` + diff --git a/gen/appengine1-cli/src/cmn.rs b/gen/appengine1-cli/src/cmn.rs new file mode 100644 index 0000000000..779c1dc086 --- /dev/null +++ b/gen/appengine1-cli/src/cmn.rs @@ -0,0 +1,721 @@ +// 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/appengine1-cli/src/main.rs b/gen/appengine1-cli/src/main.rs new file mode 100644 index 0000000000..8c70dd2f2b --- /dev/null +++ b/gen/appengine1-cli/src/main.rs @@ -0,0 +1,2229 @@ +// 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_appengine1 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::Appengine>, + gp: Vec<&'static str>, + gpm: Vec<(&'static str, &'static str)>, +} + + +impl<'n> Engine<'n> { + fn _apps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().get(opt.value_of("apps-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 _apps_locations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("locations-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 _apps_locations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_list(opt.value_of("apps-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" => { + 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", "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 _apps_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().operations_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("operations-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 _apps_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().operations_list(opt.value_of("apps-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" => { + 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", "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 _apps_repair(&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::RepairApplicationRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().repair(request, opt.value_of("apps-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 _apps_services_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-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 _apps_services_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-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 _apps_services_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_list(opt.value_of("apps-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 _apps_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()[..] { + "split.shard-by" => Some(("split.shardBy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "split.allocations" => Some(("split.allocations", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Map })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["allocations", "id", "name", "shard-by", "split"]); + 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::Service = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().services_patch(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-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 { + "update-mask" => { + call = call.update_mask(value.unwrap_or("")); + }, + "migrate-traffic" => { + call = call.migrate_traffic(arg_from_str(value.unwrap_or("false"), err, "migrate-traffic", "boolean")); + }, + _ => { + 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(["migrate-traffic", "update-mask"].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 _apps_services_versions_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()[..] { + "basic-scaling.idle-timeout" => Some(("basicScaling.idleTimeout", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "basic-scaling.max-instances" => Some(("basicScaling.maxInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "beta-settings" => Some(("betaSettings", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "vm" => Some(("vm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "instance-class" => Some(("instanceClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version-url" => Some(("versionUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.url" => Some(("apiConfig.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.security-level" => Some(("apiConfig.securityLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.auth-fail-action" => Some(("apiConfig.authFailAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.login" => Some(("apiConfig.login", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.script" => Some(("apiConfig.script", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "threadsafe" => Some(("threadsafe", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "health-check.restart-threshold" => Some(("healthCheck.restartThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.check-interval" => Some(("healthCheck.checkInterval", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.unhealthy-threshold" => Some(("healthCheck.unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.healthy-threshold" => Some(("healthCheck.healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.host" => Some(("healthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.timeout" => Some(("healthCheck.timeout", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.disable-health-check" => Some(("healthCheck.disableHealthCheck", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-expiration" => Some(("defaultExpiration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "env" => Some(("env", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "disk-usage-bytes" => Some(("diskUsageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.min-pending-latency" => Some(("automaticScaling.minPendingLatency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-received-packets-per-second" => Some(("automaticScaling.networkUtilization.targetReceivedPacketsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-sent-packets-per-second" => Some(("automaticScaling.networkUtilization.targetSentPacketsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-received-bytes-per-second" => Some(("automaticScaling.networkUtilization.targetReceivedBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-sent-bytes-per-second" => Some(("automaticScaling.networkUtilization.targetSentBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-read-ops-per-second" => Some(("automaticScaling.diskUtilization.targetReadOpsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-write-bytes-per-second" => Some(("automaticScaling.diskUtilization.targetWriteBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-read-bytes-per-second" => Some(("automaticScaling.diskUtilization.targetReadBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-write-ops-per-second" => Some(("automaticScaling.diskUtilization.targetWriteOpsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.max-pending-latency" => Some(("automaticScaling.maxPendingLatency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.max-idle-instances" => Some(("automaticScaling.maxIdleInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.min-idle-instances" => Some(("automaticScaling.minIdleInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.request-utilization.target-concurrent-requests" => Some(("automaticScaling.requestUtilization.targetConcurrentRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.request-utilization.target-request-count-per-second" => Some(("automaticScaling.requestUtilization.targetRequestCountPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.cool-down-period" => Some(("automaticScaling.coolDownPeriod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.max-total-instances" => Some(("automaticScaling.maxTotalInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.max-concurrent-requests" => Some(("automaticScaling.maxConcurrentRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.min-total-instances" => Some(("automaticScaling.minTotalInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.cpu-utilization.target-utilization" => Some(("automaticScaling.cpuUtilization.targetUtilization", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "automatic-scaling.cpu-utilization.aggregation-window-length" => Some(("automaticScaling.cpuUtilization.aggregationWindowLength", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "env-variables" => Some(("envVariables", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "resources.disk-gb" => Some(("resources.diskGb", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "resources.cpu" => Some(("resources.cpu", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "resources.memory-gb" => Some(("resources.memoryGb", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "manual-scaling.instances" => Some(("manualScaling.instances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "inbound-services" => Some(("inboundServices", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "created-by" => Some(("createdBy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "deployment.container.image" => Some(("deployment.container.image", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "deployment.zip.files-count" => Some(("deployment.zip.filesCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "deployment.zip.source-url" => Some(("deployment.zip.sourceUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-time" => Some(("createTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "network.instance-tag" => Some(("network.instanceTag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "network.forwarded-ports" => Some(("network.forwardedPorts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "network.name" => Some(("network.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nobuild-files-regex" => Some(("nobuildFilesRegex", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "serving-status" => Some(("servingStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "runtime" => Some(("runtime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["aggregation-window-length", "api-config", "auth-fail-action", "automatic-scaling", "basic-scaling", "beta-settings", "check-interval", "container", "cool-down-period", "cpu", "cpu-utilization", "create-time", "created-by", "default-expiration", "deployment", "disable-health-check", "disk-gb", "disk-usage-bytes", "disk-utilization", "env", "env-variables", "files-count", "forwarded-ports", "health-check", "healthy-threshold", "host", "id", "idle-timeout", "image", "inbound-services", "instance-class", "instance-tag", "instances", "login", "manual-scaling", "max-concurrent-requests", "max-idle-instances", "max-instances", "max-pending-latency", "max-total-instances", "memory-gb", "min-idle-instances", "min-pending-latency", "min-total-instances", "name", "network", "network-utilization", "nobuild-files-regex", "request-utilization", "resources", "restart-threshold", "runtime", "script", "security-level", "serving-status", "source-url", "target-concurrent-requests", "target-read-bytes-per-second", "target-read-ops-per-second", "target-received-bytes-per-second", "target-received-packets-per-second", "target-request-count-per-second", "target-sent-bytes-per-second", "target-sent-packets-per-second", "target-utilization", "target-write-bytes-per-second", "target-write-ops-per-second", "threadsafe", "timeout", "unhealthy-threshold", "url", "version-url", "vm", "zip"]); + 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::Version = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().services_versions_create(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-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 _apps_services_versions_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-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 _apps_services_versions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-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 { + "view" => { + call = call.view(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(["view"].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 _apps_services_versions_instances_debug(&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::DebugInstanceRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().services_versions_instances_debug(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-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 _apps_services_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-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 { + "view" => { + call = call.view(value.unwrap_or("")); + }, + "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", "view"].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 _apps_services_versions_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()[..] { + "basic-scaling.idle-timeout" => Some(("basicScaling.idleTimeout", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "basic-scaling.max-instances" => Some(("basicScaling.maxInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "beta-settings" => Some(("betaSettings", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "vm" => Some(("vm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "instance-class" => Some(("instanceClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version-url" => Some(("versionUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.url" => Some(("apiConfig.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.security-level" => Some(("apiConfig.securityLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.auth-fail-action" => Some(("apiConfig.authFailAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.login" => Some(("apiConfig.login", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "api-config.script" => Some(("apiConfig.script", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "threadsafe" => Some(("threadsafe", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "health-check.restart-threshold" => Some(("healthCheck.restartThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.check-interval" => Some(("healthCheck.checkInterval", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.unhealthy-threshold" => Some(("healthCheck.unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.healthy-threshold" => Some(("healthCheck.healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "health-check.host" => Some(("healthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.timeout" => Some(("healthCheck.timeout", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "health-check.disable-health-check" => Some(("healthCheck.disableHealthCheck", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-expiration" => Some(("defaultExpiration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "env" => Some(("env", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "disk-usage-bytes" => Some(("diskUsageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.min-pending-latency" => Some(("automaticScaling.minPendingLatency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-received-packets-per-second" => Some(("automaticScaling.networkUtilization.targetReceivedPacketsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-sent-packets-per-second" => Some(("automaticScaling.networkUtilization.targetSentPacketsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-received-bytes-per-second" => Some(("automaticScaling.networkUtilization.targetReceivedBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.network-utilization.target-sent-bytes-per-second" => Some(("automaticScaling.networkUtilization.targetSentBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-read-ops-per-second" => Some(("automaticScaling.diskUtilization.targetReadOpsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-write-bytes-per-second" => Some(("automaticScaling.diskUtilization.targetWriteBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-read-bytes-per-second" => Some(("automaticScaling.diskUtilization.targetReadBytesPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.disk-utilization.target-write-ops-per-second" => Some(("automaticScaling.diskUtilization.targetWriteOpsPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.max-pending-latency" => Some(("automaticScaling.maxPendingLatency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.max-idle-instances" => Some(("automaticScaling.maxIdleInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.min-idle-instances" => Some(("automaticScaling.minIdleInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.request-utilization.target-concurrent-requests" => Some(("automaticScaling.requestUtilization.targetConcurrentRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.request-utilization.target-request-count-per-second" => Some(("automaticScaling.requestUtilization.targetRequestCountPerSecond", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.cool-down-period" => Some(("automaticScaling.coolDownPeriod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "automatic-scaling.max-total-instances" => Some(("automaticScaling.maxTotalInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.max-concurrent-requests" => Some(("automaticScaling.maxConcurrentRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.min-total-instances" => Some(("automaticScaling.minTotalInstances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "automatic-scaling.cpu-utilization.target-utilization" => Some(("automaticScaling.cpuUtilization.targetUtilization", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "automatic-scaling.cpu-utilization.aggregation-window-length" => Some(("automaticScaling.cpuUtilization.aggregationWindowLength", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "env-variables" => Some(("envVariables", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "resources.disk-gb" => Some(("resources.diskGb", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "resources.cpu" => Some(("resources.cpu", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "resources.memory-gb" => Some(("resources.memoryGb", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "manual-scaling.instances" => Some(("manualScaling.instances", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "inbound-services" => Some(("inboundServices", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "created-by" => Some(("createdBy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "deployment.container.image" => Some(("deployment.container.image", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "deployment.zip.files-count" => Some(("deployment.zip.filesCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "deployment.zip.source-url" => Some(("deployment.zip.sourceUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-time" => Some(("createTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "network.instance-tag" => Some(("network.instanceTag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "network.forwarded-ports" => Some(("network.forwardedPorts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "network.name" => Some(("network.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nobuild-files-regex" => Some(("nobuildFilesRegex", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "serving-status" => Some(("servingStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "runtime" => Some(("runtime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["aggregation-window-length", "api-config", "auth-fail-action", "automatic-scaling", "basic-scaling", "beta-settings", "check-interval", "container", "cool-down-period", "cpu", "cpu-utilization", "create-time", "created-by", "default-expiration", "deployment", "disable-health-check", "disk-gb", "disk-usage-bytes", "disk-utilization", "env", "env-variables", "files-count", "forwarded-ports", "health-check", "healthy-threshold", "host", "id", "idle-timeout", "image", "inbound-services", "instance-class", "instance-tag", "instances", "login", "manual-scaling", "max-concurrent-requests", "max-idle-instances", "max-instances", "max-pending-latency", "max-total-instances", "memory-gb", "min-idle-instances", "min-pending-latency", "min-total-instances", "name", "network", "network-utilization", "nobuild-files-regex", "request-utilization", "resources", "restart-threshold", "runtime", "script", "security-level", "serving-status", "source-url", "target-concurrent-requests", "target-read-bytes-per-second", "target-read-ops-per-second", "target-received-bytes-per-second", "target-received-packets-per-second", "target-request-count-per-second", "target-sent-bytes-per-second", "target-sent-packets-per-second", "target-utilization", "target-write-bytes-per-second", "target-write-ops-per-second", "threadsafe", "timeout", "unhealthy-threshold", "url", "version-url", "vm", "zip"]); + 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::Version = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().services_versions_patch(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-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 { + "update-mask" => { + call = call.update_mask(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(["update-mask"].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() { + ("apps", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._apps_get(opt, dry_run, &mut err); + }, + ("locations-get", Some(opt)) => { + call_result = self._apps_locations_get(opt, dry_run, &mut err); + }, + ("locations-list", Some(opt)) => { + call_result = self._apps_locations_list(opt, dry_run, &mut err); + }, + ("operations-get", Some(opt)) => { + call_result = self._apps_operations_get(opt, dry_run, &mut err); + }, + ("operations-list", Some(opt)) => { + call_result = self._apps_operations_list(opt, dry_run, &mut err); + }, + ("repair", Some(opt)) => { + call_result = self._apps_repair(opt, dry_run, &mut err); + }, + ("services-delete", Some(opt)) => { + call_result = self._apps_services_delete(opt, dry_run, &mut err); + }, + ("services-get", Some(opt)) => { + call_result = self._apps_services_get(opt, dry_run, &mut err); + }, + ("services-list", Some(opt)) => { + call_result = self._apps_services_list(opt, dry_run, &mut err); + }, + ("services-patch", Some(opt)) => { + call_result = self._apps_services_patch(opt, dry_run, &mut err); + }, + ("services-versions-create", Some(opt)) => { + call_result = self._apps_services_versions_create(opt, dry_run, &mut err); + }, + ("services-versions-delete", Some(opt)) => { + call_result = self._apps_services_versions_delete(opt, dry_run, &mut err); + }, + ("services-versions-get", Some(opt)) => { + call_result = self._apps_services_versions_get(opt, dry_run, &mut err); + }, + ("services-versions-instances-debug", Some(opt)) => { + call_result = self._apps_services_versions_instances_debug(opt, dry_run, &mut err); + }, + ("services-versions-instances-delete", Some(opt)) => { + call_result = self._apps_services_versions_instances_delete(opt, dry_run, &mut err); + }, + ("services-versions-instances-get", Some(opt)) => { + call_result = self._apps_services_versions_instances_get(opt, dry_run, &mut err); + }, + ("services-versions-instances-list", Some(opt)) => { + call_result = self._apps_services_versions_instances_list(opt, dry_run, &mut err); + }, + ("services-versions-list", Some(opt)) => { + call_result = self._apps_services_versions_list(opt, dry_run, &mut err); + }, + ("services-versions-patch", Some(opt)) => { + call_result = self._apps_services_versions_patch(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("apps".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, "appengine1-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: "appengine1", + 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::Appengine::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 = [ + ("apps", "methods: 'get', 'locations-get', 'locations-list', 'operations-get', 'operations-list', 'repair', 'services-delete', 'services-get', 'services-list', 'services-patch', 'services-versions-create', 'services-versions-delete', 'services-versions-get', 'services-versions-instances-debug', 'services-versions-instances-delete', 'services-versions-instances-get', 'services-versions-instances-list', 'services-versions-list' and 'services-versions-patch'", vec![ + ("get", + Some(r##"Gets information about an application."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the Application resource to get. Example: `apps/myapp`."##), + 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)), + ]), + ("locations-get", + Some(r##"Get information about a location."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_locations-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Resource name for the location."##), + Some(true), + Some(false)), + + (Some(r##"locations-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("locations-list", + Some(r##"Lists information about the supported locations for this service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_locations-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. The resource that owns the locations collection, if applicable."##), + 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)), + ]), + ("operations-get", + Some(r##"Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_operations-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. The name of the operation resource."##), + Some(true), + Some(false)), + + (Some(r##"operations-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("operations-list", + Some(r##"Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_operations-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. The name of the operation collection."##), + 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)), + ]), + ("repair", + Some(r##"Recreates the required App Engine features for the application in your project, for example a Cloud Storage bucket or App Engine service account. Use this method if you receive an error message about a missing feature, for example "*Error retrieving the App Engine service account*"."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_repair", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the application to repair. Example: `apps/myapp`"##), + 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)), + ]), + ("services-delete", + Some(r##"Deletes the specified service and all enclosed versions."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-delete", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-get", + Some(r##"Gets the current configuration of the specified service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-list", + Some(r##"Lists all the services in the application."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `parent`. Name of the parent Application resource. Example: `apps/myapp`."##), + 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)), + ]), + ("services-patch", + Some(r##"Updates the configuration of the specified service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-patch", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-create", + Some(r##"Deploys code and resource files to a new version."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-create", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `parent`. Name of the parent resource to create this version under. Example: `apps/myapp/services/default`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `parent`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-delete", + Some(r##"Deletes an existing Version resource."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-delete", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-get", + Some(r##"Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-debug", + Some(r##"Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-instances-debug", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-delete", + Some(r##"Stops a running instance."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-instances-delete", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-get", + Some(r##"Gets instance information."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-instances-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-list", + Some(r##"Lists the instances of a version."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-instances-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `parent`. Name of the parent Version resource. Example: `apps/myapp/services/default/versions/v1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `parent`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `parent`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-list", + Some(r##"Lists the versions of a service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `parent`. Name of the parent Service resource. Example: `apps/myapp/services/default`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `parent`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-patch", + Some(r##"Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_cli/apps_services-versions-patch", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default/versions/1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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("appengine1") + .author("Sebastian Thiel ") + .version("0.3.6+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") + .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/appengine1/Cargo.toml b/gen/appengine1/Cargo.toml new file mode 100644 index 0000000000..215fab8282 --- /dev/null +++ b/gen/appengine1/Cargo.toml @@ -0,0 +1,34 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-appengine1" +version = "0.1.14+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" +homepage = "https://cloud.google.com/appengine/docs/admin-api/" +documentation = "http://byron.github.io/google-apis-rs/google_appengine1" +license = "MIT" +keywords = ["appengine", "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/appengine1/LICENSE.md b/gen/appengine1/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/appengine1/LICENSE.md @@ -0,0 +1,30 @@ + +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/appengine1/README.md b/gen/appengine1/README.md new file mode 100644 index 0000000000..144506413a --- /dev/null +++ b/gen/appengine1/README.md @@ -0,0 +1,187 @@ + +The `google-appengine1` library allows access to all features of the *Google appengine* service. + +This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. + +Everything else about the *appengine* *v1* API can be found at the +[official documentation site](https://cloud.google.com/appengine/docs/admin-api/). +# Features + +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_appengine1/struct.Appengine.html) ... + +* apps + * [*get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppGetCall.html), [*locations get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppLocationGetCall.html), [*locations list*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppLocationListCall.html), [*operations get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppOperationGetCall.html), [*operations list*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppOperationListCall.html), [*repair*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppRepairCall.html), [*services delete*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceDeleteCall.html), [*services get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceGetCall.html), [*services list*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceListCall.html), [*services patch*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServicePatchCall.html), [*services versions create*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionCreateCall.html), [*services versions delete*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionDeleteCall.html), [*services versions get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionGetCall.html), [*services versions instances debug*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionInstanceDebugCall.html), [*services versions instances delete*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionInstanceDeleteCall.html), [*services versions instances get*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionInstanceGetCall.html), [*services versions instances list*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionInstanceListCall.html), [*services versions list*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionListCall.html) and [*services versions patch*](http://byron.github.io/google-apis-rs/google_appengine1/struct.AppServiceVersionPatchCall.html) + + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](http://byron.github.io/google-apis-rs/google_appengine1/struct.Appengine.html)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_appengine1/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_appengine1/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_appengine1/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_appengine1/trait.Part.html)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](http://byron.github.io/google-apis-rs/google_appengine1/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.apps().services_versions_create(...).doit() +let r = hub.apps().services_versions_instances_debug(...).doit() +let r = hub.apps().services_versions_instances_delete(...).doit() +let r = hub.apps().services_versions_patch(...).doit() +let r = hub.apps().operations_get(...).doit() +let r = hub.apps().repair(...).doit() +let r = hub.apps().services_versions_delete(...).doit() +let r = hub.apps().services_patch(...).doit() +let r = hub.apps().services_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-appengine1 = "*" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate yup_oauth2 as oauth2; +extern crate google_appengine1 as appengine1; +use appengine1::DebugInstanceRequest; +use appengine1::{Result, Error}; +use std::default::Default; +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +use appengine1::Appengine; + +// 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 = Appengine::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 = DebugInstanceRequest::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.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") + .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_appengine1/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_appengine1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_appengine1/../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_appengine1/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_appengine1/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_appengine1/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_appengine1/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_appengine1/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_appengine1/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_appengine1/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_appengine1/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_appengine1/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_appengine1/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 **appengine1** 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/appengine1/src/build.rs b/gen/appengine1/src/build.rs new file mode 100644 index 0000000000..0bebaf0bf0 --- /dev/null +++ b/gen/appengine1/src/build.rs @@ -0,0 +1,25 @@ +#[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/appengine1/src/cmn.rs b/gen/appengine1/src/cmn.rs new file mode 100644 index 0000000000..d75063e466 --- /dev/null +++ b/gen/appengine1/src/cmn.rs @@ -0,0 +1,753 @@ +// 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/appengine1/src/lib.rs b/gen/appengine1/src/lib.rs new file mode 100644 index 0000000000..c02610b140 --- /dev/null +++ b/gen/appengine1/src/lib.rs @@ -0,0 +1,197 @@ +// DO NOT EDIT ! +// This file was generated automatically from 'src/mako/api/lib.rs.mako' +// DO NOT EDIT ! + +//! This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! +//! Everything else about the *appengine* *v1* API can be found at the +//! [official documentation site](https://cloud.google.com/appengine/docs/admin-api/). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1). +//! # Features +//! +//! Handle the following *Resources* with ease from the central [hub](struct.Appengine.html) ... +//! +//! * apps +//! * [*get*](struct.AppGetCall.html), [*locations get*](struct.AppLocationGetCall.html), [*locations list*](struct.AppLocationListCall.html), [*operations get*](struct.AppOperationGetCall.html), [*operations list*](struct.AppOperationListCall.html), [*repair*](struct.AppRepairCall.html), [*services delete*](struct.AppServiceDeleteCall.html), [*services get*](struct.AppServiceGetCall.html), [*services list*](struct.AppServiceListCall.html), [*services patch*](struct.AppServicePatchCall.html), [*services versions create*](struct.AppServiceVersionCreateCall.html), [*services versions delete*](struct.AppServiceVersionDeleteCall.html), [*services versions get*](struct.AppServiceVersionGetCall.html), [*services versions instances debug*](struct.AppServiceVersionInstanceDebugCall.html), [*services versions instances delete*](struct.AppServiceVersionInstanceDeleteCall.html), [*services versions instances get*](struct.AppServiceVersionInstanceGetCall.html), [*services versions instances list*](struct.AppServiceVersionInstanceListCall.html), [*services versions list*](struct.AppServiceVersionListCall.html) and [*services versions patch*](struct.AppServiceVersionPatchCall.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.Appengine.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.apps().services_versions_create(...).doit() +//! let r = hub.apps().services_versions_instances_debug(...).doit() +//! let r = hub.apps().services_versions_instances_delete(...).doit() +//! let r = hub.apps().services_versions_patch(...).doit() +//! let r = hub.apps().operations_get(...).doit() +//! let r = hub.apps().repair(...).doit() +//! let r = hub.apps().services_versions_delete(...).doit() +//! let r = hub.apps().services_patch(...).doit() +//! let r = hub.apps().services_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-appengine1 = "*" +//! ``` +//! +//! ## A complete example +//! +//! ```test_harness,no_run +//! extern crate hyper; +//! extern crate yup_oauth2 as oauth2; +//! extern crate google_appengine1 as appengine1; +//! use appengine1::DebugInstanceRequest; +//! use appengine1::{Result, Error}; +//! # #[test] fn egal() { +//! use std::default::Default; +//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +//! use appengine1::Appengine; +//! +//! // 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 = Appengine::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 = DebugInstanceRequest::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.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") +//! .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/appengine1/src/lib.rs.in b/gen/appengine1/src/lib.rs.in new file mode 100644 index 0000000000..3f1d96e2b3 --- /dev/null +++ b/gen/appengine1/src/lib.rs.in @@ -0,0 +1,6731 @@ +// 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 Appengine related resource activities +/// +/// # Examples +/// +/// Instantiate a new hub +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_appengine1 as appengine1; +/// use appengine1::DebugInstanceRequest; +/// use appengine1::{Result, Error}; +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use appengine1::Appengine; +/// +/// // 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 = Appengine::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 = DebugInstanceRequest::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.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") +/// .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 Appengine { + client: RefCell, + auth: RefCell, + _user_agent: String, +} + +impl<'a, C, A> Hub for Appengine {} + +impl<'a, C, A> Appengine + where C: BorrowMut, A: oauth2::GetToken { + + pub fn new(client: C, authenticator: A) -> Appengine { + Appengine { + client: RefCell::new(client), + auth: RefCell::new(authenticator), + _user_agent: "google-api-rust-client/0.1.14".to_string(), + } + } + + pub fn apps(&'a self) -> AppMethods<'a, C, A> { + AppMethods { 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 ### +// ########## +/// Response message for `Instances.ListInstances`. +/// +/// # 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*). +/// +/// * [services versions instances list apps](struct.AppServiceVersionInstanceListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListInstancesResponse { + /// Continuation token for fetching the next page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The instances belonging to the requested version. + pub instances: Option>, +} + +impl ResponseResult for ListInstancesResponse {} + + +/// Extra network settings. Only applicable for VM runtimes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Network { + /// Tag to apply to the VM instance during creation. + #[serde(rename="instanceTag")] + pub instance_tag: Option, + /// List of ports, or port pairs, to forward from the virtual machine to the application container. + #[serde(rename="forwardedPorts")] + pub forwarded_ports: Option>, + /// Google Cloud Platform network where the virtual machines are created. Specify the short name, not the resource path. Defaults to `default`. + pub name: Option, +} + +impl Part for Network {} + + +/// A Service resource is a logical component of an application that can share state and communicate in a secure fashion with other services. For example, an application that handles customer requests might include separate services to handle tasks such as backend data analysis or API requests from mobile devices. Each service has a collection of versions that define a specific set of code used to implement the functionality of that 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*). +/// +/// * [services get apps](struct.AppServiceGetCall.html) (response) +/// * [services patch apps](struct.AppServicePatchCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Service { + /// Mapping that defines fractional HTTP traffic diversion to different versions within the service. + pub split: Option, + /// Relative name of the service within the application. Example: `default`. @OutputOnly + pub id: Option, + /// Full path to the Service resource in the API. Example: `apps/myapp/services/default`. @OutputOnly + pub name: Option, +} + +impl RequestValue for Service {} +impl ResponseResult for Service {} + + +/// Request message for 'Applications.RepairApplication'. +/// +/// # 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*). +/// +/// * [repair apps](struct.AppRepairCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RepairApplicationRequest; + +impl RequestValue for RepairApplicationRequest {} + + +/// An Application resource contains the top-level configuration of an App Engine application. +/// +/// # 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 apps](struct.AppGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Application { + /// Hostname used to reach this application, as resolved by App Engine. @OutputOnly + #[serde(rename="defaultHostname")] + pub default_hostname: Option, + /// Full path to the Application resource in the API. Example: `apps/myapp`. @OutputOnly + pub name: Option, + /// Google Cloud Storage bucket that can be used for storing files associated with this application. This bucket is associated with the application and can be used by the gcloud deployment commands. @OutputOnly + #[serde(rename="codeBucket")] + pub code_bucket: Option, + /// Google Cloud Storage bucket that can be used by this application to store content. @OutputOnly + #[serde(rename="defaultBucket")] + pub default_bucket: Option, + /// HTTP path dispatch rules for requests to the application that do not explicitly target a service or version. Rules are order-dependent. @OutputOnly + #[serde(rename="dispatchRules")] + pub dispatch_rules: Option>, + /// Cookie expiration policy for this application. @OutputOnly + #[serde(rename="defaultCookieExpiration")] + pub default_cookie_expiration: Option, + /// Location from which this application will be run. Application instances will run out of data centers in the chosen location, which is also where all of the application's end user content is stored. Defaults to `us-central`. Options are: `us-central` - Central US `europe-west` - Western Europe `us-east1` - Eastern US + #[serde(rename="locationId")] + pub location_id: Option, + /// Google Apps authentication domain that controls which users can access this application. Defaults to open access for any Google Account. + #[serde(rename="authDomain")] + pub auth_domain: Option, + /// Identifier of the Application resource. This identifier is equivalent to the project ID of the Google Cloud Platform project where you want to deploy your application. Example: `myapp`. + pub id: Option, +} + +impl ResponseResult for Application {} + + +/// A Version resource is a specific set of source code and configuration files that are deployed into a 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*). +/// +/// * [services versions get apps](struct.AppServiceVersionGetCall.html) (response) +/// * [services versions create apps](struct.AppServiceVersionCreateCall.html) (request) +/// * [services versions patch apps](struct.AppServiceVersionPatchCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Version { + /// A service with basic scaling will create an instance when the application receives a request. The instance will be turned down when the app becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. + #[serde(rename="basicScaling")] + pub basic_scaling: Option, + /// Full path to the Version resource in the API. Example: `apps/myapp/services/default/versions/v1`. @OutputOnly + pub name: Option, + /// Metadata settings that are supplied to this version to enable beta runtime features. + #[serde(rename="betaSettings")] + pub beta_settings: Option>, + /// A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. + #[serde(rename="manualScaling")] + pub manual_scaling: Option, + /// Whether to deploy this version in a container on a virtual machine. + pub vm: Option, + /// Time that this version was created. @OutputOnly + #[serde(rename="createTime")] + pub create_time: Option, + /// Before an application can receive email or XMPP messages, the application must be configured to enable the service. + #[serde(rename="inboundServices")] + pub inbound_services: Option>, + /// Instance class that is used to run this version. Valid values are: * AutomaticScaling: `F1`, `F2`, `F4`, `F4_1G` * ManualScaling or BasicScaling: `B1`, `B2`, `B4`, `B8`, `B4_1G` Defaults to `F1` for AutomaticScaling and `B1` for ManualScaling or BasicScaling. + #[serde(rename="instanceClass")] + pub instance_class: Option, + /// Email address of the user who created this version. @OutputOnly + #[serde(rename="createdBy")] + pub created_by: Option, + /// Code and application artifacts that make up this version. Only returned in `GET` requests if `view=FULL` is set. + pub deployment: Option, + /// Custom static error pages. Limited to 10KB per page. Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="errorHandlers")] + pub error_handlers: Option>, + /// Current serving status of this version. Only the versions with a `SERVING` status create instances and can be billed. `SERVING_STATUS_UNSPECIFIED` is an invalid value. Defaults to `SERVING`. + #[serde(rename="servingStatus")] + pub serving_status: Option, + /// Relative name of the version within the service. Example: `v1`. Version names can contain only lowercase letters, numbers, or hyphens. Reserved names: "default", "latest", and any name with the prefix "ah-". + pub id: Option, + /// Extra network settings. Only applicable for VM runtimes. + pub network: Option, + /// Serving configuration for [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/). Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="apiConfig")] + pub api_config: Option, + /// Files that match this pattern will not be built into this version. Only applicable for Go runtimes. Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="nobuildFilesRegex")] + pub nobuild_files_regex: Option, + /// Whether multiple requests can be dispatched to this version at once. + pub threadsafe: Option, + /// An ordered list of URL-matching patterns that should be applied to incoming requests. The first matching URL handles the request and other request handlers are not attempted. Only returned in `GET` requests if `view=FULL` is set. + pub handlers: Option>, + /// Configures health checking for VM instances. Unhealthy instances are stopped and replaced with new instances. Only applicable for VM runtimes. Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="healthCheck")] + pub health_check: Option, + /// Duration that static files should be cached by web proxies and browsers. Only applicable if the corresponding [StaticFilesHandler](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#staticfileshandler) does not specify its own expiration time. Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="defaultExpiration")] + pub default_expiration: Option, + /// Serving URL for this version. Example: "https://myversion-dot-myservice-dot-myapp.appspot.com" @OutputOnly + #[serde(rename="versionUrl")] + pub version_url: Option, + /// Configuration for third-party Python runtime libraries that are required by the application. Only returned in `GET` requests if `view=FULL` is set. + pub libraries: Option>, + /// App Engine execution environment for this version. Defaults to `standard`. + pub env: Option, + /// Total size in bytes of all the files that are included in this version and curerntly hosted on the App Engine disk. @OutputOnly + #[serde(rename="diskUsageBytes")] + pub disk_usage_bytes: Option, + /// Automatic scaling is based on request rate, response latencies, and other application metrics. + #[serde(rename="automaticScaling")] + pub automatic_scaling: Option, + /// Desired runtime. Example: `python27`. + pub runtime: Option, + /// Environment variables available to the application. Only returned in `GET` requests if `view=FULL` is set. + #[serde(rename="envVariables")] + pub env_variables: Option>, + /// Machine resources for this version. Only applicable for VM runtimes. + pub resources: Option, +} + +impl RequestValue for Version {} +impl ResponseResult for Version {} + + +/// The response message for LocationService.ListLocations. +/// +/// # 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*). +/// +/// * [locations list apps](struct.AppLocationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListLocationsResponse { + /// The standard List next-page token. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// A list of locations that matches the specified filter in the request. + pub locations: Option>, +} + +impl ResponseResult for ListLocationsResponse {} + + +/// A resource that represents Google Cloud Platform location. +/// +/// # 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*). +/// +/// * [locations get apps](struct.AppLocationGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Location { + /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"} + pub labels: Option>, + /// The cononical id for this location. For example: `"us-east1"`. + #[serde(rename="locationId")] + pub location_id: Option, + /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"` + pub name: Option, + /// Service-specific metadata. For example the available capacity at the given location. + pub metadata: Option>, +} + +impl ResponseResult for Location {} + + +/// Request message for `Instances.DebugInstance`. +/// +/// # 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*). +/// +/// * [services versions instances debug apps](struct.AppServiceVersionInstanceDebugCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DebugInstanceRequest; + +impl RequestValue for DebugInstanceRequest {} + + +/// Target scaling by CPU usage. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CpuUtilization { + /// Target CPU utilization ratio to maintain when scaling. Must be between 0 and 1. + #[serde(rename="targetUtilization")] + pub target_utilization: Option, + /// Period of time over which CPU utilization is calculated. + #[serde(rename="aggregationWindowLength")] + pub aggregation_window_length: Option, +} + +impl Part for CpuUtilization {} + + +/// Machine resources for a version. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Resources { + /// Disk size (GB) needed. + #[serde(rename="diskGb")] + pub disk_gb: Option, + /// Number of CPU cores needed. + pub cpu: Option, + /// Memory (GB) needed. + #[serde(rename="memoryGb")] + pub memory_gb: Option, +} + +impl Part for Resources {} + + +/// 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 {} + + +/// A service with basic scaling will create an instance when the application receives a request. The instance will be turned down when the app becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct BasicScaling { + /// Duration of time after the last request that an instance must wait before the instance is shut down. + #[serde(rename="idleTimeout")] + pub idle_timeout: Option, + /// Maximum number of instances to create for this version. + #[serde(rename="maxInstances")] + pub max_instances: Option, +} + +impl Part for BasicScaling {} + + +/// Files served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct StaticFilesHandler { + /// MIME type used to serve all files served by this handler. Defaults to file-specific MIME types, which are derived from each file's filename extension. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// Time a static file served by this handler should be cached by web proxies and browsers. + pub expiration: Option, + /// Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. + pub path: Option, + /// Regular expression that matches the file paths for all files that should be referenced by this handler. + #[serde(rename="uploadPathRegex")] + pub upload_path_regex: Option, + /// Whether this handler should match the request if the file referenced by the handler does not exist. + #[serde(rename="requireMatchingFile")] + pub require_matching_file: Option, + /// HTTP headers to use for all responses from these URLs. + #[serde(rename="httpHeaders")] + pub http_headers: Option>, + /// Whether files should also be uploaded as code data. By default, files declared in static file handlers are uploaded as static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged against both your code and static data storage resource quotas. + #[serde(rename="applicationReadable")] + pub application_readable: Option, +} + +impl Part for StaticFilesHandler {} + + +/// Target scaling by network usage. Only applicable for VM runtimes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct NetworkUtilization { + /// Target packets received per second. + #[serde(rename="targetReceivedPacketsPerSecond")] + pub target_received_packets_per_second: Option, + /// Target packets sent per second. + #[serde(rename="targetSentPacketsPerSecond")] + pub target_sent_packets_per_second: Option, + /// Target bytes received per second. + #[serde(rename="targetReceivedBytesPerSecond")] + pub target_received_bytes_per_second: Option, + /// Target bytes sent per second. + #[serde(rename="targetSentBytesPerSecond")] + pub target_sent_bytes_per_second: Option, +} + +impl Part for NetworkUtilization {} + + +/// Response message for `Versions.ListVersions`. +/// +/// # 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*). +/// +/// * [services versions list apps](struct.AppServiceVersionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListVersionsResponse { + /// Continuation token for fetching the next page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The versions belonging to the requested service. + pub versions: Option>, +} + +impl ResponseResult for ListVersionsResponse {} + + +/// Response message for `Services.ListServices`. +/// +/// # 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*). +/// +/// * [services list apps](struct.AppServiceListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListServicesResponse { + /// The services belonging to the requested application. + pub services: Option>, + /// Continuation token for fetching the next page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl ResponseResult for ListServicesResponse {} + + +/// Executes a script to handle the request that matches the URL pattern. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ScriptHandler { + /// Path to the script from the application root directory. + #[serde(rename="scriptPath")] + pub script_path: Option, +} + +impl Part for ScriptHandler {} + + +/// Rules to match an HTTP request and dispatch that request to a service. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UrlDispatchRule { + /// Pathname within the host. Must start with a "`/`". A single "`*`" can be included at the end of the path. The sum of the lengths of the domain and path may not exceed 100 characters. + pub path: Option, + /// Domain name to match against. The wildcard "`*`" is supported if specified before a period: "`*.`". Defaults to matching all domains: "`*`". + pub domain: Option, + /// Resource ID of a service in this application that should serve the matched request. The service must already exist. Example: `default`. + pub service: Option, +} + +impl Part for UrlDispatchRule {} + + +/// Uses Google Cloud Endpoints to handle requests. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ApiEndpointHandler { + /// Path to the script from the application root directory. + #[serde(rename="scriptPath")] + pub script_path: Option, +} + +impl Part for ApiEndpointHandler {} + + +/// Health checking configuration for VM instances. Unhealthy instances are killed and replaced with new instances. Only applicable for instances in App Engine flexible environment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct HealthCheck { + /// Number of consecutive successful health checks required before receiving traffic. + #[serde(rename="healthyThreshold")] + pub healthy_threshold: Option, + /// Number of consecutive failed health checks required before an instance is restarted. + #[serde(rename="restartThreshold")] + pub restart_threshold: Option, + /// Time before the health check is considered failed. + pub timeout: Option, + /// Interval between health checks. + #[serde(rename="checkInterval")] + pub check_interval: Option, + /// Whether to explicitly disable health checks for this instance. + #[serde(rename="disableHealthCheck")] + pub disable_health_check: Option, + /// Host header to send when performing an HTTP health check. Example: "myapp.appspot.com" + pub host: Option, + /// Number of consecutive failed health checks required before removing traffic. + #[serde(rename="unhealthyThreshold")] + pub unhealthy_threshold: Option, +} + +impl Part for HealthCheck {} + + +/// Code and application artifacts used to deploy a version to App Engine. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Deployment { + /// Manifest of the files stored in Google Cloud Storage that are included as part of this version. All files must be readable using the credentials supplied with this call. + pub files: Option>, + /// A Docker image that App Engine uses to run the version. Only applicable for instances in App Engine flexible environment. + pub container: Option, + /// The zip file for this deployment, if this is a zip deployment. + pub zip: Option, +} + +impl Part for Deployment {} + + +/// Custom static error page to be served when an error occurs. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ErrorHandler { + /// Error condition this handler applies to. + #[serde(rename="errorCode")] + pub error_code: Option, + /// MIME type of file. Defaults to `text/html`. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// Static file content to be served for this error. + #[serde(rename="staticFile")] + pub static_file: Option, +} + +impl Part for ErrorHandler {} + + +/// Automatic scaling is based on request rate, response latencies, and other application metrics. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AutomaticScaling { + /// Target scaling by CPU usage. + #[serde(rename="cpuUtilization")] + pub cpu_utilization: Option, + /// Target scaling by network usage. + #[serde(rename="networkUtilization")] + pub network_utilization: Option, + /// Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a service. + #[serde(rename="minIdleInstances")] + pub min_idle_instances: Option, + /// Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it. + #[serde(rename="maxPendingLatency")] + pub max_pending_latency: Option, + /// Maximum number of idle instances that should be maintained for this version. + #[serde(rename="maxIdleInstances")] + pub max_idle_instances: Option, + /// Target scaling by disk usage. + #[serde(rename="diskUtilization")] + pub disk_utilization: Option, + /// Target scaling by request utilization. + #[serde(rename="requestUtilization")] + pub request_utilization: Option, + /// Amount of time that the [Autoscaler](https://cloud.google.com/compute/docs/autoscaler/) should wait between changes to the number of virtual machines. Only applicable for VM runtimes. + #[serde(rename="coolDownPeriod")] + pub cool_down_period: Option, + /// Maximum number of instances that should be started to handle requests. + #[serde(rename="maxTotalInstances")] + pub max_total_instances: Option, + /// Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Defaults to a runtime-specific value. + #[serde(rename="maxConcurrentRequests")] + pub max_concurrent_requests: Option, + /// Minimum number of instances that should be maintained for this version. + #[serde(rename="minTotalInstances")] + pub min_total_instances: Option, + /// Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it. + #[serde(rename="minPendingLatency")] + pub min_pending_latency: Option, +} + +impl Part for AutomaticScaling {} + + +/// URL pattern and description of how the URL should be handled. App Engine can handle URLs by executing application code or by serving static files uploaded with the version, such as images, CSS, or JavaScript. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UrlMap { + /// Security (HTTPS) enforcement for this URL. + #[serde(rename="securityLevel")] + pub security_level: Option, + /// Action to take when users access resources that require authentication. Defaults to `redirect`. + #[serde(rename="authFailAction")] + pub auth_fail_action: Option, + /// URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings. All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. + #[serde(rename="urlRegex")] + pub url_regex: Option, + /// Executes a script to handle the request that matches this URL pattern. + pub script: Option, + /// Returns the contents of a file, such as an image, as the response. + #[serde(rename="staticFiles")] + pub static_files: Option, + /// Uses API Endpoints to handle requests. + #[serde(rename="apiEndpoint")] + pub api_endpoint: Option, + /// Level of login required to access this resource. + pub login: Option, + /// `30x` code to use when performing redirects for the `secure` field. Defaults to `302`. + #[serde(rename="redirectHttpResponseCode")] + pub redirect_http_response_code: Option, +} + +impl Part for UrlMap {} + + +/// Single source file that is part of the version to be deployed. Each source file that is deployed must be specified separately. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FileInfo { + /// The MIME type of the file. Defaults to the value from Google Cloud Storage. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// URL source to use to fetch this file. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. + #[serde(rename="sourceUrl")] + pub source_url: Option, + /// The SHA1 hash of the file, in hex. + #[serde(rename="sha1Sum")] + pub sha1_sum: Option, +} + +impl Part for FileInfo {} + + +/// 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 ZipInfo { + /// An estimate of the number of files in a zip for a zip deployment. If set, must be greater than or equal to the actual number of files. Used for optimizing performance; if not provided, deployment may be slow. + #[serde(rename="filesCount")] + pub files_count: Option, + /// URL of the zip file to deploy from. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. + #[serde(rename="sourceUrl")] + pub source_url: Option, +} + +impl Part for ZipInfo {} + + +/// The response message for Operations.ListOperations. +/// +/// # 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*). +/// +/// * [operations list apps](struct.AppOperationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListOperationsResponse { + /// A list of operations that matches the specified filter in the request. + pub operations: Option>, + /// The standard List next-page token. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl ResponseResult for ListOperationsResponse {} + + +/// An Instance resource is the computing unit that App Engine uses to automatically scale an application. +/// +/// # 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*). +/// +/// * [services versions instances get apps](struct.AppServiceVersionInstanceGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Instance { + /// Number of errors since this instance was started. @OutputOnly + pub errors: Option, + /// Full path to the Instance resource in the API. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. @OutputOnly + pub name: Option, + /// App Engine release this instance is running on. @OutputOnly + #[serde(rename="appEngineRelease")] + pub app_engine_release: Option, + /// Virtual machine ID of this instance. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmId")] + pub vm_id: Option, + /// Total memory in use (bytes). @OutputOnly + #[serde(rename="memoryUsage")] + pub memory_usage: Option, + /// Availability of the instance. @OutputOnly + pub availability: Option, + /// Average latency (ms) over the last minute. @OutputOnly + #[serde(rename="averageLatency")] + pub average_latency: Option, + /// Whether this instance is in debug mode. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmDebugEnabled")] + pub vm_debug_enabled: Option, + /// Time that this instance was started. @OutputOnly + #[serde(rename="startTime")] + pub start_time: Option, + /// Average queries per second (QPS) over the last minute. @OutputOnly + pub qps: Option, + /// Number of requests since this instance was started. @OutputOnly + pub requests: Option, + /// Name of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmName")] + pub vm_name: Option, + /// Relative name of the instance within the version. Example: `instance-1`. @OutputOnly + pub id: Option, + /// Zone where the virtual machine is located. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmZoneName")] + pub vm_zone_name: Option, + /// Status of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmStatus")] + pub vm_status: Option, +} + +impl ResponseResult for Instance {} + + +/// A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManualScaling { + /// Number of instances to assign to the service at the start. This number can later be altered by using the [Modules API](https://cloud.google.com/appengine/docs/python/modules/functions) `set_num_instances()` function. + pub instances: Option, +} + +impl Part for ManualScaling {} + + +/// Traffic routing configuration for versions within a single service. Traffic splits define how traffic directed to the service is assigned to versions. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TrafficSplit { + /// Mechanism used to determine which version a request is sent to. The traffic selection algorithm will be stable for either type until allocations are changed. + #[serde(rename="shardBy")] + pub shard_by: Option, + /// Mapping from version IDs within the service to fractional (0.000, 1] allocations of traffic for that version. Each version can be specified only once, but some versions in the service may not have any traffic allocation. Services that have traffic allocated cannot be deleted until either the service is deleted or their traffic allocation is removed. Allocations must sum to 1. Up to two decimal place precision is supported for IP-based splits and up to three decimal places is supported for cookie-based splits. + pub allocations: Option>, +} + +impl Part for TrafficSplit {} + + +/// [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/) configuration for API handlers. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ApiConfigHandler { + /// URL to serve the endpoint at. + pub url: Option, + /// Security (HTTPS) enforcement for this URL. + #[serde(rename="securityLevel")] + pub security_level: Option, + /// Action to take when users access resources that require authentication. Defaults to `redirect`. + #[serde(rename="authFailAction")] + pub auth_fail_action: Option, + /// Level of login required to access this resource. Defaults to `optional`. + pub login: Option, + /// Path to the script from the application root directory. + pub script: Option, +} + +impl Part for ApiConfigHandler {} + + +/// Third-party Python runtime library that is required by the application. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Library { + /// Version of the library to select, or "latest". + pub version: Option, + /// Name of the library. Example: "django". + pub name: Option, +} + +impl Part for Library {} + + +/// Target scaling by disk usage. Only applicable for VM runtimes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DiskUtilization { + /// Target ops read per seconds. + #[serde(rename="targetReadOpsPerSecond")] + pub target_read_ops_per_second: Option, + /// Target bytes written per second. + #[serde(rename="targetWriteBytesPerSecond")] + pub target_write_bytes_per_second: Option, + /// Target bytes read per second. + #[serde(rename="targetReadBytesPerSecond")] + pub target_read_bytes_per_second: Option, + /// Target ops written per second. + #[serde(rename="targetWriteOpsPerSecond")] + pub target_write_ops_per_second: Option, +} + +impl Part for DiskUtilization {} + + +/// Target scaling by request utilization. Only applicable for VM runtimes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RequestUtilization { + /// Target number of concurrent requests. + #[serde(rename="targetConcurrentRequests")] + pub target_concurrent_requests: Option, + /// Target requests per second. + #[serde(rename="targetRequestCountPerSecond")] + pub target_request_count_per_second: Option, +} + +impl Part for RequestUtilization {} + + +/// Docker image that is used to start a VM container for the version you deploy. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContainerInfo { + /// URI to the hosted container image in a Docker repository. The URI must be fully qualified and include a tag or digest. Examples: "gcr.io/my-project/image:tag" or "gcr.io/my-project/image@digest" + pub image: Option, +} + +impl Part for ContainerInfo {} + + +/// This resource represents a long-running operation that is the result of a network API call. +/// +/// # 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*). +/// +/// * [services versions create apps](struct.AppServiceVersionCreateCall.html) (response) +/// * [services versions instances debug apps](struct.AppServiceVersionInstanceDebugCall.html) (response) +/// * [services versions instances delete apps](struct.AppServiceVersionInstanceDeleteCall.html) (response) +/// * [services versions patch apps](struct.AppServiceVersionPatchCall.html) (response) +/// * [operations get apps](struct.AppOperationGetCall.html) (response) +/// * [repair apps](struct.AppRepairCall.html) (response) +/// * [services versions delete apps](struct.AppServiceVersionDeleteCall.html) (response) +/// * [services patch apps](struct.AppServicePatchCall.html) (response) +/// * [services delete apps](struct.AppServiceDeleteCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Operation { + /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. + pub metadata: Option>, + /// If the value is `false`, it means the operation is still in progress. If true, the operation is completed, and either `error` or `response` is available. + pub done: Option, + /// The normal response of the operation in case of success. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. + pub response: Option>, + /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should have the format of `operations/some/unique/name`. + pub name: Option, + /// The error result of the operation in case of failure. + pub error: Option, +} + +impl ResponseResult for Operation {} + + + +// ################### +// MethodBuilders ### +// ################# + +/// A builder providing access to all methods supported on *app* resources. +/// It is not used directly, but through the `Appengine` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_appengine1 as appengine1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use appengine1::Appengine; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Appengine::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `locations_get(...)`, `locations_list(...)`, `operations_get(...)`, `operations_list(...)`, `repair(...)`, `services_delete(...)`, `services_get(...)`, `services_list(...)`, `services_patch(...)`, `services_versions_create(...)`, `services_versions_delete(...)`, `services_versions_get(...)`, `services_versions_instances_debug(...)`, `services_versions_instances_delete(...)`, `services_versions_instances_get(...)`, `services_versions_instances_list(...)`, `services_versions_list(...)` and `services_versions_patch(...)` +/// // to build up your call. +/// let rb = hub.apps(); +/// # } +/// ``` +pub struct AppMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, +} + +impl<'a, C, A> MethodsBuilder for AppMethods<'a, C, A> {} + +impl<'a, C, A> AppMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Lists the instances of a version. + /// + /// # Arguments + /// + /// * `appsId` - Part of `parent`. Name of the parent Version resource. Example: `apps/myapp/services/default/versions/v1`. + /// * `servicesId` - Part of `parent`. See documentation of `appsId`. + /// * `versionsId` - Part of `parent`. See documentation of `appsId`. + pub fn services_versions_instances_list(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + AppServiceVersionInstanceListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_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: + /// + /// Deploys code and resource files to a new version. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `parent`. Name of the parent resource to create this version under. Example: `apps/myapp/services/default`. + /// * `servicesId` - Part of `parent`. See documentation of `appsId`. + pub fn services_versions_create(&self, request: Version, apps_id: &str, services_id: &str) -> AppServiceVersionCreateCall<'a, C, A> { + AppServiceVersionCreateCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Recreates the required App Engine features for the application in your project, for example a Cloud Storage bucket or App Engine service account. Use this method if you receive an error message about a missing feature, for example "*Error retrieving the App Engine service account*". + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the application to repair. Example: `apps/myapp` + pub fn repair(&self, request: RepairApplicationRequest, apps_id: &str) -> AppRepairCall<'a, C, A> { + AppRepairCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_debug(&self, request: DebugInstanceRequest, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + AppServiceVersionInstanceDebugCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the current configuration of the specified service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + pub fn services_get(&self, apps_id: &str, services_id: &str) -> AppServiceGetCall<'a, C, A> { + AppServiceGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_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 instance. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_delete(&self, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + AppServiceVersionInstanceDeleteCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.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 Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default/versions/1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_patch(&self, request: Version, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionPatchCall<'a, C, A> { + AppServiceVersionPatchCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _update_mask: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists the versions of a service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `parent`. Name of the parent Service resource. Example: `apps/myapp/services/default`. + /// * `servicesId` - Part of `parent`. See documentation of `appsId`. + pub fn services_versions_list(&self, apps_id: &str, services_id: &str) -> AppServiceVersionListCall<'a, C, A> { + AppServiceVersionListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _view: Default::default(), + _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 the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. The name of the operation resource. + /// * `operationsId` - Part of `name`. See documentation of `appsId`. + pub fn operations_get(&self, apps_id: &str, operations_id: &str) -> AppOperationGetCall<'a, C, A> { + AppOperationGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _operations_id: operations_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists all the services in the application. + /// + /// # Arguments + /// + /// * `appsId` - Part of `parent`. Name of the parent Application resource. Example: `apps/myapp`. + pub fn services_list(&self, apps_id: &str) -> AppServiceListCall<'a, C, A> { + AppServiceListCall { + hub: self.hub, + _apps_id: apps_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: + /// + /// Lists information about the supported locations for this service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. The resource that owns the locations collection, if applicable. + pub fn locations_list(&self, apps_id: &str) -> AppLocationListCall<'a, C, A> { + AppLocationListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _page_token: Default::default(), + _page_size: 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: + /// + /// Gets instance information. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_get(&self, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + AppServiceVersionInstanceGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. The name of the operation collection. + pub fn operations_list(&self, apps_id: &str) -> AppOperationListCall<'a, C, A> { + AppOperationListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _page_token: Default::default(), + _page_size: 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 an existing Version resource. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_delete(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionDeleteCall<'a, C, A> { + AppServiceVersionDeleteCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Get information about a location. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Resource name for the location. + /// * `locationsId` - Part of `name`. See documentation of `appsId`. + pub fn locations_get(&self, apps_id: &str, locations_id: &str) -> AppLocationGetCall<'a, C, A> { + AppLocationGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _locations_id: locations_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates the configuration of the specified service. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + pub fn services_patch(&self, request: Service, apps_id: &str, services_id: &str) -> AppServicePatchCall<'a, C, A> { + AppServicePatchCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _update_mask: Default::default(), + _migrate_traffic: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets information about an application. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the Application resource to get. Example: `apps/myapp`. + pub fn get(&self, apps_id: &str) -> AppGetCall<'a, C, A> { + AppGetCall { + hub: self.hub, + _apps_id: apps_id.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 service and all enclosed versions. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + pub fn services_delete(&self, apps_id: &str, services_id: &str) -> AppServiceDeleteCall<'a, C, A> { + AppServiceDeleteCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_get(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionGetCall<'a, C, A> { + AppServiceVersionGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _view: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + + + +// ################### +// CallBuilders ### +// ################# + +/// Lists the instances of a version. +/// +/// A builder for the *services.versions.instances.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_instances_list("appsId", "servicesId", "versionsId") +/// .page_token("erat") +/// .page_size(-35) +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceListCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceListCall<'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, ListInstancesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.versions.instances.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_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", "appsId", "servicesId", "versionsId", "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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId")].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 ["versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `parent`. Name of the parent Version resource. Example: `apps/myapp/services/default/versions/v1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `parent`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `parent`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppServiceVersionInstanceListCall<'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) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceListCall<'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) -> AppServiceVersionInstanceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deploys code and resource files to a new version. +/// +/// A builder for the *services.versions.create* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// use appengine1::Version; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = Version::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.apps().services_versions_create(req, "appsId", "servicesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: Version, + _apps_id: String, + _services_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionCreateCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionCreateCall<'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: "appengine.apps.services.versions.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + for &field in ["alt", "appsId", "servicesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId")].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 ["servicesId", "appsId"].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: Version) -> AppServiceVersionCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `parent`. Name of the parent resource to create this version under. Example: `apps/myapp/services/default`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionCreateCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `parent`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionCreateCall<'a, C, A> { + self._services_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) -> AppServiceVersionCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionCreateCall<'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) -> AppServiceVersionCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Recreates the required App Engine features for the application in your project, for example a Cloud Storage bucket or App Engine service account. Use this method if you receive an error message about a missing feature, for example "*Error retrieving the App Engine service account*". +/// +/// A builder for the *repair* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// use appengine1::RepairApplicationRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = RepairApplicationRequest::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.apps().repair(req, "appsId") +/// .doit(); +/// # } +/// ``` +pub struct AppRepairCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: RepairApplicationRequest, + _apps_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppRepairCall<'a, C, A> {} + +impl<'a, C, A> AppRepairCall<'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: "appengine.apps.repair", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + for &field in ["alt", "appsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}:repair".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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: RepairApplicationRequest) -> AppRepairCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the application to repair. Example: `apps/myapp` + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppRepairCall<'a, C, A> { + self._apps_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) -> AppRepairCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppRepairCall<'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) -> AppRepairCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment. +/// +/// A builder for the *services.versions.instances.debug* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// use appengine1::DebugInstanceRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = DebugInstanceRequest::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.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceDebugCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: DebugInstanceRequest, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceDebugCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceDebugCall<'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: "appengine.apps.services.versions.instances.debug", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}:debug".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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: DebugInstanceRequest) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceDebugCall<'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) -> AppServiceVersionInstanceDebugCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the current configuration of the specified service. +/// +/// A builder for the *services.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_get("appsId", "servicesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceGetCall<'a, C, A> {} + +impl<'a, C, A> AppServiceGetCall<'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, Service)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + for &field in ["alt", "appsId", "servicesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId")].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 ["servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceGetCall<'a, C, A> { + self._services_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) -> AppServiceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceGetCall<'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) -> AppServiceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Stops a running instance. +/// +/// A builder for the *services.versions.instances.delete* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_instances_delete("appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceDeleteCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceDeleteCall<'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: "appengine.apps.services.versions.instances.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceDeleteCall<'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) -> AppServiceVersionInstanceDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. +/// +/// A builder for the *services.versions.patch* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// use appengine1::Version; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = Version::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.apps().services_versions_patch(req, "appsId", "servicesId", "versionsId") +/// .update_mask("duo") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: Version, + _apps_id: String, + _services_id: String, + _versions_id: String, + _update_mask: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionPatchCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionPatchCall<'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: "appengine.apps.services.versions.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + if let Some(value) = self._update_mask { + params.push(("updateMask", value.to_string())); + } + for &field in ["alt", "appsId", "servicesId", "versionsId", "updateMask"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId")].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 ["versionsId", "servicesId", "appsId"].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: Version) -> AppServiceVersionPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default/versions/1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionPatchCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionPatchCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionPatchCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Standard field mask for the set of fields to be updated. + /// + /// Sets the *update mask* query property to the given value. + pub fn update_mask(mut self, new_value: &str) -> AppServiceVersionPatchCall<'a, C, A> { + self._update_mask = 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) -> AppServiceVersionPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionPatchCall<'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) -> AppServiceVersionPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the versions of a service. +/// +/// A builder for the *services.versions.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_list("appsId", "servicesId") +/// .view("Lorem") +/// .page_token("eos") +/// .page_size(-81) +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _view: Option, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionListCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionListCall<'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, ListVersionsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.versions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + if let Some(value) = self._view { + params.push(("view", value.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", "appsId", "servicesId", "view", "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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId")].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 ["servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `parent`. Name of the parent Service resource. Example: `apps/myapp/services/default`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `parent`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionListCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Controls the set of fields returned in the `List` response. + /// + /// Sets the *view* query property to the given value. + pub fn view(mut self, new_value: &str) -> AppServiceVersionListCall<'a, C, A> { + self._view = Some(new_value.to_string()); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppServiceVersionListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppServiceVersionListCall<'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) -> AppServiceVersionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionListCall<'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) -> AppServiceVersionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. +/// +/// A builder for the *operations.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().operations_get("appsId", "operationsId") +/// .doit(); +/// # } +/// ``` +pub struct AppOperationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _operations_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppOperationGetCall<'a, C, A> {} + +impl<'a, C, A> AppOperationGetCall<'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: "appengine.apps.operations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("operationsId", self._operations_id.to_string())); + for &field in ["alt", "appsId", "operationsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/operations/{operationsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{operationsId}", "operationsId")].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 ["operationsId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. The name of the operation resource. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppOperationGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *operations 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 operations_id(mut self, new_value: &str) -> AppOperationGetCall<'a, C, A> { + self._operations_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) -> AppOperationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppOperationGetCall<'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) -> AppOperationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all the services in the application. +/// +/// A builder for the *services.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_list("appsId") +/// .page_token("elitr") +/// .page_size(-97) +/// .doit(); +/// # } +/// ``` +pub struct AppServiceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceListCall<'a, C, A> {} + +impl<'a, C, A> AppServiceListCall<'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, ListServicesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("appsId", self._apps_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", "appsId", "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://appengine.googleapis.com/v1/apps/{appsId}/services".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `parent`. Name of the parent Application resource. Example: `apps/myapp`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppServiceListCall<'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) -> AppServiceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceListCall<'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) -> AppServiceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists information about the supported locations for this service. +/// +/// A builder for the *locations.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().locations_list("appsId") +/// .page_token("labore") +/// .page_size(-39) +/// .filter("dolore") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _filter: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationListCall<'a, C, A> {} + +impl<'a, C, A> AppLocationListCall<'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, ListLocationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_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 { + params.push(("filter", value.to_string())); + } + for &field in ["alt", "appsId", "pageToken", "pageSize", "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://appengine.googleapis.com/v1/apps/{appsId}/locations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. The resource that owns the locations collection, if applicable. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// The standard list page token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The standard list page size. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppLocationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// The standard list filter. + /// + /// Sets the *filter* query property to the given value. + pub fn filter(mut self, new_value: &str) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets instance information. +/// +/// A builder for the *services.versions.instances.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_instances_get("appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceGetCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceGetCall<'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: "appengine.apps.services.versions.instances.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceGetCall<'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) -> AppServiceVersionInstanceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. +/// +/// A builder for the *operations.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().operations_list("appsId") +/// .page_token("et") +/// .page_size(-70) +/// .filter("et") +/// .doit(); +/// # } +/// ``` +pub struct AppOperationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _filter: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppOperationListCall<'a, C, A> {} + +impl<'a, C, A> AppOperationListCall<'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, ListOperationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.operations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_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 { + params.push(("filter", value.to_string())); + } + for &field in ["alt", "appsId", "pageToken", "pageSize", "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://appengine.googleapis.com/v1/apps/{appsId}/operations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. The name of the operation collection. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppOperationListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// The standard list page token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppOperationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The standard list page size. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppOperationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// The standard list filter. + /// + /// Sets the *filter* query property to the given value. + pub fn filter(mut self, new_value: &str) -> AppOperationListCall<'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) -> AppOperationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppOperationListCall<'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) -> AppOperationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing Version resource. +/// +/// A builder for the *services.versions.delete* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_delete("appsId", "servicesId", "versionsId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionDeleteCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionDeleteCall<'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: "appengine.apps.services.versions.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId")].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 ["versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionDeleteCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionDeleteCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionDeleteCall<'a, C, A> { + self._versions_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) -> AppServiceVersionDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionDeleteCall<'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) -> AppServiceVersionDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Get information about a location. +/// +/// A builder for the *locations.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().locations_get("appsId", "locationsId") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _locations_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationGetCall<'a, C, A> {} + +impl<'a, C, A> AppLocationGetCall<'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, Location)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("locationsId", self._locations_id.to_string())); + for &field in ["alt", "appsId", "locationsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/locations/{locationsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{locationsId}", "locationsId")].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 ["locationsId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Resource name for the location. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *locations 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 locations_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._locations_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) -> AppLocationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationGetCall<'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) -> AppLocationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the configuration of the specified service. +/// +/// A builder for the *services.patch* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// use appengine1::Service; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = Service::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.apps().services_patch(req, "appsId", "servicesId") +/// .update_mask("ea") +/// .migrate_traffic(false) +/// .doit(); +/// # } +/// ``` +pub struct AppServicePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: Service, + _apps_id: String, + _services_id: String, + _update_mask: Option, + _migrate_traffic: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServicePatchCall<'a, C, A> {} + +impl<'a, C, A> AppServicePatchCall<'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: "appengine.apps.services.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + if let Some(value) = self._update_mask { + params.push(("updateMask", value.to_string())); + } + if let Some(value) = self._migrate_traffic { + params.push(("migrateTraffic", value.to_string())); + } + for &field in ["alt", "appsId", "servicesId", "updateMask", "migrateTraffic"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId")].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 ["servicesId", "appsId"].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: Service) -> AppServicePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServicePatchCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServicePatchCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Standard field mask for the set of fields to be updated. + /// + /// Sets the *update mask* query property to the given value. + pub fn update_mask(mut self, new_value: &str) -> AppServicePatchCall<'a, C, A> { + self._update_mask = Some(new_value.to_string()); + self + } + /// Set to `true` to gradually shift traffic from one version to another single version. By default, traffic is shifted immediately. For gradual traffic migration, the target version must be located within instances that are configured for both [warmup requests](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#inboundservicetype) and [automatic scaling](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#automaticscaling). You must specify the [`shardBy`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services#shardby) field in the Service resource. Gradual traffic migration is not supported in the App Engine flexible environment. For examples, see [Migrating and Splitting Traffic](https://cloud.google.com/appengine/docs/admin-api/migrating-splitting-traffic). + /// + /// Sets the *migrate traffic* query property to the given value. + pub fn migrate_traffic(mut self, new_value: bool) -> AppServicePatchCall<'a, C, A> { + self._migrate_traffic = 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) -> AppServicePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServicePatchCall<'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) -> AppServicePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets information about an application. +/// +/// A builder for the *get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().get("appsId") +/// .doit(); +/// # } +/// ``` +pub struct AppGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppGetCall<'a, C, A> {} + +impl<'a, C, A> AppGetCall<'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, Application)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + for &field in ["alt", "appsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the Application resource to get. Example: `apps/myapp`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppGetCall<'a, C, A> { + self._apps_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) -> AppGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppGetCall<'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) -> AppGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes the specified service and all enclosed versions. +/// +/// A builder for the *services.delete* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_delete("appsId", "servicesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceDeleteCall<'a, C, A> {} + +impl<'a, C, A> AppServiceDeleteCall<'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: "appengine.apps.services.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + for &field in ["alt", "appsId", "servicesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId")].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 ["servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceDeleteCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceDeleteCall<'a, C, A> { + self._services_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) -> AppServiceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceDeleteCall<'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) -> AppServiceDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource. +/// +/// A builder for the *services.versions.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1 as appengine1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_get("appsId", "servicesId", "versionsId") +/// .view("voluptua.") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _view: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionGetCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionGetCall<'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, Version)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.versions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + if let Some(value) = self._view { + params.push(("view", value.to_string())); + } + for &field in ["alt", "appsId", "servicesId", "versionsId", "view"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId")].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 ["versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionGetCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionGetCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Controls the set of fields returned in the `Get` response. + /// + /// Sets the *view* query property to the given value. + pub fn view(mut self, new_value: &str) -> AppServiceVersionGetCall<'a, C, A> { + self._view = 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) -> AppServiceVersionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionGetCall<'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) -> AppServiceVersionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/appengine1_beta4-cli/Cargo.toml b/gen/appengine1_beta4-cli/Cargo.toml index f3957d2121..666c2d3d95 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+20160314" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "appengine1-beta4" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appengine1_beta4] diff --git a/gen/appengine1_beta4-cli/README.md b/gen/appengine1_beta4-cli/README.md index bb76aa7eaf..9093ef5144 100644 --- a/gen/appengine1_beta4-cli/README.md +++ b/gen/appengine1_beta4-cli/README.md @@ -24,12 +24,15 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *appengine* API at revision *20160314*. The CLI is at version *0.3.6*. +This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *0.3.6*. ```bash appengine1-beta4 [options] apps + create (-r )... [-p ]... [-o ] get [-p ]... [-o ] + locations-get [-p ]... [-o ] + locations-list [-p ]... [-o ] modules-delete [-p ]... [-o ] modules-get [-p ]... [-o ] modules-list [-p ]... [-o ] @@ -37,6 +40,10 @@ appengine1-beta4 [options] modules-versions-create (-r )... [-p ]... [-o ] modules-versions-delete [-p ]... [-o ] modules-versions-get [-p ]... [-o ] + modules-versions-instances-debug (-r )... [-p ]... [-o ] + modules-versions-instances-delete [-p ]... [-o ] + modules-versions-instances-get [-p ]... [-o ] + modules-versions-instances-list [-p ]... [-o ] modules-versions-list [-p ]... [-o ] modules-versions-patch (-r )... [-p ]... [-o ] operations-get [-p ]... [-o ] diff --git a/gen/appengine1_beta4-cli/mkdocs.yml b/gen/appengine1_beta4-cli/mkdocs.yml index 9a2b2c2424..3791b22c21 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+20160314 +site_name: appengine v0.3.6+20160802 site_url: http://byron.github.io/google-apis-rs/google-appengine1_beta4-cli site_description: Write integrating applications with bcore @@ -9,7 +9,10 @@ site_dir: build_html pages: - ['index.md', 'Home'] +- ['apps_create.md', 'Apps', 'Create'] - ['apps_get.md', 'Apps', 'Get'] +- ['apps_locations-get.md', 'Apps', 'Locations Get'] +- ['apps_locations-list.md', 'Apps', 'Locations List'] - ['apps_modules-delete.md', 'Apps', 'Modules Delete'] - ['apps_modules-get.md', 'Apps', 'Modules Get'] - ['apps_modules-list.md', 'Apps', 'Modules List'] @@ -17,6 +20,10 @@ pages: - ['apps_modules-versions-create.md', 'Apps', 'Modules Versions Create'] - ['apps_modules-versions-delete.md', 'Apps', 'Modules Versions Delete'] - ['apps_modules-versions-get.md', 'Apps', 'Modules Versions Get'] +- ['apps_modules-versions-instances-debug.md', 'Apps', 'Modules Versions Instances Debug'] +- ['apps_modules-versions-instances-delete.md', 'Apps', 'Modules Versions Instances Delete'] +- ['apps_modules-versions-instances-get.md', 'Apps', 'Modules Versions Instances Get'] +- ['apps_modules-versions-instances-list.md', 'Apps', 'Modules Versions Instances List'] - ['apps_modules-versions-list.md', 'Apps', 'Modules Versions List'] - ['apps_modules-versions-patch.md', 'Apps', 'Modules Versions Patch'] - ['apps_operations-get.md', 'Apps', 'Operations Get'] diff --git a/gen/appengine1_beta4-cli/src/main.rs b/gen/appengine1_beta4-cli/src/main.rs index f175613167..e71987fc30 100644 --- a/gen/appengine1_beta4-cli/src/main.rs +++ b/gen/appengine1_beta4-cli/src/main.rs @@ -45,6 +45,98 @@ struct Engine<'n> { impl<'n> Engine<'n> { + fn _apps_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()[..] { + "default-hostname" => Some(("defaultHostname", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "code-bucket" => Some(("codeBucket", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-bucket" => Some(("defaultBucket", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-cookie-expiration" => Some(("defaultCookieExpiration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auth-domain" => Some(("authDomain", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["auth-domain", "code-bucket", "default-bucket", "default-cookie-expiration", "default-hostname", "id", "location", "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::Application = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().create(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 _apps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().get(opt.value_of("apps-id").unwrap_or("")); @@ -101,6 +193,120 @@ impl<'n> Engine<'n> { } } + fn _apps_locations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("locations-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 _apps_locations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_list(opt.value_of("apps-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" => { + 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", "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 _apps_modules_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().modules_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or("")); @@ -608,6 +814,253 @@ impl<'n> Engine<'n> { } } + fn _apps_modules_versions_instances_debug(&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::DebugInstanceRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().modules_versions_instances_debug(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_modules_versions_instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().modules_versions_instances_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_modules_versions_instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().modules_versions_instances_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_modules_versions_instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().modules_versions_instances_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or(""), opt.value_of("versions-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 _apps_modules_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().modules_versions_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("modules-id").unwrap_or("")); @@ -936,9 +1389,18 @@ impl<'n> Engine<'n> { match self.opt.subcommand() { ("apps", Some(opt)) => { match opt.subcommand() { + ("create", Some(opt)) => { + call_result = self._apps_create(opt, dry_run, &mut err); + }, ("get", Some(opt)) => { call_result = self._apps_get(opt, dry_run, &mut err); }, + ("locations-get", Some(opt)) => { + call_result = self._apps_locations_get(opt, dry_run, &mut err); + }, + ("locations-list", Some(opt)) => { + call_result = self._apps_locations_list(opt, dry_run, &mut err); + }, ("modules-delete", Some(opt)) => { call_result = self._apps_modules_delete(opt, dry_run, &mut err); }, @@ -960,6 +1422,18 @@ impl<'n> Engine<'n> { ("modules-versions-get", Some(opt)) => { call_result = self._apps_modules_versions_get(opt, dry_run, &mut err); }, + ("modules-versions-instances-debug", Some(opt)) => { + call_result = self._apps_modules_versions_instances_debug(opt, dry_run, &mut err); + }, + ("modules-versions-instances-delete", Some(opt)) => { + call_result = self._apps_modules_versions_instances_delete(opt, dry_run, &mut err); + }, + ("modules-versions-instances-get", Some(opt)) => { + call_result = self._apps_modules_versions_instances_get(opt, dry_run, &mut err); + }, + ("modules-versions-instances-list", Some(opt)) => { + call_result = self._apps_modules_versions_instances_list(opt, dry_run, &mut err); + }, ("modules-versions-list", Some(opt)) => { call_result = self._apps_modules_versions_list(opt, dry_run, &mut err); }, @@ -1064,14 +1538,86 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("apps", "methods: 'get', 'modules-delete', 'modules-get', 'modules-list', 'modules-patch', 'modules-versions-create', 'modules-versions-delete', 'modules-versions-get', 'modules-versions-list', 'modules-versions-patch', 'operations-get' and 'operations-list'", vec![ + ("apps", "methods: 'create', 'get', 'locations-get', 'locations-list', 'modules-delete', 'modules-get', 'modules-list', 'modules-patch', 'modules-versions-create', 'modules-versions-delete', 'modules-versions-get', 'modules-versions-instances-debug', 'modules-versions-instances-delete', 'modules-versions-instances-get', 'modules-versions-instances-list', 'modules-versions-list', 'modules-versions-patch', 'operations-get' and 'operations-list'", vec![ + ("create", + Some(r##"Creates an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project)."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_create", + 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)), + ]), ("get", Some(r##"Gets information about an application."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the application to get. For example: "apps/myapp"."##), + Some(r##"Part of `name`. Name of the application to get. Example: `apps/myapp`."##), + 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)), + ]), + ("locations-get", + Some(r##"Get information about a location."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_locations-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Resource name for the location."##), + Some(true), + Some(false)), + + (Some(r##"locations-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("locations-list", + Some(r##"Lists information about the supported locations for this service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_locations-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. The resource that owns the locations collection, if applicable."##), Some(true), Some(false)), @@ -1088,12 +1634,12 @@ fn main() { Some(false)), ]), ("modules-delete", - Some(r##"Deletes a module and all enclosed versions."##), + Some(r##"Deletes the specified module and all enclosed versions."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-delete", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`."##), Some(true), Some(false)), @@ -1116,12 +1662,12 @@ fn main() { Some(false)), ]), ("modules-get", - Some(r##"Gets the current configuration of the module."##), + Some(r##"Gets the current configuration of the specified module."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`."##), Some(true), Some(false)), @@ -1149,7 +1695,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp`."##), Some(true), Some(false)), @@ -1171,7 +1717,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default"."##), + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default`."##), Some(true), Some(false)), @@ -1200,12 +1746,12 @@ fn main() { Some(false)), ]), ("modules-versions-create", - Some(r##"Deploys new code and resource files to a version."##), + Some(r##"Deploys code and resource files to a new version."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-create", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default"."##), + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default`."##), Some(true), Some(false)), @@ -1239,7 +1785,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default/versions/v1"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`."##), Some(true), Some(false)), @@ -1268,12 +1814,172 @@ fn main() { Some(false)), ]), ("modules-versions-get", - Some(r##"Gets application deployment information."##), + Some(r##"Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default/versions/v1"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`."##), + Some(true), + Some(false)), + + (Some(r##"modules-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("modules-versions-instances-debug", + Some(r##"Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-instances-debug", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"modules-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("modules-versions-instances-delete", + Some(r##"Stops a running instance."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-instances-delete", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"modules-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("modules-versions-instances-get", + Some(r##"Gets instance information."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-instances-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"modules-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("modules-versions-instances-list", + Some(r##"Lists the instances of a version."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-instances-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`."##), Some(true), Some(false)), @@ -1307,7 +2013,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`."##), Some(true), Some(false)), @@ -1330,12 +2036,12 @@ fn main() { Some(false)), ]), ("modules-versions-patch", - Some(r##"Updates an existing version. Note: UNIMPLEMENTED."##), + Some(r##"Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta4_cli/apps_modules-versions-patch", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default/versions/1"."##), + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default/versions/1`."##), Some(true), Some(false)), @@ -1425,7 +2131,7 @@ fn main() { let mut app = App::new("appengine1-beta4") .author("Sebastian Thiel ") - .version("0.3.6+20160314") + .version("0.3.6+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_beta4/Cargo.toml b/gen/appengine1_beta4/Cargo.toml index 6e142c0b47..42c141a7cc 100644 --- a/gen/appengine1_beta4/Cargo.toml +++ b/gen/appengine1_beta4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appengine1_beta4" -version = "0.1.14+20160314" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/appengine1_beta4/README.md b/gen/appengine1_beta4/README.md index cd592ef005..fd48ebdd12 100644 --- a/gen/appengine1_beta4/README.md +++ b/gen/appengine1_beta4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appengine1_beta4` library allows access to all features of the *Google appengine* service. -This documentation was generated from *appengine* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *appengine:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *appengine* *v1_beta4* API can be found at the [official documentation site](https://cloud.google.com/appengine/docs/admin-api/). @@ -14,7 +14,7 @@ Everything else about the *appengine* *v1_beta4* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.Appengine.html) ... * apps - * [*get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppGetCall.html), [*modules delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleDeleteCall.html), [*modules get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleGetCall.html), [*modules list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleListCall.html), [*modules patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModulePatchCall.html), [*modules versions create*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionCreateCall.html), [*modules versions delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionDeleteCall.html), [*modules versions get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionGetCall.html), [*modules versions list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionListCall.html), [*modules versions patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionPatchCall.html), [*operations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppOperationGetCall.html) and [*operations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppOperationListCall.html) + * [*create*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppCreateCall.html), [*get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppGetCall.html), [*locations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppLocationGetCall.html), [*locations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppLocationListCall.html), [*modules delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleDeleteCall.html), [*modules get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleGetCall.html), [*modules list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleListCall.html), [*modules patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModulePatchCall.html), [*modules versions create*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionCreateCall.html), [*modules versions delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionDeleteCall.html), [*modules versions get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionGetCall.html), [*modules versions instances debug*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionInstanceDebugCall.html), [*modules versions instances delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionInstanceDeleteCall.html), [*modules versions instances get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionInstanceGetCall.html), [*modules versions instances list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionInstanceListCall.html), [*modules versions list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionListCall.html), [*modules versions patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppModuleVersionPatchCall.html), [*operations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppOperationGetCall.html) and [*operations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta4/struct.AppOperationListCall.html) @@ -48,6 +48,9 @@ Or specifically ... ```ignore let r = hub.apps().modules_patch(...).doit() +let r = hub.apps().create(...).doit() +let r = hub.apps().modules_versions_instances_delete(...).doit() +let r = hub.apps().modules_versions_instances_debug(...).doit() let r = hub.apps().modules_delete(...).doit() let r = hub.apps().operations_get(...).doit() let r = hub.apps().modules_versions_patch(...).doit() diff --git a/gen/appengine1_beta4/src/lib.rs b/gen/appengine1_beta4/src/lib.rs index 13fa4b6621..778cbbccc7 100644 --- a/gen/appengine1_beta4/src/lib.rs +++ b/gen/appengine1_beta4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *appengine* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *appengine:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *appengine* *v1_beta4* API can be found at the //! [official documentation site](https://cloud.google.com/appengine/docs/admin-api/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Appengine.html) ... //! //! * apps -//! * [*get*](struct.AppGetCall.html), [*modules delete*](struct.AppModuleDeleteCall.html), [*modules get*](struct.AppModuleGetCall.html), [*modules list*](struct.AppModuleListCall.html), [*modules patch*](struct.AppModulePatchCall.html), [*modules versions create*](struct.AppModuleVersionCreateCall.html), [*modules versions delete*](struct.AppModuleVersionDeleteCall.html), [*modules versions get*](struct.AppModuleVersionGetCall.html), [*modules versions list*](struct.AppModuleVersionListCall.html), [*modules versions patch*](struct.AppModuleVersionPatchCall.html), [*operations get*](struct.AppOperationGetCall.html) and [*operations list*](struct.AppOperationListCall.html) +//! * [*create*](struct.AppCreateCall.html), [*get*](struct.AppGetCall.html), [*locations get*](struct.AppLocationGetCall.html), [*locations list*](struct.AppLocationListCall.html), [*modules delete*](struct.AppModuleDeleteCall.html), [*modules get*](struct.AppModuleGetCall.html), [*modules list*](struct.AppModuleListCall.html), [*modules patch*](struct.AppModulePatchCall.html), [*modules versions create*](struct.AppModuleVersionCreateCall.html), [*modules versions delete*](struct.AppModuleVersionDeleteCall.html), [*modules versions get*](struct.AppModuleVersionGetCall.html), [*modules versions instances debug*](struct.AppModuleVersionInstanceDebugCall.html), [*modules versions instances delete*](struct.AppModuleVersionInstanceDeleteCall.html), [*modules versions instances get*](struct.AppModuleVersionInstanceGetCall.html), [*modules versions instances list*](struct.AppModuleVersionInstanceListCall.html), [*modules versions list*](struct.AppModuleVersionListCall.html), [*modules versions patch*](struct.AppModuleVersionPatchCall.html), [*operations get*](struct.AppOperationGetCall.html) and [*operations list*](struct.AppOperationListCall.html) //! //! //! @@ -48,6 +48,9 @@ //! //! ```ignore //! let r = hub.apps().modules_patch(...).doit() +//! let r = hub.apps().create(...).doit() +//! let r = hub.apps().modules_versions_instances_delete(...).doit() +//! let r = hub.apps().modules_versions_instances_debug(...).doit() //! let r = hub.apps().modules_delete(...).doit() //! let r = hub.apps().operations_get(...).doit() //! let r = hub.apps().modules_versions_patch(...).doit() @@ -105,8 +108,8 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.apps().modules_patch(req, "appsId", "modulesId") -//! .migrate_traffic(false) -//! .mask("sea") +//! .migrate_traffic(true) +//! .mask("sit") //! .doit(); //! //! match result { diff --git a/gen/appengine1_beta4/src/lib.rs.in b/gen/appengine1_beta4/src/lib.rs.in index 44a73754a6..bc28fe5ab1 100644 --- a/gen/appengine1_beta4/src/lib.rs.in +++ b/gen/appengine1_beta4/src/lib.rs.in @@ -158,66 +158,89 @@ impl<'a, C, A> Appengine // ############ // SCHEMAS ### // ########## -/// Used to specify extra network settings (for VM runtimes only). -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Network { - /// A tag to apply to the VM instance during creation. - #[serde(rename="instanceTag")] - pub instance_tag: Option, - /// A list of ports (or port pairs) to forward from the VM into the app container. - #[serde(rename="forwardedPorts")] - pub forwarded_ports: Option>, - /// The Google Compute Engine network where the VMs will be created. If not specified, or empty, the network named "default" will be used. (The short name should be specified, not the resource path.) - pub name: Option, -} - -impl Part for Network {} - - -/// An Application contains the top-level configuration of an App Engine application. +/// Response message for `Instances.ListInstances`. /// /// # 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*). /// +/// * [modules versions instances list apps](struct.AppModuleVersionInstanceListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListInstancesResponse { + /// Continuation token for fetching the next page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The instances belonging to the requested version. + pub instances: Option>, +} + +impl ResponseResult for ListInstancesResponse {} + + +/// Extra network settings. Only applicable for VM runtimes. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Network { + /// Tag to apply to the VM instance during creation. + #[serde(rename="instanceTag")] + pub instance_tag: Option, + /// List of ports, or port pairs, to forward from the virtual machine to the application container. + #[serde(rename="forwardedPorts")] + pub forwarded_ports: Option>, + /// Google Cloud Platform network where the virtual machines are created. Specify the short name, not the resource path. Defaults to `default`. + pub name: Option, +} + +impl Part for Network {} + + +/// An Application resource contains the top-level configuration of an App Engine application. +/// +/// # 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*). +/// +/// * [create apps](struct.AppCreateCall.html) (request) /// * [get apps](struct.AppGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Application { - /// The hostname used to reach the application, as resolved by App Engine. @OutputOnly + /// Hostname used to reach the application, as resolved by App Engine. @OutputOnly #[serde(rename="defaultHostname")] pub default_hostname: Option, - /// The full path to the application in the API. Example: "apps/myapp". @OutputOnly + /// Full path to the Application resource in the API. Example: `apps/myapp`. @OutputOnly pub name: Option, - /// A Google Cloud Storage bucket which can be used for storing files associated with an application. This bucket is associated with the application and can be used by the gcloud deployment commands. @OutputOnly + /// Google Cloud Storage bucket that can be used for storing files associated with this application. This bucket is associated with the application and can be used by the gcloud deployment commands. @OutputOnly #[serde(rename="codeBucket")] pub code_bucket: Option, - /// A Google Cloud Storage bucket which can be used by the application to store content. @OutputOnly + /// Google Cloud Storage bucket that can be used by this application to store content. @OutputOnly #[serde(rename="defaultBucket")] pub default_bucket: Option, - /// HTTP path dispatch rules for requests to the app that do not explicitly target a module or version. The rules are order-dependent. @OutputOnly + /// HTTP path dispatch rules for requests to the application that do not explicitly target a module or version. Rules are order-dependent. @OutputOnly #[serde(rename="dispatchRules")] pub dispatch_rules: Option>, - /// Determines the cookie expiration policy for the application. @OutputOnly + /// Cookie expiration policy for this application. @OutputOnly #[serde(rename="defaultCookieExpiration")] pub default_cookie_expiration: Option, - /// The location from which the application will be run. Application instances will run out of data centers in the chosen location and all of the application's End User Content will be stored at rest. The default is "us-central". Choices are: "us-central" - Central US "europe-west" - Western Europe "us-east1" - Eastern US + /// Location from which this application will be run. Application instances will run out of data centers in the chosen location, which is also where all of the application's end user content is stored. Defaults to `us-central`. Options are: `us-central` - Central US `europe-west` - Western Europe `us-east1` - Eastern US pub location: Option, - /// If set, only users from the specified Google Apps authentication domain may access the application. If not set, any Google Account may access the application. + /// Google Apps authentication domain that controls which users can access this application. Defaults to open access for any Google Account. #[serde(rename="authDomain")] pub auth_domain: Option, - /// The relative name/path of the application. Example: "myapp". + /// Identifier of the Application resource. This identifier is equivalent to the project ID of the Google Cloud Platform project where you want to deploy your application. Example: `myapp`. pub id: Option, } +impl RequestValue for Application {} impl ResponseResult for Application {} -/// A Version is a specific set of source code and configuration files deployed to a module. +/// A Version resource is a specific set of source code and configuration files that are deployed into a module. /// /// # Activities /// @@ -233,68 +256,68 @@ pub struct Version { /// A module with basic scaling will create an instance when the application receives a request. The instance will be turned down when the app becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. #[serde(rename="basicScaling")] pub basic_scaling: Option, - /// Beta settings supplied to the application via metadata. + /// Metadata settings that are supplied to this version to enable beta runtime features. #[serde(rename="betaSettings")] pub beta_settings: Option>, /// A module with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. #[serde(rename="manualScaling")] pub manual_scaling: Option, - /// Creation time of this version. This will be between the start and end times of the operation that creates this version. @OutputOnly + /// Time that this version was created. @OutputOnly #[serde(rename="creationTime")] pub creation_time: Option, - /// Whether to deploy this app in a VM container. + /// Whether to deploy this version in a container on a virtual machine. pub vm: Option, /// Before an application can receive email or XMPP messages, the application must be configured to enable the service. #[serde(rename="inboundServices")] pub inbound_services: Option>, - /// The frontend instance class to use to run this app. Valid values are `[F1, F2, F4, F4_1G]`. Default: "F1" + /// Instance class that is used to run this version. Valid values are: * AutomaticScaling: `F1`, `F2`, `F4`, `F4_1G` * ManualScaling or BasicScaling: `B1`, `B2`, `B4`, `B8`, `B4_1G` Defaults to `F1` for AutomaticScaling and `B1` for ManualScaling or BasicScaling. #[serde(rename="instanceClass")] pub instance_class: Option, - /// Code and application artifacts that make up this version. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Code and application artifacts that make up this version. Only returned in `GET` requests if `view=FULL` is set. pub deployment: Option, - /// Custom static error pages instead of these generic error pages, (limit 10 KB/page) Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Custom static error pages. Limited to 10KB per page. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="errorHandlers")] pub error_handlers: Option>, - /// The current serving status of this version. Only `SERVING` versions will have instances created or billed for. If this field is unset when a version is created, `SERVING` status will be assumed. It is an error to explicitly set this field to `SERVING_STATUS_UNSPECIFIED`. + /// Current serving status of this version. Only the versions with a `SERVING` status create instances and can be billed. `SERVING_STATUS_UNSPECIFIED` is an invalid value. Defaults to `SERVING`. #[serde(rename="servingStatus")] pub serving_status: Option, - /// The relative name/path of the Version within the module. Example: "v1". Version specifiers can contain lowercase letters, digits, and hyphens. It cannot begin with the prefix `ah-` and the names `default` and `latest` are reserved and cannot be used. + /// Relative name of the version within the module. Example: `v1`. Version names can contain only lowercase letters, numbers, or hyphens. Reserved names: "default", "latest", and any name with the prefix "ah-". pub id: Option, - /// If true, multiple requests can be dispatched to the app at once. + /// Whether multiple requests can be dispatched to this version at once. pub threadsafe: Option, - /// Serving configuration for Google Cloud Endpoints. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Serving configuration for [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/). Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="apiConfig")] pub api_config: Option, - /// Go only. Files that match this pattern will not be built into the app. May only be set on create requests. + /// Files that match this pattern will not be built into this version. Only applicable for Go runtimes. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="nobuildFilesRegex")] pub nobuild_files_regex: Option, - /// Used to specify extra network settings (for VM runtimes only). + /// Extra network settings. Only applicable for VM runtimes. pub network: Option, - /// An ordered list of URL Matching patterns that should be applied to incoming requests. The first matching URL consumes the request, and subsequent handlers are not attempted. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// An ordered list of URL-matching patterns that should be applied to incoming requests. The first matching URL handles the request and other request handlers are not attempted. Only returned in `GET` requests if `view=FULL` is set. pub handlers: Option>, - /// Configure health checking for the VM instances. Unhealthy VM instances will be stopped and replaced with new instances. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Configures health checking for VM instances. Unhealthy instances are stopped and replaced with new instances. Only applicable for VM runtimes. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="healthCheck")] pub health_check: Option, - /// The length of time a static file served by a static file handler ought to be cached by web proxies and browsers, if the handler does not specify its own expiration. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Duration that static files should be cached by web proxies and browsers. Only applicable if the corresponding [StaticFilesHandler](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#staticfileshandler) does not specify its own expiration time. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="defaultExpiration")] pub default_expiration: Option, - /// The full path to the Version resource in the API. Example: "apps/myapp/modules/default/versions/v1". @OutputOnly + /// Full path to the Version resource in the API. Example: `apps/myapp/modules/default/versions/v1`. @OutputOnly pub name: Option, - /// Configuration for Python runtime third-party libraries required by the application. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Configuration for third-party Python runtime libraries required by the application. Only returned in `GET` requests if `view=FULL` is set. pub libraries: Option>, - /// The email address of the user who created this version. @OutputOnly + /// Email address of the user who created this version. @OutputOnly pub deployer: Option, - /// The App Engine execution environment to use for this version. Default: "1" + /// App Engine execution environment to use for this version. Defaults to `1`. pub env: Option, - /// Automatic scaling is the scaling policy that App Engine has used since its inception. It is based on request rate, response latencies, and other application metrics. + /// Automatic scaling is based on request rate, response latencies, and other application metrics. #[serde(rename="automaticScaling")] pub automatic_scaling: Option, - /// The desired runtime. Values can include python27, java7, go, etc. + /// Desired runtime. Example: `python27`. pub runtime: Option, - /// Environment variables made available to the application. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Environment variables made available to the application. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="envVariables")] pub env_variables: Option>, - /// Used to specify how many machine resources an app version needs (for VM runtimes only). + /// Machine resources for this version. Only applicable for VM runtimes. pub resources: Option, } @@ -302,31 +325,67 @@ impl RequestValue for Version {} impl ResponseResult for Version {} -/// A Python runtime third-party library required by the application. +/// The response message for LocationService.ListLocations. +/// +/// # 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*). +/// +/// * [locations list apps](struct.AppLocationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListLocationsResponse { + /// The standard List next-page token. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// A list of locations that matches the specified filter in the request. + pub locations: Option>, +} + +impl ResponseResult for ListLocationsResponse {} + + +/// Third-party Python runtime library that is required by the application. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Library { - /// The version of the library to select, or "latest". + /// Version of the library to select, or "latest". pub version: Option, - /// The name of the library, e.g. "PIL" or "django". + /// Name of the library. Example: "django". pub name: Option, } impl Part for Library {} +/// Request message for `Instances.DebugInstance`. +/// +/// # 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*). +/// +/// * [modules versions instances debug apps](struct.AppModuleVersionInstanceDebugCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DebugInstanceRequest; + +impl RequestValue for DebugInstanceRequest {} + + /// Target scaling by CPU usage. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CpuUtilization { - /// Target (0-1) CPU utilization ratio to maintain when scaling. + /// Target CPU utilization ratio to maintain when scaling. Must be between 0 and 1. #[serde(rename="targetUtilization")] pub target_utilization: Option, - /// The period of time over which CPU utilization is calculated. + /// Period of time over which CPU utilization is calculated. #[serde(rename="aggregationWindowLength")] pub aggregation_window_length: Option, } @@ -334,18 +393,18 @@ pub struct CpuUtilization { impl Part for CpuUtilization {} -/// Used to specify how many machine resources an app version needs. +/// Machine resources for a version. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Resources { - /// How much disk size, in GB, an app version needs. + /// Disk size (GB) needed. #[serde(rename="diskGb")] pub disk_gb: Option, - /// How many CPU cores an app version needs. + /// Number of CPU cores needed. pub cpu: Option, - /// How much memory, in GB, an app version needs. + /// Memory (GB) needed. #[serde(rename="memoryGb")] pub memory_gb: Option, } @@ -397,10 +456,10 @@ impl Part for Status {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BasicScaling { - /// The instance will be shut down this amount of time after receiving its last request. + /// Duration of time after the last request that an instance must wait before the instance is shut down. #[serde(rename="idleTimeout")] pub idle_timeout: Option, - /// The maximum number of instances for App Engine to create for this version. + /// Maximum number of instances to create for this version. #[serde(rename="maxInstances")] pub max_instances: Option, } @@ -414,23 +473,23 @@ impl Part for BasicScaling {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StaticFilesHandler { - /// If specified, all files served by this handler will be served using the specified MIME type. If not specified, the MIME type for a file will be derived from the file's filename extension. + /// MIME type used to serve all files served by this handler. Defaults to file-specific MIME types, which are derived from each file's filename extension. #[serde(rename="mimeType")] pub mime_type: Option, - /// The length of time a static file served by this handler ought to be cached by web proxies and browsers. + /// Time a static file served by this handler should be cached. pub expiration: Option, - /// The path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. + /// Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. pub path: Option, - /// A regular expression that matches the file paths for all files that will be referenced by this handler. + /// Regular expression that matches the file paths for all files that should be referenced by this handler. #[serde(rename="uploadPathRegex")] pub upload_path_regex: Option, - /// If true, this UrlMap entry does not match the request unless the file referenced by the handler also exists. If no such file exists, processing will continue with the next UrlMap that matches the requested URL. + /// Whether this handler should match the request if the file referenced by the handler does not exist. #[serde(rename="requireMatchingFile")] pub require_matching_file: Option, /// HTTP headers to use for all responses from these URLs. #[serde(rename="httpHeaders")] pub http_headers: Option>, - /// By default, files declared in static file handlers are uploaded as static data and are only served to end users, they cannot be read by an application. If this field is set to true, the files are also uploaded as code data so your application can read them. Both uploads are charged against your code and static data storage resource quotas. + /// Whether files should also be uploaded as code data. By default, files declared in static file handlers are uploaded as static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged against both your code and static data storage resource quotas. #[serde(rename="applicationReadable")] pub application_readable: Option, } @@ -438,22 +497,22 @@ pub struct StaticFilesHandler { impl Part for StaticFilesHandler {} -/// Target scaling by network usage (for VM runtimes only). +/// Target scaling by network usage. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkUtilization { - /// Target bytes per second received. + /// Target bytes received per second. #[serde(rename="targetReceivedBytesPerSec")] pub target_received_bytes_per_sec: Option, - /// Target bytes per second sent. + /// Target bytes sent per second. #[serde(rename="targetSentBytesPerSec")] pub target_sent_bytes_per_sec: Option, - /// Target packets per second sent. + /// Target packets sent per second. #[serde(rename="targetSentPacketsPerSec")] pub target_sent_packets_per_sec: Option, - /// Target packets per second received. + /// Target packets received per second. #[serde(rename="targetReceivedPacketsPerSec")] pub target_received_packets_per_sec: Option, } @@ -475,7 +534,7 @@ pub struct ListVersionsResponse { /// Continuation token for fetching the next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// The versions belonging to the requested application module. + /// The versions belonging to the requested module. pub versions: Option>, } @@ -488,12 +547,12 @@ impl ResponseResult for ListVersionsResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Deployment { - /// A manifest of files stored in Google Cloud Storage which should be included as part of this application. All files must be readable using the credentials supplied with this call. + /// Manifest of the files stored in Google Cloud Storage that are included as part of this version. All files must be readable using the credentials supplied with this call. pub files: Option>, - /// The origin of the source code for this deployment. There can be more than one source reference per Version if source code is distributed among multiple repositories. + /// Origin of the source code for this deployment. There can be more than one source reference per version if source code is distributed among multiple repositories. #[serde(rename="sourceReferences")] pub source_references: Option>, - /// If supplied, a docker (container) image which should be used to start the application. Only applicable to the 'vm' runtime. + /// A Docker image that App Engine uses the run the version. Only applicable for instances in App Engine flexible environment. pub container: Option, } @@ -506,7 +565,7 @@ impl Part for Deployment {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ScriptHandler { - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. #[serde(rename="scriptPath")] pub script_path: Option, } @@ -520,24 +579,24 @@ impl Part for ScriptHandler {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlDispatchRule { - /// The pathname within the host. This must start with a '/'. A single '*' (glob) can be included at the end of the path. The sum of the lengths of the domain and path may not exceed 100 characters. + /// Pathname within the host. Must start with a "`/`". A single "`*`" can be included at the end of the path. The sum of the lengths of the domain and path may not exceed 100 characters. pub path: Option, - /// The domain name to match on. Supports '*' (glob) wildcarding on the left-hand side of a '.'. If empty, all domains will be matched (the same as '*'). + /// Domain name to match against. The wildcard "`*`" is supported if specified before a period: "`*.`". Defaults to matching all domains: "`*`". pub domain: Option, - /// The resource id of a Module in this application that should service the matched request. The Module must already exist. Example: "default". + /// Resource ID of a module in this application that should serve the matched request. The module must already exist. Example: `default`. pub module: Option, } impl Part for UrlDispatchRule {} -/// Use Google Cloud Endpoints to handle requests. +/// Uses Google Cloud Endpoints to handle requests. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApiEndpointHandler { - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. #[serde(rename="scriptPath")] pub script_path: Option, } @@ -545,29 +604,29 @@ pub struct ApiEndpointHandler { impl Part for ApiEndpointHandler {} -/// Configure health checking for the VM instances. Unhealthy VM instances will be killed and replaced with new instances. +/// Health checking configuration for VM instances. Unhealthy instances are killed and replaced with new instances. Only applicable for instances in App Engine flexible environment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HealthCheck { - /// The number of consecutive successful health checks before receiving traffic. + /// Number of consecutive successful health checks required before receiving traffic. #[serde(rename="healthyThreshold")] pub healthy_threshold: Option, - /// The number of consecutive failed health checks before an instance is restarted. + /// Number of consecutive failed health checks required before an instance is restarted. #[serde(rename="restartThreshold")] pub restart_threshold: Option, - /// The amount of time before the health check is considered failed. + /// Time before the health check is considered failed. pub timeout: Option, - /// The interval between health checks. + /// Interval between health checks. #[serde(rename="checkInterval")] pub check_interval: Option, /// Whether to explicitly disable health checks for this instance. #[serde(rename="disableHealthCheck")] pub disable_health_check: Option, - /// The host header to send when performing an HTTP health check (e.g. myapp.appspot.com) + /// Host header to send when performing an HTTP health check. Example: "myapp.appspot.com" pub host: Option, - /// The number of consecutive failed health checks before removing traffic. + /// Number of consecutive failed health checks required before removing traffic. #[serde(rename="unhealthyThreshold")] pub unhealthy_threshold: Option, } @@ -575,16 +634,16 @@ pub struct HealthCheck { impl Part for HealthCheck {} -/// A custom static error page to be served when an error occurs. +/// Custom static error page to be served when an error occurs. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ErrorHandler { - /// The error condition this handler applies to. + /// Error condition this handler applies to. #[serde(rename="errorCode")] pub error_code: Option, - /// MIME type of file. If unspecified, "text/html" is assumed. + /// MIME type of file. Defaults to `text/html`. #[serde(rename="mimeType")] pub mime_type: Option, /// Static file content to be served for this error. @@ -601,20 +660,20 @@ impl Part for ErrorHandler {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StaticDirectoryHandler { - /// If specified, all files served by this handler will be served using the specified MIME type. If not specified, the MIME type for a file will be derived from the file's filename extension. + /// MIME type used to serve all files served by this handler. Defaults to file-specific MIME types, which are direved from each file's filename extension. #[serde(rename="mimeType")] pub mime_type: Option, - /// The length of time a static file served by this handler ought to be cached by web proxies and browsers. + /// Time a static file served by this handler should be cached. pub expiration: Option, - /// The path to the directory containing the static files, from the application root directory. Everything after the end of the matched url pattern is appended to static_dir to form the full path to the requested file. + /// Path to the directory containing the static files from the application root directory. Everything after the end of the matched URL pattern is appended to `static_dir` to form the full path to the requested file. pub directory: Option, - /// If true, this UrlMap entry does not match the request unless the file referenced by the handler also exists. If no such file exists, processing will continue with the next UrlMap that matches the requested URL. + /// Whether this handler should match the request if the file referenced by the handler does not exist. #[serde(rename="requireMatchingFile")] pub require_matching_file: Option, /// HTTP headers to use for all responses from these URLs. #[serde(rename="httpHeaders")] pub http_headers: Option>, - /// By default, files declared in static file handlers are uploaded as static data and are only served to end users, they cannot be read by an application. If this field is set to true, the files are also uploaded as code data so your application can read them. Both uploads are charged against your code and static data storage resource quotas. + /// Whether files should also be uploaded as code data. By default, files declared in static directory handlers are uploaded as static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged against both your code and static data storage resource quotas. #[serde(rename="applicationReadable")] pub application_readable: Option, } @@ -622,7 +681,7 @@ pub struct StaticDirectoryHandler { impl Part for StaticDirectoryHandler {} -/// Automatic scaling is the scaling policy that App Engine has used since its inception. It is based on request rate, response latencies, and other application metrics. +/// Automatic scaling is based on request rate, response latencies, and other application metrics. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -634,13 +693,13 @@ pub struct AutomaticScaling { /// Target scaling by network usage. #[serde(rename="networkUtilization")] pub network_utilization: Option, - /// The minimum number of idle instances that App Engine should maintain for this version. Only applies to the default version of a module, since other versions are not expected to receive significant traffic. + /// Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a module. #[serde(rename="minIdleInstances")] pub min_idle_instances: Option, - /// The maximum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. + /// Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it. #[serde(rename="maxPendingLatency")] pub max_pending_latency: Option, - /// The maximum number of idle instances that App Engine should maintain for this version. + /// Maximum number of idle instances that should be maintained for this version. #[serde(rename="maxIdleInstances")] pub max_idle_instances: Option, /// Target scaling by disk usage. @@ -649,19 +708,19 @@ pub struct AutomaticScaling { /// Target scaling by request utilization. #[serde(rename="requestUtilization")] pub request_utilization: Option, - /// The amount of time that the [Autoscaler](https://cloud.google.com/compute/docs/autoscaler/) should wait between changes to the number of virtual machines. Applies only to the VM runtime. + /// Amount of time that the [Autoscaler](https://cloud.google.com/compute/docs/autoscaler/) should wait between changes to the number of virtual machines. Only applicable for VM runtimes. #[serde(rename="coolDownPeriod")] pub cool_down_period: Option, - /// Max number of instances that App Engine should start to handle requests. + /// Maximum number of instances that should be started to handle requests. #[serde(rename="maxTotalInstances")] pub max_total_instances: Option, - /// The number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Default value is chosen based on the runtime. + /// Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Defaults to a runtime-specific value. #[serde(rename="maxConcurrentRequests")] pub max_concurrent_requests: Option, - /// Minimum number of instances that App Engine should maintain. + /// Minimum number of instances that should be maintained for this version. #[serde(rename="minTotalInstances")] pub min_total_instances: Option, - /// The minimum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. + /// Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it. #[serde(rename="minPendingLatency")] pub min_pending_latency: Option, } @@ -669,7 +728,7 @@ pub struct AutomaticScaling { impl Part for AutomaticScaling {} -/// A URL pattern and description of how it should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS or JavaScript. +/// URL pattern and description of how the URL should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the version, such as images, CSS, or JavaScript. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -678,26 +737,26 @@ pub struct UrlMap { /// Serves the entire contents of a directory as static files. This attribute is deprecated. You can mimic the behavior of static directories using static files. #[serde(rename="staticDirectory")] pub static_directory: Option, - /// Configures whether security (HTTPS) should be enforced for this URL. + /// Security (HTTPS) enforcement for this URL. #[serde(rename="securityLevel")] pub security_level: Option, - /// For users not logged in, how to handle access to resources with required login. Defaults to "redirect". + /// Action to take when users access resources that require authentication. Defaults to `redirect`. #[serde(rename="authFailAction")] pub auth_fail_action: Option, - /// A URL prefix. This value uses regular expression syntax (and so regexp special characters must be escaped), but it should not contain groupings. All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. This is always required. + /// A URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings. All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. #[serde(rename="urlRegex")] pub url_regex: Option, - /// Executes a script to handle the request that matches the URL pattern. + /// Executes a script to handle the request that matches this URL pattern. pub script: Option, /// Returns the contents of a file, such as an image, as the response. #[serde(rename="staticFiles")] pub static_files: Option, - /// Use API Endpoints to handle requests. + /// Uses API Endpoints to handle requests. #[serde(rename="apiEndpoint")] pub api_endpoint: Option, - /// What level of login is required to access this resource. + /// Level of login required to access this resource. pub login: Option, - /// `30x` code to use when performing redirects for the `secure` field. A `302` is used by default. + /// `30x` code to use when performing redirects for the `secure` field. Defaults to `302`. #[serde(rename="redirectHttpResponseCode")] pub redirect_http_response_code: Option, } @@ -705,19 +764,19 @@ pub struct UrlMap { impl Part for UrlMap {} -/// A single source file which is part of the application to be deployed. +/// Single source file that is part of the version to be deployed. Each source file that is deployed must be specified separately. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileInfo { - /// The MIME type of the file; if unspecified, the value from Google Cloud Storage will be used. + /// The MIME type of the file. Defaults to the value from Google Cloud Storage. #[serde(rename="mimeType")] pub mime_type: Option, - /// The URL source to use to fetch this file. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. + /// URL source to use to fetch this file. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. #[serde(rename="sourceUrl")] pub source_url: Option, - /// The SHA1 (160 bits) hash of the file in hex. + /// The SHA1 hash of the file, in hex. #[serde(rename="sha1Sum")] pub sha1_sum: Option, } @@ -746,33 +805,88 @@ pub struct ListOperationsResponse { impl ResponseResult for ListOperationsResponse {} +/// An Instance resource is the computing unit that App Engine uses to automatically scale an application. +/// +/// # 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*). +/// +/// * [modules versions instances get apps](struct.AppModuleVersionInstanceGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Instance { + /// Number of errors since this instance was started. @OutputOnly + pub errors: Option, + /// Full path to the Instance resource in the API. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. @OutputOnly + pub name: Option, + /// Whether this instance is in debug mode. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmUnlocked")] + pub vm_unlocked: Option, + /// App Engine release this instance is running on. @OutputOnly + #[serde(rename="appEngineRelease")] + pub app_engine_release: Option, + /// Virtual machine ID of this instance. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmId")] + pub vm_id: Option, + /// Total memory in use (bytes). @OutputOnly + #[serde(rename="memoryUsage")] + pub memory_usage: Option, + /// Availability of the instance. @OutputOnly + pub availability: Option, + /// Average latency (ms) over the last minute. @OutputOnly + #[serde(rename="averageLatency")] + pub average_latency: Option, + /// Relative name of the instance within the version. Example: `instance-1`. @OutputOnly + pub id: Option, + /// Average queries per second (QPS) over the last minute. @OutputOnly + pub qps: Option, + /// Number of requests since this instance was started. @OutputOnly + pub requests: Option, + /// Name of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmName")] + pub vm_name: Option, + /// Time that this instance was started. @OutputOnly + #[serde(rename="startTimestamp")] + pub start_timestamp: Option, + /// Zone where the virtual machine is located. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmZoneName")] + pub vm_zone_name: Option, + /// Status of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmStatus")] + pub vm_status: Option, +} + +impl ResponseResult for Instance {} + + /// A module with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ManualScaling { - /// The number of instances to assign to the module at the start. This number can later be altered by using the [Modules API](https://cloud.google.com/appengine/docs/python/modules/functions) `set_num_instances()` function. + /// Number of instances to assign to the module at the start. This number can later be altered by using the [Modules API](https://cloud.google.com/appengine/docs/python/modules/functions) `set_num_instances()` function. pub instances: Option, } impl Part for ManualScaling {} -/// A Docker (container) image which should be used to start the application. +/// Docker image that is used to start a VM container for the version you deploy. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContainerInfo { - /// Reference to a hosted container image. Must be a URI to a resource in a Docker repository. Must be fully qualified, including tag or digest. e.g. gcr.io/my-project/image:tag or gcr.io/my-project/image@digest + /// URI to the hosted container image in a Docker repository. The URI must be fully qualified and include a tag or digest. Examples: "gcr.io/my-project/image:tag" or "gcr.io/my-project/image@digest" pub image: Option, } impl Part for ContainerInfo {} -/// API Serving configuration for Cloud Endpoints. +/// [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/) configuration for API handlers. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -780,22 +894,22 @@ impl Part for ContainerInfo {} pub struct ApiConfigHandler { /// URL to serve the endpoint at. pub url: Option, - /// Configures whether security (HTTPS) should be enforced for this URL. + /// Security (HTTPS) enforcement for this URL. #[serde(rename="securityLevel")] pub security_level: Option, - /// For users not logged in, how to handle access to resources with required login. Defaults to "redirect". + /// Action to take when users access resources that require authentication. Defaults to `redirect`. #[serde(rename="authFailAction")] pub auth_fail_action: Option, - /// What level of login is required to access this resource. Default is "optional". + /// Level of login required to access this resource. Defaults to `optional`. pub login: Option, - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. pub script: Option, } impl Part for ApiConfigHandler {} -/// A module is a component of an application that provides a single service or configuration. A module has a collection of versions that define a specific set of code used to implement the functionality of that module. +/// A Module resource is a logical component of an application that can share state and communicate in a secure fashion with other modules. For example, an application that handles customer requests might include separate modules to handle tasks such as backend data analysis or API requests from mobile devices. Each module has a collection of versions that define a specific set of code used to implement the functionality of that module. /// /// # Activities /// @@ -807,11 +921,11 @@ impl Part for ApiConfigHandler {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Module { - /// A mapping that defines fractional HTTP traffic diversion to different versions within the module. + /// Mapping that defines fractional HTTP traffic diversion to different versions within the module. pub split: Option, - /// The relative name/path of the module within the application. Example: "default" @OutputOnly + /// Relative name of the module within the application. Example: `default`. @OutputOnly pub id: Option, - /// The full path to the Module resource in the API. Example: "apps/myapp/modules/default" @OutputOnly + /// Full path to the Module resource in the API. Example: `apps/myapp/modules/default`. @OutputOnly pub name: Option, } @@ -819,38 +933,38 @@ impl RequestValue for Module {} impl ResponseResult for Module {} -/// A reference to a particular snapshot of the source tree used to build and deploy the application. +/// Reference to a particular snapshot of the source tree used to build and deploy the application. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SourceReference { - /// The canonical (and persistent) identifier of the deployed revision, i.e. any kind of aliases including tags or branch names are not allowed. Example (git): "2198322f89e0bb2e25021667c2ed489d1fd34e6b" + /// The canonical, persistent identifier of the deployed revision. Aliases that include tags or branch names are not allowed. Example (git): "2198322f89e0bb2e25021667c2ed489d1fd34e6b" #[serde(rename="revisionId")] pub revision_id: Option, - /// Optional. A URI string identifying the repository. Example: "https://source.developers.google.com/p/app-123/r/default" + /// URI string identifying the repository. Example: "https://source.developers.google.com/p/app-123/r/default" pub repository: Option, } impl Part for SourceReference {} -/// Target scaling by disk usage (for VM runtimes only). +/// Target scaling by disk usage. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskUtilization { - /// Target ops per second written. + /// Target ops written per second. #[serde(rename="targetWriteOpsPerSec")] pub target_write_ops_per_sec: Option, - /// Target bytes per second read. + /// Target bytes read per second. #[serde(rename="targetReadBytesPerSec")] pub target_read_bytes_per_sec: Option, - /// Target ops per second read. + /// Target ops read per second. #[serde(rename="targetReadOpsPerSec")] pub target_read_ops_per_sec: Option, - /// Target bytes per second written. + /// Target bytes written per second. #[serde(rename="targetWriteBytesPerSec")] pub target_write_bytes_per_sec: Option, } @@ -858,7 +972,7 @@ pub struct DiskUtilization { impl Part for DiskUtilization {} -/// Target scaling by request utilization (for VM runtimes only). +/// Target scaling by request utilization. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -875,16 +989,16 @@ pub struct RequestUtilization { impl Part for RequestUtilization {} -/// Configuration for traffic splitting for versions within a single module. Traffic splitting allows traffic directed to the module to be assigned to one of several versions in a fractional way, enabling experiments and canarying new builds, for example. +/// Traffic routing configuration for versions within a single module. Traffic splits define how traffic directed to the module is assigned to versions. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TrafficSplit { - /// Which mechanism should be used as a selector when choosing a version to send a request to. The traffic selection algorithm will be stable for either type until allocations are changed. + /// Mechanism used to determine which version a request is sent to. The traffic selection algorithm will be stable for either type until allocations are changed. #[serde(rename="shardBy")] pub shard_by: Option, - /// Mapping from module version IDs within the module to fractional (0.000, 1] allocations of traffic for that version. Each version may only be specified once, but some versions in the module may not have any traffic allocation. Modules that have traffic allocated in this field may not be deleted until the module is deleted, or their traffic allocation is removed. Allocations must sum to 1. Supports precision up to two decimal places for IP-based splits and up to three decimal places for cookie-based splits. + /// Mapping from version IDs within the module to fractional (0.000, 1] allocations of traffic for that version. Each version can be specified only once, but some versions in the module may not have any traffic allocation. Modules that have traffic allocated cannot be deleted until either the module is deleted or their traffic allocation is removed. Allocations must sum to 1. Up to two decimal place precision is supported for IP-based splits and up to three decimal places is supported for cookie-based splits. pub allocations: Option>, } @@ -899,6 +1013,9 @@ impl Part for TrafficSplit {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [modules patch apps](struct.AppModulePatchCall.html) (response) +/// * [create apps](struct.AppCreateCall.html) (response) +/// * [modules versions instances delete apps](struct.AppModuleVersionInstanceDeleteCall.html) (response) +/// * [modules versions instances debug apps](struct.AppModuleVersionInstanceDebugCall.html) (response) /// * [modules delete apps](struct.AppModuleDeleteCall.html) (response) /// * [operations get apps](struct.AppOperationGetCall.html) (response) /// * [modules versions patch apps](struct.AppModuleVersionPatchCall.html) (response) @@ -922,6 +1039,31 @@ pub struct Operation { impl ResponseResult for Operation {} +/// A resource that represents Google Cloud Platform location. +/// +/// # 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*). +/// +/// * [locations get apps](struct.AppLocationGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Location { + /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"} + pub labels: Option>, + /// The cononical id for this location. For example: `"us-east1"`. + #[serde(rename="locationId")] + pub location_id: Option, + /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"` + pub name: Option, + /// Service-specific metadata. For example the available capacity at the given location. + pub metadata: Option>, +} + +impl ResponseResult for Location {} + + // ################### // MethodBuilders ### @@ -950,7 +1092,7 @@ impl ResponseResult for Operation {} /// ::default(), None); /// let mut hub = Appengine::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `modules_delete(...)`, `modules_get(...)`, `modules_list(...)`, `modules_patch(...)`, `modules_versions_create(...)`, `modules_versions_delete(...)`, `modules_versions_get(...)`, `modules_versions_list(...)`, `modules_versions_patch(...)`, `operations_get(...)` and `operations_list(...)` +/// // like `create(...)`, `get(...)`, `locations_get(...)`, `locations_list(...)`, `modules_delete(...)`, `modules_get(...)`, `modules_list(...)`, `modules_patch(...)`, `modules_versions_create(...)`, `modules_versions_delete(...)`, `modules_versions_get(...)`, `modules_versions_instances_debug(...)`, `modules_versions_instances_delete(...)`, `modules_versions_instances_get(...)`, `modules_versions_instances_list(...)`, `modules_versions_list(...)`, `modules_versions_patch(...)`, `operations_get(...)` and `operations_list(...)` /// // to build up your call. /// let rb = hub.apps(); /// # } @@ -972,7 +1114,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - /// * `appsId` - Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default". + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. pub fn modules_patch(&self, request: Module, apps_id: &str, modules_id: &str) -> AppModulePatchCall<'a, C, A> { AppModulePatchCall { @@ -990,30 +1132,11 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all the modules in the application. + /// Gets the current configuration of the specified module. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp". - pub fn modules_list(&self, apps_id: &str) -> AppModuleListCall<'a, C, A> { - AppModuleListCall { - hub: self.hub, - _apps_id: apps_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 the current configuration of the module. - /// - /// # Arguments - /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. pub fn modules_get(&self, apps_id: &str, modules_id: &str) -> AppModuleGetCall<'a, C, A> { AppModuleGetCall { @@ -1026,13 +1149,143 @@ impl<'a, C, A> AppMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets instance information. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// * `modulesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn modules_versions_instances_get(&self, apps_id: &str, modules_id: &str, versions_id: &str, instances_id: &str) -> AppModuleVersionInstanceGetCall<'a, C, A> { + AppModuleVersionInstanceGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _modules_id: modules_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists all the modules in the application. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp`. + pub fn modules_list(&self, apps_id: &str) -> AppModuleListCall<'a, C, A> { + AppModuleListCall { + hub: self.hub, + _apps_id: apps_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 an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project). + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn create(&self, request: Application) -> AppCreateCall<'a, C, A> { + AppCreateCall { + 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 instances of a version. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`. + /// * `modulesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + pub fn modules_versions_instances_list(&self, apps_id: &str, modules_id: &str, versions_id: &str) -> AppModuleVersionInstanceListCall<'a, C, A> { + AppModuleVersionInstanceListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _modules_id: modules_id.to_string(), + _versions_id: versions_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: + /// + /// Stops a running instance. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// * `modulesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn modules_versions_instances_delete(&self, apps_id: &str, modules_id: &str, versions_id: &str, instances_id: &str) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + AppModuleVersionInstanceDeleteCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _modules_id: modules_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// * `modulesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn modules_versions_instances_debug(&self, request: DebugInstanceRequest, apps_id: &str, modules_id: &str, versions_id: &str, instances_id: &str) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + AppModuleVersionInstanceDebugCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _modules_id: modules_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Gets information about an application. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the application to get. For example: "apps/myapp". + /// * `appsId` - Part of `name`. Name of the application to get. Example: `apps/myapp`. pub fn get(&self, apps_id: &str) -> AppGetCall<'a, C, A> { AppGetCall { hub: self.hub, @@ -1046,11 +1299,11 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a module and all enclosed versions. + /// Deletes the specified module and all enclosed versions. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. pub fn modules_delete(&self, apps_id: &str, modules_id: &str) -> AppModuleDeleteCall<'a, C, A> { AppModuleDeleteCall { @@ -1084,12 +1337,51 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing version. Note: UNIMPLEMENTED. + /// Get information about a location. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Resource name for the location. + /// * `locationsId` - Part of `name`. See documentation of `appsId`. + pub fn locations_get(&self, apps_id: &str, locations_id: &str) -> AppLocationGetCall<'a, C, A> { + AppLocationGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _locations_id: locations_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists information about the supported locations for this service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. The resource that owns the locations collection, if applicable. + pub fn locations_list(&self, apps_id: &str) -> AppLocationListCall<'a, C, A> { + AppLocationListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _page_token: Default::default(), + _page_size: 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 specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. /// /// # Arguments /// /// * `request` - No description provided. - /// * `appsId` - Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default/versions/1". + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default/versions/1`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn modules_versions_patch(&self, request: Version, apps_id: &str, modules_id: &str, versions_id: &str) -> AppModuleVersionPatchCall<'a, C, A> { @@ -1132,7 +1424,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default/versions/v1". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn modules_versions_delete(&self, apps_id: &str, modules_id: &str, versions_id: &str) -> AppModuleVersionDeleteCall<'a, C, A> { @@ -1149,12 +1441,12 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deploys new code and resource files to a version. + /// Deploys code and resource files to a new version. /// /// # Arguments /// /// * `request` - No description provided. - /// * `appsId` - Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default". + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. pub fn modules_versions_create(&self, request: Version, apps_id: &str, modules_id: &str) -> AppModuleVersionCreateCall<'a, C, A> { AppModuleVersionCreateCall { @@ -1170,11 +1462,11 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets application deployment information. + /// Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default/versions/v1". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn modules_versions_get(&self, apps_id: &str, modules_id: &str, versions_id: &str) -> AppModuleVersionGetCall<'a, C, A> { @@ -1196,7 +1488,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`. /// * `modulesId` - Part of `name`. See documentation of `appsId`. pub fn modules_versions_list(&self, apps_id: &str, modules_id: &str) -> AppModuleVersionListCall<'a, C, A> { AppModuleVersionListCall { @@ -1437,7 +1729,7 @@ impl<'a, C, A> AppModulePatchCall<'a, C, A> where C: BorrowMut, A self._request = new_value; self } - /// Part of `name`. Name of the resource to update. For example: "apps/myapp/modules/default". + /// Part of `name`. Name of the resource to update. Example: `apps/myapp/modules/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -1457,7 +1749,7 @@ impl<'a, C, A> AppModulePatchCall<'a, C, A> where C: BorrowMut, A self._modules_id = new_value.to_string(); self } - /// Whether to use Traffic Migration to shift traffic gradually. Traffic can only be migrated from a single version to another single version. + /// Set to `true` to gradually shift traffic from one version to another single version. By default, traffic is shifted immediately. For gradual traffic migration, the target version must be located within instances that are configured for both [warmup requests](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#inboundservicetype) and [automatic scaling](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#automaticscaling). You must specify the [`shardBy`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules#shardby) field in the Module resource. Gradual traffic migration is not supported in the App Engine flexible environment. For examples, see [Migrating and Splitting Traffic](https://cloud.google.com/appengine/docs/admin-api/migrating-splitting-traffic). /// /// Sets the *migrate traffic* query property to the given value. pub fn migrate_traffic(mut self, new_value: bool) -> AppModulePatchCall<'a, C, A> { @@ -1529,272 +1821,7 @@ impl<'a, C, A> AppModulePatchCall<'a, C, A> where C: BorrowMut, A } -/// Lists all the modules in the application. -/// -/// A builder for the *modules.list* method supported by a *app* resource. -/// It is not used directly, but through a `AppMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_appengine1_beta4 as appengine1_beta4; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use appengine1_beta4::Appengine; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Appengine::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.apps().modules_list("appsId") -/// .page_token("sea") -/// .page_size(-90) -/// .doit(); -/// # } -/// ``` -pub struct AppModuleListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Appengine, - _apps_id: String, - _page_token: Option, - _page_size: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AppModuleListCall<'a, C, A> {} - -impl<'a, C, A> AppModuleListCall<'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, ListModulesResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "appengine.apps.modules.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("appsId", self._apps_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", "appsId", "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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) - } - } - } - } - - - /// Part of `name`. Name of the resource requested. For example: "apps/myapp". - /// - /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleListCall<'a, C, A> { - self._apps_id = new_value.to_string(); - self - } - /// Continuation token for fetching the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AppModuleListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum results to return per page. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> AppModuleListCall<'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) -> AppModuleListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> AppModuleListCall<'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) -> AppModuleListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets the current configuration of the module. +/// Gets the current configuration of the specified module. /// /// A builder for the *modules.get* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -1969,7 +1996,7 @@ impl<'a, C, A> AppModuleGetCall<'a, C, A> where C: BorrowMut, A: } - /// Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default". + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -2047,6 +2074,1661 @@ impl<'a, C, A> AppModuleGetCall<'a, C, A> where C: BorrowMut, A: } +/// Gets instance information. +/// +/// A builder for the *modules.versions.instances.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().modules_versions_instances_get("appsId", "modulesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppModuleVersionInstanceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _modules_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppModuleVersionInstanceGetCall<'a, C, A> {} + +impl<'a, C, A> AppModuleVersionInstanceGetCall<'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: "appengine.apps.modules.versions.instances.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("modulesId", self._modules_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "modulesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules/{modulesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{modulesId}", "modulesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "modulesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleVersionInstanceGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *modules 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 modules_id(mut self, new_value: &str) -> AppModuleVersionInstanceGetCall<'a, C, A> { + self._modules_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppModuleVersionInstanceGetCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppModuleVersionInstanceGetCall<'a, C, A> { + self._instances_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) -> AppModuleVersionInstanceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppModuleVersionInstanceGetCall<'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) -> AppModuleVersionInstanceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all the modules in the application. +/// +/// A builder for the *modules.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().modules_list("appsId") +/// .page_token("ea") +/// .page_size(-61) +/// .doit(); +/// # } +/// ``` +pub struct AppModuleListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppModuleListCall<'a, C, A> {} + +impl<'a, C, A> AppModuleListCall<'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, ListModulesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.modules.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("appsId", self._apps_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", "appsId", "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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppModuleListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppModuleListCall<'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) -> AppModuleListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppModuleListCall<'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) -> AppModuleListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project). +/// +/// A builder for the *create* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// use appengine1_beta4::Application; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = Application::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.apps().create(req) +/// .doit(); +/// # } +/// ``` +pub struct AppCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: Application, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppCreateCall<'a, C, A> {} + +impl<'a, C, A> AppCreateCall<'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: "appengine.apps.create", + 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://appengine.googleapis.com/v1beta4/apps".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.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: Application) -> AppCreateCall<'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) -> AppCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppCreateCall<'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) -> AppCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the instances of a version. +/// +/// A builder for the *modules.versions.instances.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().modules_versions_instances_list("appsId", "modulesId", "versionsId") +/// .page_token("et") +/// .page_size(-41) +/// .doit(); +/// # } +/// ``` +pub struct AppModuleVersionInstanceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _modules_id: String, + _versions_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppModuleVersionInstanceListCall<'a, C, A> {} + +impl<'a, C, A> AppModuleVersionInstanceListCall<'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, ListInstancesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.modules.versions.instances.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("modulesId", self._modules_id.to_string())); + params.push(("versionsId", self._versions_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", "appsId", "modulesId", "versionsId", "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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules/{modulesId}/versions/{versionsId}/instances".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{modulesId}", "modulesId"), ("{versionsId}", "versionsId")].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 ["versionsId", "modulesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleVersionInstanceListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *modules 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 modules_id(mut self, new_value: &str) -> AppModuleVersionInstanceListCall<'a, C, A> { + self._modules_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppModuleVersionInstanceListCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppModuleVersionInstanceListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppModuleVersionInstanceListCall<'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) -> AppModuleVersionInstanceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppModuleVersionInstanceListCall<'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) -> AppModuleVersionInstanceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Stops a running instance. +/// +/// A builder for the *modules.versions.instances.delete* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().modules_versions_instances_delete("appsId", "modulesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppModuleVersionInstanceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _modules_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppModuleVersionInstanceDeleteCall<'a, C, A> {} + +impl<'a, C, A> AppModuleVersionInstanceDeleteCall<'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: "appengine.apps.modules.versions.instances.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("modulesId", self._modules_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "modulesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules/{modulesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{modulesId}", "modulesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "modulesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *modules 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 modules_id(mut self, new_value: &str) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + self._modules_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + self._instances_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) -> AppModuleVersionInstanceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppModuleVersionInstanceDeleteCall<'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) -> AppModuleVersionInstanceDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment. +/// +/// A builder for the *modules.versions.instances.debug* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// use appengine1_beta4::DebugInstanceRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = DebugInstanceRequest::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.apps().modules_versions_instances_debug(req, "appsId", "modulesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppModuleVersionInstanceDebugCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: DebugInstanceRequest, + _apps_id: String, + _modules_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppModuleVersionInstanceDebugCall<'a, C, A> {} + +impl<'a, C, A> AppModuleVersionInstanceDebugCall<'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: "appengine.apps.modules.versions.instances.debug", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("modulesId", self._modules_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "modulesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta4/apps/{appsId}/modules/{modulesId}/versions/{versionsId}/instances/{instancesId}:debug".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{modulesId}", "modulesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "modulesId", "appsId"].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: DebugInstanceRequest) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *modules 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 modules_id(mut self, new_value: &str) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._modules_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._instances_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) -> AppModuleVersionInstanceDebugCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppModuleVersionInstanceDebugCall<'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) -> AppModuleVersionInstanceDebugCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Gets information about an application. /// /// A builder for the *get* method supported by a *app* resource. @@ -2074,7 +3756,7 @@ impl<'a, C, A> AppModuleGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().get("appsId") -/// .ensure_resources_exist(true) +/// .ensure_resources_exist(false) /// .doit(); /// # } /// ``` @@ -2225,7 +3907,7 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut, A: oauth2 } - /// Part of `name`. Name of the application to get. For example: "apps/myapp". + /// Part of `name`. Name of the application to get. Example: `apps/myapp`. /// /// Sets the *apps id* path property to the given value. /// @@ -2300,7 +3982,7 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut, A: oauth2 } -/// Deletes a module and all enclosed versions. +/// Deletes the specified module and all enclosed versions. /// /// A builder for the *modules.delete* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -2475,7 +4157,7 @@ impl<'a, C, A> AppModuleDeleteCall<'a, C, A> where C: BorrowMut, } - /// Part of `name`. Name of the resource requested. For example: "apps/myapp/modules/default". + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/modules/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -2806,7 +4488,537 @@ impl<'a, C, A> AppOperationGetCall<'a, C, A> where C: BorrowMut, } -/// Updates an existing version. Note: UNIMPLEMENTED. +/// Get information about a location. +/// +/// A builder for the *locations.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().locations_get("appsId", "locationsId") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _locations_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationGetCall<'a, C, A> {} + +impl<'a, C, A> AppLocationGetCall<'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, Location)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("locationsId", self._locations_id.to_string())); + for &field in ["alt", "appsId", "locationsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta4/apps/{appsId}/locations/{locationsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{locationsId}", "locationsId")].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 ["locationsId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Resource name for the location. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *locations 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 locations_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._locations_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) -> AppLocationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationGetCall<'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) -> AppLocationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists information about the supported locations for this service. +/// +/// A builder for the *locations.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta4 as appengine1_beta4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta4::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().locations_list("appsId") +/// .page_token("dolore") +/// .page_size(-37) +/// .filter("aliquyam") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _filter: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationListCall<'a, C, A> {} + +impl<'a, C, A> AppLocationListCall<'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, ListLocationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_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 { + params.push(("filter", value.to_string())); + } + for &field in ["alt", "appsId", "pageToken", "pageSize", "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://appengine.googleapis.com/v1beta4/apps/{appsId}/locations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. The resource that owns the locations collection, if applicable. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// The standard list page token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The standard list page size. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppLocationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// The standard list filter. + /// + /// Sets the *filter* query property to the given value. + pub fn filter(mut self, new_value: &str) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta4/apps.modules.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. /// /// A builder for the *modules.versions.patch* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -2839,7 +5051,7 @@ impl<'a, C, A> AppOperationGetCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().modules_versions_patch(req, "appsId", "modulesId", "versionsId") -/// .mask("ipsum") +/// .mask("et") /// .doit(); /// # } /// ``` @@ -3019,7 +5231,7 @@ impl<'a, C, A> AppModuleVersionPatchCall<'a, C, A> where C: BorrowMut AppModuleVersionPatchCall<'a, C, A> where C: BorrowMut AppModuleVersionDeleteCall<'a, C, A> where C: BorrowMut AppModuleVersionDeleteCall<'a, C, A> where C: BorrowMut AppModuleVersionCreateCall<'a, C, A> where C: BorrowMut AppModuleVersionCreateCall<'a, C, A> where C: BorrowMut AppModuleVersionCreateCall<'a, C, A> where C: BorrowMut AppModuleVersionGetCall<'a, C, A> where C: BorrowMut AppModuleVersionGetCall<'a, C, A> where C: BorrowMut AppModuleVersionListCall<'a, C, A> where C: BorrowMut"] description = "A complete library to interact with appengine (protocol v1beta5)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appengine1_beta5-cli" @@ -19,10 +19,10 @@ name = "appengine1-beta5" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appengine1_beta5] diff --git a/gen/appengine1_beta5-cli/README.md b/gen/appengine1_beta5-cli/README.md index 2c88dec083..bca2711ddd 100644 --- a/gen/appengine1_beta5-cli/README.md +++ b/gen/appengine1_beta5-cli/README.md @@ -24,12 +24,15 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *appengine* API at revision *20160314*. The CLI is at version *0.3.6*. +This documentation was generated from the *appengine* API at revision *20160802*. The CLI is at version *0.3.6*. ```bash appengine1-beta5 [options] apps + create (-r )... [-p ]... [-o ] get [-p ]... [-o ] + locations-get [-p ]... [-o ] + locations-list [-p ]... [-o ] operations-get [-p ]... [-o ] operations-list [-p ]... [-o ] services-delete [-p ]... [-o ] @@ -39,6 +42,10 @@ appengine1-beta5 [options] services-versions-create (-r )... [-p ]... [-o ] services-versions-delete [-p ]... [-o ] services-versions-get [-p ]... [-o ] + services-versions-instances-debug (-r )... [-p ]... [-o ] + services-versions-instances-delete [-p ]... [-o ] + services-versions-instances-get [-p ]... [-o ] + services-versions-instances-list [-p ]... [-o ] services-versions-list [-p ]... [-o ] services-versions-patch (-r )... [-p ]... [-o ] appengine1-beta5 --help diff --git a/gen/appengine1_beta5-cli/mkdocs.yml b/gen/appengine1_beta5-cli/mkdocs.yml index aba72943df..c5705f200e 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+20160314 +site_name: appengine v0.3.6+20160802 site_url: http://byron.github.io/google-apis-rs/google-appengine1_beta5-cli site_description: Write integrating applications with bcore @@ -9,7 +9,10 @@ site_dir: build_html pages: - ['index.md', 'Home'] +- ['apps_create.md', 'Apps', 'Create'] - ['apps_get.md', 'Apps', 'Get'] +- ['apps_locations-get.md', 'Apps', 'Locations Get'] +- ['apps_locations-list.md', 'Apps', 'Locations List'] - ['apps_operations-get.md', 'Apps', 'Operations Get'] - ['apps_operations-list.md', 'Apps', 'Operations List'] - ['apps_services-delete.md', 'Apps', 'Services Delete'] @@ -19,6 +22,10 @@ pages: - ['apps_services-versions-create.md', 'Apps', 'Services Versions Create'] - ['apps_services-versions-delete.md', 'Apps', 'Services Versions Delete'] - ['apps_services-versions-get.md', 'Apps', 'Services Versions Get'] +- ['apps_services-versions-instances-debug.md', 'Apps', 'Services Versions Instances Debug'] +- ['apps_services-versions-instances-delete.md', 'Apps', 'Services Versions Instances Delete'] +- ['apps_services-versions-instances-get.md', 'Apps', 'Services Versions Instances Get'] +- ['apps_services-versions-instances-list.md', 'Apps', 'Services Versions Instances List'] - ['apps_services-versions-list.md', 'Apps', 'Services Versions List'] - ['apps_services-versions-patch.md', 'Apps', 'Services Versions Patch'] diff --git a/gen/appengine1_beta5-cli/src/main.rs b/gen/appengine1_beta5-cli/src/main.rs index 0e15c10a35..2a62efa62d 100644 --- a/gen/appengine1_beta5-cli/src/main.rs +++ b/gen/appengine1_beta5-cli/src/main.rs @@ -45,6 +45,98 @@ struct Engine<'n> { impl<'n> Engine<'n> { + fn _apps_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()[..] { + "default-hostname" => Some(("defaultHostname", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "code-bucket" => Some(("codeBucket", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-bucket" => Some(("defaultBucket", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-cookie-expiration" => Some(("defaultCookieExpiration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auth-domain" => Some(("authDomain", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["auth-domain", "code-bucket", "default-bucket", "default-cookie-expiration", "default-hostname", "id", "location", "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::Application = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().create(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 _apps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().get(opt.value_of("apps-id").unwrap_or("")); @@ -101,6 +193,120 @@ impl<'n> Engine<'n> { } } + fn _apps_locations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("locations-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 _apps_locations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().locations_list(opt.value_of("apps-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" => { + 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", "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 _apps_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().operations_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("operations-id").unwrap_or("")); @@ -723,6 +929,253 @@ impl<'n> Engine<'n> { } } + fn _apps_services_versions_instances_debug(&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::DebugInstanceRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.apps().services_versions_instances_debug(request, opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_delete(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_get(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-id").unwrap_or(""), opt.value_of("instances-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 _apps_services_versions_instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.apps().services_versions_instances_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or(""), opt.value_of("versions-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 _apps_services_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.apps().services_versions_list(opt.value_of("apps-id").unwrap_or(""), opt.value_of("services-id").unwrap_or("")); @@ -938,9 +1391,18 @@ impl<'n> Engine<'n> { match self.opt.subcommand() { ("apps", Some(opt)) => { match opt.subcommand() { + ("create", Some(opt)) => { + call_result = self._apps_create(opt, dry_run, &mut err); + }, ("get", Some(opt)) => { call_result = self._apps_get(opt, dry_run, &mut err); }, + ("locations-get", Some(opt)) => { + call_result = self._apps_locations_get(opt, dry_run, &mut err); + }, + ("locations-list", Some(opt)) => { + call_result = self._apps_locations_list(opt, dry_run, &mut err); + }, ("operations-get", Some(opt)) => { call_result = self._apps_operations_get(opt, dry_run, &mut err); }, @@ -968,6 +1430,18 @@ impl<'n> Engine<'n> { ("services-versions-get", Some(opt)) => { call_result = self._apps_services_versions_get(opt, dry_run, &mut err); }, + ("services-versions-instances-debug", Some(opt)) => { + call_result = self._apps_services_versions_instances_debug(opt, dry_run, &mut err); + }, + ("services-versions-instances-delete", Some(opt)) => { + call_result = self._apps_services_versions_instances_delete(opt, dry_run, &mut err); + }, + ("services-versions-instances-get", Some(opt)) => { + call_result = self._apps_services_versions_instances_get(opt, dry_run, &mut err); + }, + ("services-versions-instances-list", Some(opt)) => { + call_result = self._apps_services_versions_instances_list(opt, dry_run, &mut err); + }, ("services-versions-list", Some(opt)) => { call_result = self._apps_services_versions_list(opt, dry_run, &mut err); }, @@ -1066,14 +1540,86 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("apps", "methods: 'get', 'operations-get', 'operations-list', 'services-delete', 'services-get', 'services-list', 'services-patch', 'services-versions-create', 'services-versions-delete', 'services-versions-get', 'services-versions-list' and 'services-versions-patch'", vec![ + ("apps", "methods: 'create', 'get', 'locations-get', 'locations-list', 'operations-get', 'operations-list', 'services-delete', 'services-get', 'services-list', 'services-patch', 'services-versions-create', 'services-versions-delete', 'services-versions-get', 'services-versions-instances-debug', 'services-versions-instances-delete', 'services-versions-instances-get', 'services-versions-instances-list', 'services-versions-list' and 'services-versions-patch'", vec![ + ("create", + Some(r##"Creates an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project)."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_create", + 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)), + ]), ("get", Some(r##"Gets information about an application."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the application to get. For example: "apps/myapp"."##), + Some(r##"Part of `name`. Name of the application to get. Example: `apps/myapp`."##), + 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)), + ]), + ("locations-get", + Some(r##"Get information about a location."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_locations-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Resource name for the location."##), + Some(true), + Some(false)), + + (Some(r##"locations-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("locations-list", + Some(r##"Lists information about the supported locations for this service."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_locations-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. The resource that owns the locations collection, if applicable."##), Some(true), Some(false)), @@ -1140,12 +1686,12 @@ fn main() { Some(false)), ]), ("services-delete", - Some(r##"Deletes a service and all enclosed versions."##), + Some(r##"Deletes the specified service and all enclosed versions."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-delete", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`."##), Some(true), Some(false)), @@ -1168,12 +1714,12 @@ fn main() { Some(false)), ]), ("services-get", - Some(r##"Gets the current configuration of the service."##), + Some(r##"Gets the current configuration of the specified service."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`."##), Some(true), Some(false)), @@ -1201,7 +1747,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp`."##), Some(true), Some(false)), @@ -1223,7 +1769,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource to update. For example: "apps/myapp/services/default"."##), + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`."##), Some(true), Some(false)), @@ -1252,7 +1798,7 @@ fn main() { Some(false)), ]), ("services-versions-create", - Some(r##"Deploys new code and resource files to a version."##), + Some(r##"Deploys new code and resource files to a new version."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-create", vec![ (Some(r##"apps-id"##), @@ -1291,7 +1837,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`."##), Some(true), Some(false)), @@ -1320,12 +1866,172 @@ fn main() { Some(false)), ]), ("services-versions-get", - Some(r##"Gets application deployment information."##), + Some(r##"Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-get", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-debug", + Some(r##"Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-instances-debug", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-delete", + Some(r##"Stops a running instance."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-instances-delete", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1/instances/instance-1"."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-get", + Some(r##"Gets instance information."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-instances-get", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`."##), + Some(true), + Some(false)), + + (Some(r##"services-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"versions-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + Some(true), + Some(false)), + + (Some(r##"instances-id"##), + None, + Some(r##"Part of `name`. See documentation of `appsId`."##), + 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)), + ]), + ("services-versions-instances-list", + Some(r##"Lists the instances of a version."##), + "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-instances-list", + vec![ + (Some(r##"apps-id"##), + None, + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`."##), Some(true), Some(false)), @@ -1359,7 +2065,7 @@ fn main() { vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default"."##), + Some(r##"Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`."##), Some(true), Some(false)), @@ -1382,12 +2088,12 @@ fn main() { Some(false)), ]), ("services-versions-patch", - Some(r##"Updates an existing version. Note: UNIMPLEMENTED."##), + Some(r##"Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment."##), "Details at http://byron.github.io/google-apis-rs/google_appengine1_beta5_cli/apps_services-versions-patch", vec![ (Some(r##"apps-id"##), None, - Some(r##"Part of `name`. Name of the resource to update. For example: "apps/myapp/services/default/versions/1"."##), + Some(r##"Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default/versions/1`."##), Some(true), Some(false)), @@ -1427,7 +2133,7 @@ fn main() { let mut app = App::new("appengine1-beta5") .author("Sebastian Thiel ") - .version("0.3.6+20160314") + .version("0.3.6+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/appengine1_beta5/Cargo.toml b/gen/appengine1_beta5/Cargo.toml index c25b884cdf..c2ddd24d0c 100644 --- a/gen/appengine1_beta5/Cargo.toml +++ b/gen/appengine1_beta5/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appengine1_beta5" -version = "0.1.14+20160314" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/appengine1_beta5/README.md b/gen/appengine1_beta5/README.md index 9dfcde8a5e..a6bfc9e0b8 100644 --- a/gen/appengine1_beta5/README.md +++ b/gen/appengine1_beta5/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appengine1_beta5` library allows access to all features of the *Google appengine* service. -This documentation was generated from *appengine* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *appengine:v1beta5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1beta5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *appengine* *v1_beta5* API can be found at the [official documentation site](https://cloud.google.com/appengine/docs/admin-api/). @@ -14,7 +14,7 @@ Everything else about the *appengine* *v1_beta5* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.Appengine.html) ... * apps - * [*get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppGetCall.html), [*operations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppOperationGetCall.html), [*operations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppOperationListCall.html), [*services delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceDeleteCall.html), [*services get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceGetCall.html), [*services list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceListCall.html), [*services patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServicePatchCall.html), [*services versions create*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionCreateCall.html), [*services versions delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionDeleteCall.html), [*services versions get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionGetCall.html), [*services versions list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionListCall.html) and [*services versions patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionPatchCall.html) + * [*create*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppCreateCall.html), [*get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppGetCall.html), [*locations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppLocationGetCall.html), [*locations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppLocationListCall.html), [*operations get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppOperationGetCall.html), [*operations list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppOperationListCall.html), [*services delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceDeleteCall.html), [*services get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceGetCall.html), [*services list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceListCall.html), [*services patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServicePatchCall.html), [*services versions create*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionCreateCall.html), [*services versions delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionDeleteCall.html), [*services versions get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionGetCall.html), [*services versions instances debug*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionInstanceDebugCall.html), [*services versions instances delete*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionInstanceDeleteCall.html), [*services versions instances get*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionInstanceGetCall.html), [*services versions instances list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionInstanceListCall.html), [*services versions list*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionListCall.html) and [*services versions patch*](http://byron.github.io/google-apis-rs/google_appengine1_beta5/struct.AppServiceVersionPatchCall.html) @@ -48,6 +48,9 @@ Or specifically ... ```ignore let r = hub.apps().services_versions_create(...).doit() +let r = hub.apps().services_versions_instances_debug(...).doit() +let r = hub.apps().create(...).doit() +let r = hub.apps().services_versions_instances_delete(...).doit() let r = hub.apps().services_versions_patch(...).doit() let r = hub.apps().operations_get(...).doit() let r = hub.apps().services_versions_delete(...).doit() @@ -77,7 +80,7 @@ google-appengine1_beta5 = "*" extern crate hyper; extern crate yup_oauth2 as oauth2; extern crate google_appengine1_beta5 as appengine1_beta5; -use appengine1_beta5::Version; +use appengine1_beta5::DebugInstanceRequest; use appengine1_beta5::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -98,13 +101,12 @@ let mut hub = Appengine::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 = Version::default(); +let mut req = DebugInstanceRequest::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.apps().services_versions_patch(req, "appsId", "servicesId", "versionsId") - .mask("sed") +let result = hub.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") .doit(); match result { diff --git a/gen/appengine1_beta5/src/lib.rs b/gen/appengine1_beta5/src/lib.rs index 753dda4d6b..a027476bef 100644 --- a/gen/appengine1_beta5/src/lib.rs +++ b/gen/appengine1_beta5/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *appengine* crate version *0.1.14+20160314*, where *20160314* is the exact revision of the *appengine:v1beta5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *appengine* crate version *0.1.14+20160802*, where *20160802* is the exact revision of the *appengine:v1beta5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *appengine* *v1_beta5* API can be found at the //! [official documentation site](https://cloud.google.com/appengine/docs/admin-api/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Appengine.html) ... //! //! * apps -//! * [*get*](struct.AppGetCall.html), [*operations get*](struct.AppOperationGetCall.html), [*operations list*](struct.AppOperationListCall.html), [*services delete*](struct.AppServiceDeleteCall.html), [*services get*](struct.AppServiceGetCall.html), [*services list*](struct.AppServiceListCall.html), [*services patch*](struct.AppServicePatchCall.html), [*services versions create*](struct.AppServiceVersionCreateCall.html), [*services versions delete*](struct.AppServiceVersionDeleteCall.html), [*services versions get*](struct.AppServiceVersionGetCall.html), [*services versions list*](struct.AppServiceVersionListCall.html) and [*services versions patch*](struct.AppServiceVersionPatchCall.html) +//! * [*create*](struct.AppCreateCall.html), [*get*](struct.AppGetCall.html), [*locations get*](struct.AppLocationGetCall.html), [*locations list*](struct.AppLocationListCall.html), [*operations get*](struct.AppOperationGetCall.html), [*operations list*](struct.AppOperationListCall.html), [*services delete*](struct.AppServiceDeleteCall.html), [*services get*](struct.AppServiceGetCall.html), [*services list*](struct.AppServiceListCall.html), [*services patch*](struct.AppServicePatchCall.html), [*services versions create*](struct.AppServiceVersionCreateCall.html), [*services versions delete*](struct.AppServiceVersionDeleteCall.html), [*services versions get*](struct.AppServiceVersionGetCall.html), [*services versions instances debug*](struct.AppServiceVersionInstanceDebugCall.html), [*services versions instances delete*](struct.AppServiceVersionInstanceDeleteCall.html), [*services versions instances get*](struct.AppServiceVersionInstanceGetCall.html), [*services versions instances list*](struct.AppServiceVersionInstanceListCall.html), [*services versions list*](struct.AppServiceVersionListCall.html) and [*services versions patch*](struct.AppServiceVersionPatchCall.html) //! //! //! @@ -48,6 +48,9 @@ //! //! ```ignore //! let r = hub.apps().services_versions_create(...).doit() +//! let r = hub.apps().services_versions_instances_debug(...).doit() +//! let r = hub.apps().create(...).doit() +//! let r = hub.apps().services_versions_instances_delete(...).doit() //! let r = hub.apps().services_versions_patch(...).doit() //! let r = hub.apps().operations_get(...).doit() //! let r = hub.apps().services_versions_delete(...).doit() @@ -77,7 +80,7 @@ //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; //! extern crate google_appengine1_beta5 as appengine1_beta5; -//! use appengine1_beta5::Version; +//! use appengine1_beta5::DebugInstanceRequest; //! use appengine1_beta5::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; @@ -99,13 +102,12 @@ //! // 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 = Version::default(); +//! let mut req = DebugInstanceRequest::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.apps().services_versions_patch(req, "appsId", "servicesId", "versionsId") -//! .mask("sea") +//! let result = hub.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") //! .doit(); //! //! match result { diff --git a/gen/appengine1_beta5/src/lib.rs.in b/gen/appengine1_beta5/src/lib.rs.in index e6e25b0777..22c0635e48 100644 --- a/gen/appengine1_beta5/src/lib.rs.in +++ b/gen/appengine1_beta5/src/lib.rs.in @@ -70,7 +70,7 @@ impl Default for Scope { /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_appengine1_beta5 as appengine1_beta5; -/// use appengine1_beta5::Version; +/// use appengine1_beta5::DebugInstanceRequest; /// use appengine1_beta5::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; @@ -92,13 +92,12 @@ impl Default for Scope { /// // 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 = Version::default(); +/// let mut req = DebugInstanceRequest::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.apps().services_versions_patch(req, "appsId", "servicesId", "versionsId") -/// .mask("accusam") +/// let result = hub.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") /// .doit(); /// /// match result { @@ -157,26 +156,47 @@ impl<'a, C, A> Appengine // ############ // SCHEMAS ### // ########## -/// Used to specify extra network settings (for VM runtimes only). +/// Response message for `Instances.ListInstances`. +/// +/// # 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*). +/// +/// * [services versions instances list apps](struct.AppServiceVersionInstanceListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListInstancesResponse { + /// Continuation token for fetching the next page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The instances belonging to the requested version. + pub instances: Option>, +} + +impl ResponseResult for ListInstancesResponse {} + + +/// Extra network settings. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Network { - /// A tag to apply to the VM instance during creation. + /// Tag to apply to the VM instance during creation. #[serde(rename="instanceTag")] pub instance_tag: Option, - /// A list of ports (or port pairs) to forward from the VM into the app container. + /// List of ports, or port pairs, to forward from the virtual machine to the application container. #[serde(rename="forwardedPorts")] pub forwarded_ports: Option>, - /// The Google Compute Engine network where the VMs will be created. If not specified, or empty, the network named "default" will be used. (The short name should be specified, not the resource path.) + /// Google Cloud Platform network where the virtual machines are created. Specify the short name, not the resource path. Defaults to `default`. pub name: Option, } impl Part for Network {} -/// A service is a logical component of an application that can share state and communicate in a secure fashion with other services. For example, an application that handles customer requests might include separate services to handle other tasks such as API requests from mobile devices or backend data analysis. Each service has a collection of versions that define a specific set of code used to implement the functionality of that service. +/// A Service resource is a logical component of an application that can share state and communicate in a secure fashion with other services. For example, an application that handles customer requests might include separate services to handle other tasks such as API requests from mobile devices or backend data analysis. Each service has a collection of versions that define a specific set of code used to implement the functionality of that service. /// /// # Activities /// @@ -188,11 +208,11 @@ impl Part for Network {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Service { - /// A mapping that defines fractional HTTP traffic diversion to different versions within the service. + /// Mapping that defines fractional HTTP traffic diversion to different versions within the service. pub split: Option, - /// The relative name/path of the service within the application. Example: "default" @OutputOnly + /// Relative name of the service within the application. Example: `default`. @OutputOnly pub id: Option, - /// The full path to the Service resource in the API. Example: "apps/myapp/services/default" @OutputOnly + /// Full path to the Service resource in the API. Example: `apps/myapp/services/default`. @OutputOnly pub name: Option, } @@ -200,47 +220,49 @@ impl RequestValue for Service {} impl ResponseResult for Service {} -/// An Application contains the top-level configuration of an App Engine application. +/// An Application resource contains the top-level configuration of an App Engine application. /// /// # 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*). /// +/// * [create apps](struct.AppCreateCall.html) (request) /// * [get apps](struct.AppGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Application { - /// The hostname used to reach the application, as resolved by App Engine. @OutputOnly + /// Hostname used to reach the application, as resolved by App Engine. @OutputOnly #[serde(rename="defaultHostname")] pub default_hostname: Option, - /// The full path to the application in the API. Example: "apps/myapp". @OutputOnly + /// Full path to the Application resource in the API. Example: `apps/myapp`. @OutputOnly pub name: Option, - /// A Google Cloud Storage bucket which can be used for storing files associated with an application. This bucket is associated with the application and can be used by the gcloud deployment commands. @OutputOnly + /// A Google Cloud Storage bucket that can be used for storing files associated with this application. This bucket is associated with the application and can be used by the gcloud deployment commands. @OutputOnly #[serde(rename="codeBucket")] pub code_bucket: Option, - /// A Google Cloud Storage bucket which can be used by the application to store content. @OutputOnly + /// A Google Cloud Storage bucket that can be used by the application to store content. @OutputOnly #[serde(rename="defaultBucket")] pub default_bucket: Option, - /// HTTP path dispatch rules for requests to the app that do not explicitly target a service or version. The rules are order-dependent. @OutputOnly + /// HTTP path dispatch rules for requests to the application that do not explicitly target a service or version. Rules are order-dependent. @OutputOnly #[serde(rename="dispatchRules")] pub dispatch_rules: Option>, - /// Determines the cookie expiration policy for the application. @OutputOnly + /// Cookie expiration policy for this application. @OutputOnly #[serde(rename="defaultCookieExpiration")] pub default_cookie_expiration: Option, - /// The location from which the application will be run. Application instances will run out of data centers in the chosen location and all of the application's End User Content will be stored at rest. The default is "us-central". Choices are: "us-central" - Central US "europe-west" - Western Europe "us-east1" - Eastern US + /// Location from which this application will be run. Application instances will run out of data centers in the chosen location, which is also where all of the application's end user content is stored. Defaults to `us-central`. Options are: `us-central` - Central US `europe-west` - Western Europe `us-east1` - Eastern US pub location: Option, - /// If set, only users from the specified Google Apps authentication domain may access the application. If not set, any Google Account may access the application. + /// Google Apps authentication domain that controls which users can access this application. Defaults to open access for any Google Account. #[serde(rename="authDomain")] pub auth_domain: Option, - /// The relative name/path of the application. Example: "myapp". + /// Identifier of the Application resource. This identifier is equivalent to the project ID of the Google Cloud Platform project where you want to deploy your application. Example: `myapp`. pub id: Option, } +impl RequestValue for Application {} impl ResponseResult for Application {} -/// A Version is a specific set of source code and configuration files deployed to a service. +/// A Version resource is a specific set of source code and configuration files that are deployed into a service. /// /// # Activities /// @@ -256,71 +278,71 @@ pub struct Version { /// A service with basic scaling will create an instance when the application receives a request. The instance will be turned down when the app becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. #[serde(rename="basicScaling")] pub basic_scaling: Option, - /// Beta settings supplied to the application via metadata. + /// Metadata settings that are supplied to this version to enable beta runtime features. #[serde(rename="betaSettings")] pub beta_settings: Option>, /// A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. #[serde(rename="manualScaling")] pub manual_scaling: Option, - /// Creation time of this version. This will be between the start and end times of the operation that creates this version. @OutputOnly + /// Time that this version was created. @OutputOnly #[serde(rename="creationTime")] pub creation_time: Option, - /// Whether to deploy this app in a VM container. + /// Whether to deploy this version in a container on a virtual machine. pub vm: Option, /// Before an application can receive email or XMPP messages, the application must be configured to enable the service. #[serde(rename="inboundServices")] pub inbound_services: Option>, - /// The instance class to use to run this app. Valid values for AutomaticScaling are `[F1, F2, F4, F4_1G]`. Valid values for ManualScaling and BasicScaling are `[B1, B2, B4, B8, B4_1G]`. Default: "F1" for AutomaticScaling, "B1" for ManualScaling and BasicScaling + /// Instance class that is used to run this version. Valid values are: * AutomaticScaling: `F1`, `F2`, `F4`, `F4_1G` * ManualScaling or BasicScaling: `B1`, `B2`, `B4`, `B8`, `B4_1G` Defaults to `F1` for AutomaticScaling and `B1` for ManualScaling or BasicScaling. #[serde(rename="instanceClass")] pub instance_class: Option, - /// Code and application artifacts that make up this version. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Code and application artifacts that make up this version. Only returned in `GET` requests if `view=FULL` is set. pub deployment: Option, - /// Custom static error pages instead of these generic error pages, (limit 10 KB/page) Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Custom static error pages. Limited to 10KB per page. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="errorHandlers")] pub error_handlers: Option>, - /// The current serving status of this version. Only `SERVING` versions will have instances created or billed for. If this field is unset when a version is created, `SERVING` status will be assumed. It is an error to explicitly set this field to `SERVING_STATUS_UNSPECIFIED`. + /// Current serving status of this version. Only the versions with a `SERVING` status create instances and can be billed. `SERVING_STATUS_UNSPECIFIED` is an invalid value. Defaults to `SERVING`. #[serde(rename="servingStatus")] pub serving_status: Option, - /// The relative name/path of the Version within the service. Example: "v1". Version specifiers can contain lowercase letters, digits, and hyphens. It cannot begin with the prefix `ah-` and the names `default` and `latest` are reserved and cannot be used. + /// Relative name of the version within the module. Example: `v1`. Version names can contain only lowercase letters, numbers, or hyphens. Reserved names: "default", "latest", and any name with the prefix "ah-". pub id: Option, - /// If true, multiple requests can be dispatched to the app at once. + /// Whether multiple requests can be dispatched to this version at once. pub threadsafe: Option, - /// Serving configuration for Google Cloud Endpoints. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Serving configuration for [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/). Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="apiConfig")] pub api_config: Option, - /// Go only. Files that match this pattern will not be built into the app. May only be set on create requests. + /// Files that match this pattern will not be built into this version. Only applicable for Go runtimes. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="nobuildFilesRegex")] pub nobuild_files_regex: Option, - /// Used to specify extra network settings (for VM runtimes only). + /// Extra network settings. Only applicable for VM runtimes. pub network: Option, - /// An ordered list of URL Matching patterns that should be applied to incoming requests. The first matching URL consumes the request, and subsequent handlers are not attempted. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// An ordered list of URL-matching patterns that should be applied to incoming requests. The first matching URL handles the request and other request handlers are not attempted. Only returned in `GET` requests if `view=FULL` is set. pub handlers: Option>, - /// Configure health checking for the VM instances. Unhealthy VM instances will be stopped and replaced with new instances. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Configures health checking for VM instances. Unhealthy instances are be stopped and replaced with new instances. Only applicable for VM runtimes. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="healthCheck")] pub health_check: Option, - /// The length of time a static file served by a static file handler ought to be cached by web proxies and browsers, if the handler does not specify its own expiration. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Duration that static files should be cached by web proxies and browsers. Only applicable if the corresponding [StaticFilesHandler](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#staticfileshandler) does not specify its own expiration time. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="defaultExpiration")] pub default_expiration: Option, - /// The full path to the Version resource in the API. Example: "apps/myapp/services/default/versions/v1". @OutputOnly + /// Full path to the Version resource in the API. Example: `apps/myapp/services/default/versions/v1`. @OutputOnly pub name: Option, - /// Configuration for Python runtime third-party libraries required by the application. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Configuration for third-party Python runtime libraries required by the application. Only returned in `GET` requests if `view=FULL` is set. pub libraries: Option>, - /// The email address of the user who created this version. @OutputOnly + /// Email address of the user who created this version. @OutputOnly pub deployer: Option, - /// The App Engine execution environment to use for this version. Default: "1" + /// App Engine execution environment to use for this version. Defaults to `1`. pub env: Option, /// Total size of version files hosted on App Engine disk in bytes. @OutputOnly #[serde(rename="diskUsageBytes")] pub disk_usage_bytes: Option, - /// Automatic scaling is the scaling policy that App Engine has used since its inception. It is based on request rate, response latencies, and other application metrics. + /// Automatic scaling is based on request rate, response latencies, and other application metrics. #[serde(rename="automaticScaling")] pub automatic_scaling: Option, - /// The desired runtime. Values can include python27, java7, go, etc. + /// Desired runtime. Example: `python27`. pub runtime: Option, - /// Environment variables made available to the application. Only returned in `GET` requests if `view=FULL` is set. May only be set on create requests; once created, is immutable. + /// Environment variables made available to the application. Only returned in `GET` requests if `view=FULL` is set. #[serde(rename="envVariables")] pub env_variables: Option>, - /// Used to specify how many machine resources an app version needs (for VM runtimes only). + /// Machine resources for this version. Only applicable for VM runtimes. pub resources: Option, } @@ -328,16 +350,77 @@ impl RequestValue for Version {} impl ResponseResult for Version {} +/// The response message for LocationService.ListLocations. +/// +/// # 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*). +/// +/// * [locations list apps](struct.AppLocationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListLocationsResponse { + /// The standard List next-page token. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// A list of locations that matches the specified filter in the request. + pub locations: Option>, +} + +impl ResponseResult for ListLocationsResponse {} + + +/// A resource that represents Google Cloud Platform location. +/// +/// # 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*). +/// +/// * [locations get apps](struct.AppLocationGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Location { + /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"} + pub labels: Option>, + /// The cononical id for this location. For example: `"us-east1"`. + #[serde(rename="locationId")] + pub location_id: Option, + /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"` + pub name: Option, + /// Service-specific metadata. For example the available capacity at the given location. + pub metadata: Option>, +} + +impl ResponseResult for Location {} + + +/// Request message for `Instances.DebugInstance`. +/// +/// # 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*). +/// +/// * [services versions instances debug apps](struct.AppServiceVersionInstanceDebugCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DebugInstanceRequest; + +impl RequestValue for DebugInstanceRequest {} + + /// Target scaling by CPU usage. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CpuUtilization { - /// Target (0-1) CPU utilization ratio to maintain when scaling. + /// Target CPU utilization ratio to maintain when scaling. Must be between 0 and 1. #[serde(rename="targetUtilization")] pub target_utilization: Option, - /// The period of time over which CPU utilization is calculated. + /// Period of time over which CPU utilization is calculated. #[serde(rename="aggregationWindowLength")] pub aggregation_window_length: Option, } @@ -345,18 +428,18 @@ pub struct CpuUtilization { impl Part for CpuUtilization {} -/// Used to specify how many machine resources an app version needs. +/// Machine resources for a version. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Resources { - /// How much disk size, in GB, an app version needs. + /// Disk size (GB) needed. #[serde(rename="diskGb")] pub disk_gb: Option, - /// How many CPU cores an app version needs. + /// Number of CPU cores needed. pub cpu: Option, - /// How much memory, in GB, an app version needs. + /// Memory (GB) needed. #[serde(rename="memoryGb")] pub memory_gb: Option, } @@ -387,10 +470,10 @@ impl Part for Status {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BasicScaling { - /// The instance will be shut down this amount of time after receiving its last request. + /// Duration of time after the last request that an instance must wait before the instance is shut down. #[serde(rename="idleTimeout")] pub idle_timeout: Option, - /// The maximum number of instances for App Engine to create for this version. + /// Maximum number of instances to create for this version. #[serde(rename="maxInstances")] pub max_instances: Option, } @@ -404,23 +487,23 @@ impl Part for BasicScaling {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StaticFilesHandler { - /// If specified, all files served by this handler will be served using the specified MIME type. If not specified, the MIME type for a file will be derived from the file's filename extension. + /// MIME type used to serve all files served by this handler. Defaults to file-specific MIME types, which are derived from each file's filename extension. #[serde(rename="mimeType")] pub mime_type: Option, - /// The length of time a static file served by this handler ought to be cached by web proxies and browsers. + /// Time a static file served by this handler should be cached. pub expiration: Option, - /// The path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. + /// Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. pub path: Option, - /// A regular expression that matches the file paths for all files that will be referenced by this handler. + /// Regular expression that matches the file paths for all files that should be referenced by this handler. #[serde(rename="uploadPathRegex")] pub upload_path_regex: Option, - /// If true, this UrlMap entry does not match the request unless the file referenced by the handler also exists. If no such file exists, processing will continue with the next UrlMap that matches the requested URL. + /// Whether this handler should match the request if the file referenced by the handler does not exist. #[serde(rename="requireMatchingFile")] pub require_matching_file: Option, /// HTTP headers to use for all responses from these URLs. #[serde(rename="httpHeaders")] pub http_headers: Option>, - /// By default, files declared in static file handlers are uploaded as static data and are only served to end users, they cannot be read by an application. If this field is set to true, the files are also uploaded as code data so your application can read them. Both uploads are charged against your code and static data storage resource quotas. + /// Whether files should also be uploaded as code data. By default, files declared in static file handlers are uploaded as static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged against both your code and static data storage resource quotas. #[serde(rename="applicationReadable")] pub application_readable: Option, } @@ -428,22 +511,22 @@ pub struct StaticFilesHandler { impl Part for StaticFilesHandler {} -/// Target scaling by network usage (for VM runtimes only). +/// Target scaling by network usage. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkUtilization { - /// Target bytes per second received. + /// Target bytes received per second. #[serde(rename="targetReceivedBytesPerSec")] pub target_received_bytes_per_sec: Option, - /// Target bytes per second sent. + /// Target bytes sent per second. #[serde(rename="targetSentBytesPerSec")] pub target_sent_bytes_per_sec: Option, - /// Target packets per second sent. + /// Target packets sent per second. #[serde(rename="targetSentPacketsPerSec")] pub target_sent_packets_per_sec: Option, - /// Target packets per second received. + /// Target packets received per second. #[serde(rename="targetReceivedPacketsPerSec")] pub target_received_packets_per_sec: Option, } @@ -465,7 +548,7 @@ pub struct ListVersionsResponse { /// Continuation token for fetching the next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// The versions belonging to the requested application service. + /// The versions belonging to the requested service. pub versions: Option>, } @@ -478,12 +561,12 @@ impl ResponseResult for ListVersionsResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Deployment { - /// A manifest of files stored in Google Cloud Storage which should be included as part of this application. All files must be readable using the credentials supplied with this call. + /// Manifest of the files stored in Google Cloud Storage that are included as part of this version. All files must be readable using the credentials supplied with this call. pub files: Option>, - /// The origin of the source code for this deployment. There can be more than one source reference per Version if source code is distributed among multiple repositories. + /// Origin of the source code for this deployment. There can be more than one source reference per version if source code is distributed among multiple repositories. #[serde(rename="sourceReferences")] pub source_references: Option>, - /// If supplied, a docker (container) image which should be used to start the application. Only applicable to the 'vm' runtime. + /// A Docker image that App Engine uses the run the version. Only applicable for instances in App Engine flexible environment. pub container: Option, } @@ -496,7 +579,7 @@ impl Part for Deployment {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ScriptHandler { - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. #[serde(rename="scriptPath")] pub script_path: Option, } @@ -510,24 +593,24 @@ impl Part for ScriptHandler {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlDispatchRule { - /// The pathname within the host. This must start with a '/'. A single '*' (glob) can be included at the end of the path. The sum of the lengths of the domain and path may not exceed 100 characters. + /// Pathname within the host. Must start with a "`/`". A single "`*`" can be included at the end of the path. The sum of the lengths of the domain and path may not exceed 100 characters. pub path: Option, - /// The domain name to match on. Supports '*' (glob) wildcarding on the left-hand side of a '.'. If empty, all domains will be matched (the same as '*'). + /// Domain name to match against. The wildcard "`*`" is supported if specified before a period: "`*.`". Defaults to matching all domains: "`*`". pub domain: Option, - /// The resource id of a Service in this application that should service the matched request. The Service must already exist. Example: "default". + /// Resource id of a service in this application that should serve the matched request. The service must already exist. Example: `default`. pub service: Option, } impl Part for UrlDispatchRule {} -/// Use Google Cloud Endpoints to handle requests. +/// Uses Google Cloud Endpoints to handle requests. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApiEndpointHandler { - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. #[serde(rename="scriptPath")] pub script_path: Option, } @@ -535,29 +618,29 @@ pub struct ApiEndpointHandler { impl Part for ApiEndpointHandler {} -/// Configure health checking for the VM instances. Unhealthy VM instances will be killed and replaced with new instances. +/// Health checking configuration for VM instances. Unhealthy instances are killed and replaced with new instances. Only applicable for instances in App Engine flexible environment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HealthCheck { - /// The number of consecutive successful health checks before receiving traffic. + /// Number of consecutive successful health checks required before receiving traffic. #[serde(rename="healthyThreshold")] pub healthy_threshold: Option, - /// The number of consecutive failed health checks before an instance is restarted. + /// Number of consecutive failed health checks required before an instance is restarted. #[serde(rename="restartThreshold")] pub restart_threshold: Option, - /// The amount of time before the health check is considered failed. + /// Time before the health check is considered failed. pub timeout: Option, - /// The interval between health checks. + /// Interval between health checks. #[serde(rename="checkInterval")] pub check_interval: Option, /// Whether to explicitly disable health checks for this instance. #[serde(rename="disableHealthCheck")] pub disable_health_check: Option, - /// The host header to send when performing an HTTP health check (e.g. myapp.appspot.com) + /// Host header to send when performing an HTTP health check. Example: "myapp.appspot.com" pub host: Option, - /// The number of consecutive failed health checks before removing traffic. + /// Number of consecutive failed health checks required before removing traffic. #[serde(rename="unhealthyThreshold")] pub unhealthy_threshold: Option, } @@ -565,16 +648,16 @@ pub struct HealthCheck { impl Part for HealthCheck {} -/// A custom static error page to be served when an error occurs. +/// Custom static error page to be served when an error occurs. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ErrorHandler { - /// The error condition this handler applies to. + /// Error condition this handler applies to. #[serde(rename="errorCode")] pub error_code: Option, - /// MIME type of file. If unspecified, "text/html" is assumed. + /// MIME type of file. Defaults to `text/html`. #[serde(rename="mimeType")] pub mime_type: Option, /// Static file content to be served for this error. @@ -585,7 +668,7 @@ pub struct ErrorHandler { impl Part for ErrorHandler {} -/// Automatic scaling is the scaling policy that App Engine has used since its inception. It is based on request rate, response latencies, and other application metrics. +/// Automatic scaling is based on request rate, response latencies, and other application metrics. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -597,13 +680,13 @@ pub struct AutomaticScaling { /// Target scaling by network usage. #[serde(rename="networkUtilization")] pub network_utilization: Option, - /// The minimum number of idle instances that App Engine should maintain for this version. Only applies to the default version of a service, since other versions are not expected to receive significant traffic. + /// Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a module. #[serde(rename="minIdleInstances")] pub min_idle_instances: Option, - /// The maximum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. + /// Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it. #[serde(rename="maxPendingLatency")] pub max_pending_latency: Option, - /// The maximum number of idle instances that App Engine should maintain for this version. + /// Maximum number of idle instances that should be maintained for this version. #[serde(rename="maxIdleInstances")] pub max_idle_instances: Option, /// Target scaling by disk usage. @@ -612,19 +695,19 @@ pub struct AutomaticScaling { /// Target scaling by request utilization. #[serde(rename="requestUtilization")] pub request_utilization: Option, - /// The amount of time that the [Autoscaler](https://cloud.google.com/compute/docs/autoscaler/) should wait between changes to the number of virtual machines. Applies only to the VM runtime. + /// Amount of time that the [Autoscaler](https://cloud.google.com/compute/docs/autoscaler/) should wait between changes to the number of virtual machines. Only applicable for VM runtimes. #[serde(rename="coolDownPeriod")] pub cool_down_period: Option, - /// Max number of instances that App Engine should start to handle requests. + /// Maximum number of instances that should be started to handle requests. #[serde(rename="maxTotalInstances")] pub max_total_instances: Option, - /// The number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Default value is chosen based on the runtime. + /// Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Defaults to a runtime-specific value. #[serde(rename="maxConcurrentRequests")] pub max_concurrent_requests: Option, - /// Minimum number of instances that App Engine should maintain. + /// Minimum number of instances that should be maintained for this version. #[serde(rename="minTotalInstances")] pub min_total_instances: Option, - /// The minimum amount of time that App Engine should allow a request to wait in the pending queue before starting a new instance to handle it. + /// Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it. #[serde(rename="minPendingLatency")] pub min_pending_latency: Option, } @@ -632,32 +715,32 @@ pub struct AutomaticScaling { impl Part for AutomaticScaling {} -/// A URL pattern and description of how it should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS or JavaScript. +/// URL pattern and description of how the URL should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the version, such as images, CSS, or JavaScript. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlMap { - /// Configures whether security (HTTPS) should be enforced for this URL. + /// Security (HTTPS) enforcement for this URL. #[serde(rename="securityLevel")] pub security_level: Option, - /// For users not logged in, how to handle access to resources with required login. Defaults to "redirect". + /// Action to take when users access resources that require authentication. Defaults to `redirect`. #[serde(rename="authFailAction")] pub auth_fail_action: Option, - /// A URL prefix. This value uses regular expression syntax (and so regexp special characters must be escaped), but it should not contain groupings. All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. This is always required. + /// A URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings. All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. #[serde(rename="urlRegex")] pub url_regex: Option, - /// Executes a script to handle the request that matches the URL pattern. + /// Executes a script to handle the request that matches this URL pattern. pub script: Option, /// Returns the contents of a file, such as an image, as the response. #[serde(rename="staticFiles")] pub static_files: Option, - /// Use API Endpoints to handle requests. + /// Uses API Endpoints to handle requests. #[serde(rename="apiEndpoint")] pub api_endpoint: Option, - /// What level of login is required to access this resource. + /// Level of login required to access this resource. pub login: Option, - /// `30x` code to use when performing redirects for the `secure` field. A `302` is used by default. + /// `30x` code to use when performing redirects for the `secure` field. Defaults to `302`. #[serde(rename="redirectHttpResponseCode")] pub redirect_http_response_code: Option, } @@ -665,19 +748,19 @@ pub struct UrlMap { impl Part for UrlMap {} -/// A single source file which is part of the application to be deployed. +/// Single source file that is part of the version to be deployed. Each source file that is deployed must be specified separately. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileInfo { - /// The MIME type of the file; if unspecified, the value from Google Cloud Storage will be used. + /// The MIME type of the file. Defaults to the value from Google Cloud Storage. #[serde(rename="mimeType")] pub mime_type: Option, - /// The URL source to use to fetch this file. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. + /// URL source to use to fetch this file. Must be a URL to a resource in Google Cloud Storage in the form 'http(s)://storage.googleapis.com/\/\'. #[serde(rename="sourceUrl")] pub source_url: Option, - /// The SHA1 (160 bits) hash of the file in hex. + /// The SHA1 hash of the file, in hex. #[serde(rename="sha1Sum")] pub sha1_sum: Option, } @@ -706,33 +789,88 @@ pub struct ListOperationsResponse { impl ResponseResult for ListOperationsResponse {} +/// An Instance resource is the computing unit that App Engine uses to automatically scale an application. +/// +/// # 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*). +/// +/// * [services versions instances get apps](struct.AppServiceVersionInstanceGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Instance { + /// Number of errors since this instance was started. @OutputOnly + pub errors: Option, + /// Full path to the Instance resource in the API. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. @OutputOnly + pub name: Option, + /// Whether this instance is in debug mode. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmUnlocked")] + pub vm_unlocked: Option, + /// App Engine release this instance is running on. @OutputOnly + #[serde(rename="appEngineRelease")] + pub app_engine_release: Option, + /// Virtual machine ID of this instance. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmId")] + pub vm_id: Option, + /// Total memory in use (bytes). @OutputOnly + #[serde(rename="memoryUsage")] + pub memory_usage: Option, + /// Availability of the instance. @OutputOnly + pub availability: Option, + /// Average latency (ms) over the last minute. @OutputOnly + #[serde(rename="averageLatency")] + pub average_latency: Option, + /// Relative name of the instance within the version. Example: `instance-1`. @OutputOnly + pub id: Option, + /// Average queries per second (QPS) over the last minute. @OutputOnly + pub qps: Option, + /// Number of requests since this instance was started. @OutputOnly + pub requests: Option, + /// Name of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmName")] + pub vm_name: Option, + /// Time that this instance was started. @OutputOnly + #[serde(rename="startTimestamp")] + pub start_timestamp: Option, + /// Zone where the virtual machine is located. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmZoneName")] + pub vm_zone_name: Option, + /// Status of the virtual machine where this instance lives. Only applicable for instances in App Engine flexible environment. @OutputOnly + #[serde(rename="vmStatus")] + pub vm_status: Option, +} + +impl ResponseResult for Instance {} + + /// A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ManualScaling { - /// The number of instances to assign to the service at the start. This number can later be altered by using the [Modules API](https://cloud.google.com/appengine/docs/python/modules/functions) `set_num_instances()` function. + /// Number of instances to assign to the service at the start. This number can later be altered by using the [Modules API](https://cloud.google.com/appengine/docs/python/modules/functions) `set_num_instances()` function. pub instances: Option, } impl Part for ManualScaling {} -/// A Docker (container) image which should be used to start the application. +/// Docker image that is used to start a VM container for the version you deploy. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContainerInfo { - /// Reference to a hosted container image. Must be a URI to a resource in a Docker repository. Must be fully qualified, including tag or digest. e.g. gcr.io/my-project/image:tag or gcr.io/my-project/image@digest + /// URI to the hosted container image in a Docker repository. The URI must be fully qualified and include a tag or digest. Examples: "gcr.io/my-project/image:tag" or "gcr.io/my-project/image@digest" pub image: Option, } impl Part for ContainerInfo {} -/// API Serving configuration for Cloud Endpoints. +/// [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/) configuration for API handlers. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -740,68 +878,68 @@ impl Part for ContainerInfo {} pub struct ApiConfigHandler { /// URL to serve the endpoint at. pub url: Option, - /// Configures whether security (HTTPS) should be enforced for this URL. + /// Security (HTTPS) enforcement for this URL. #[serde(rename="securityLevel")] pub security_level: Option, - /// For users not logged in, how to handle access to resources with required login. Defaults to "redirect". + /// Action to take when users access resources that require authentication. Defaults to `redirect`. #[serde(rename="authFailAction")] pub auth_fail_action: Option, - /// What level of login is required to access this resource. Default is "optional". + /// Level of login required to access this resource. Defaults to `optional`. pub login: Option, - /// Specifies the path to the script from the application root directory. + /// Path to the script from the application root directory. pub script: Option, } impl Part for ApiConfigHandler {} -/// A Python runtime third-party library required by the application. +/// Third-party Python runtime library that is required by the application. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Library { - /// The version of the library to select, or "latest". + /// Version of the library to select, or "latest". pub version: Option, - /// The name of the library, e.g. "PIL" or "django". + /// Name of the library. Example: "django". pub name: Option, } impl Part for Library {} -/// A reference to a particular snapshot of the source tree used to build and deploy the application. +/// Reference to a particular snapshot of the source tree used to build and deploy the application. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SourceReference { - /// The canonical (and persistent) identifier of the deployed revision, i.e. any kind of aliases including tags or branch names are not allowed. Example (git): "2198322f89e0bb2e25021667c2ed489d1fd34e6b" + /// The canonical, persistent identifier of the deployed revision. Aliases that include tags or branch names are not allowed. Example (git): "2198322f89e0bb2e25021667c2ed489d1fd34e6b" #[serde(rename="revisionId")] pub revision_id: Option, - /// Optional. A URI string identifying the repository. Example: "https://source.developers.google.com/p/app-123/r/default" + /// URI string identifying the repository. Example: "https://source.developers.google.com/p/app-123/r/default" pub repository: Option, } impl Part for SourceReference {} -/// Target scaling by disk usage (for VM runtimes only). +/// Target scaling by disk usage. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskUtilization { - /// Target ops per second written. + /// Target ops written per second. #[serde(rename="targetWriteOpsPerSec")] pub target_write_ops_per_sec: Option, - /// Target bytes per second read. + /// Target bytes read per second. #[serde(rename="targetReadBytesPerSec")] pub target_read_bytes_per_sec: Option, - /// Target ops per second read. + /// Target ops read per second. #[serde(rename="targetReadOpsPerSec")] pub target_read_ops_per_sec: Option, - /// Target bytes per second written. + /// Target bytes written per second. #[serde(rename="targetWriteBytesPerSec")] pub target_write_bytes_per_sec: Option, } @@ -809,7 +947,7 @@ pub struct DiskUtilization { impl Part for DiskUtilization {} -/// Target scaling by request utilization (for VM runtimes only). +/// Target scaling by request utilization. Only applicable for VM runtimes. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -847,16 +985,16 @@ pub struct ListServicesResponse { impl ResponseResult for ListServicesResponse {} -/// Configuration for traffic splitting for versions within a single service. Traffic splitting allows traffic directed to the service to be assigned to one of several versions in a fractional way, enabling experiments and canarying new builds, for example. +/// Traffic routing configuration for versions within a single service. Traffic splits define how traffic directed to the service is assigned to versions. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TrafficSplit { - /// Which mechanism should be used as a selector when choosing a version to send a request to. The traffic selection algorithm will be stable for either type until allocations are changed. + /// Mechanism used to determine which version a request is sent to. The traffic selection algorithm will be stable for either type until allocations are changed. #[serde(rename="shardBy")] pub shard_by: Option, - /// Mapping from service version IDs within the service to fractional (0.000, 1] allocations of traffic for that version. Each version may only be specified once, but some versions in the service may not have any traffic allocation. Services that have traffic allocated in this field may not be deleted until the service is deleted, or their traffic allocation is removed. Allocations must sum to 1. Supports precision up to two decimal places for IP-based splits and up to three decimal places for cookie-based splits. + /// Mapping from version IDs within the service to fractional (0.000, 1] allocations of traffic for that version. Each version can be specified only once, but some versions in the service may not have any traffic allocation. Services that have traffic allocated cannot be deleted until either the service is deleted or their traffic allocation is removed. Allocations must sum to 1. Up to two decimal place precision is supported for IP-based splits and up to three decimal places is supported for cookie-based splits. pub allocations: Option>, } @@ -871,6 +1009,9 @@ impl Part for TrafficSplit {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [services versions create apps](struct.AppServiceVersionCreateCall.html) (response) +/// * [services versions instances debug apps](struct.AppServiceVersionInstanceDebugCall.html) (response) +/// * [create apps](struct.AppCreateCall.html) (response) +/// * [services versions instances delete apps](struct.AppServiceVersionInstanceDeleteCall.html) (response) /// * [services versions patch apps](struct.AppServiceVersionPatchCall.html) (response) /// * [operations get apps](struct.AppOperationGetCall.html) (response) /// * [services versions delete apps](struct.AppServiceVersionDeleteCall.html) (response) @@ -922,7 +1063,7 @@ impl ResponseResult for Operation {} /// ::default(), None); /// let mut hub = Appengine::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `operations_get(...)`, `operations_list(...)`, `services_delete(...)`, `services_get(...)`, `services_list(...)`, `services_patch(...)`, `services_versions_create(...)`, `services_versions_delete(...)`, `services_versions_get(...)`, `services_versions_list(...)` and `services_versions_patch(...)` +/// // like `create(...)`, `get(...)`, `locations_get(...)`, `locations_list(...)`, `operations_get(...)`, `operations_list(...)`, `services_delete(...)`, `services_get(...)`, `services_list(...)`, `services_patch(...)`, `services_versions_create(...)`, `services_versions_delete(...)`, `services_versions_get(...)`, `services_versions_instances_debug(...)`, `services_versions_instances_delete(...)`, `services_versions_instances_get(...)`, `services_versions_instances_list(...)`, `services_versions_list(...)` and `services_versions_patch(...)` /// // to build up your call. /// let rb = hub.apps(); /// # } @@ -939,15 +1080,19 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all the services in the application. + /// Lists the instances of a version. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp". - pub fn services_list(&self, apps_id: &str) -> AppServiceListCall<'a, C, A> { - AppServiceListCall { + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_list(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + AppServiceVersionInstanceListCall { hub: self.hub, _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), @@ -958,7 +1103,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deploys new code and resource files to a version. + /// Deploys new code and resource files to a new version. /// /// # Arguments /// @@ -979,11 +1124,36 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets the current configuration of the service. + /// Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started. Only applicable for instances in App Engine flexible environment. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default". + /// * `request` - No description provided. + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_debug(&self, request: DebugInstanceRequest, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + AppServiceVersionInstanceDebugCall { + hub: self.hub, + _request: request, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the current configuration of the specified service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. pub fn services_get(&self, apps_id: &str, services_id: &str) -> AppServiceGetCall<'a, C, A> { AppServiceGetCall { @@ -998,12 +1168,35 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing version. Note: UNIMPLEMENTED. + /// Stops a running instance. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1/instances/instance-1". + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_delete(&self, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + AppServiceVersionInstanceDeleteCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.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 Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. /// /// # Arguments /// /// * `request` - No description provided. - /// * `appsId` - Part of `name`. Name of the resource to update. For example: "apps/myapp/services/default/versions/1". + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default/versions/1`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn services_versions_patch(&self, request: Version, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionPatchCall<'a, C, A> { @@ -1026,7 +1219,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. pub fn services_versions_list(&self, apps_id: &str, services_id: &str) -> AppServiceVersionListCall<'a, C, A> { AppServiceVersionListCall { @@ -1061,6 +1254,68 @@ impl<'a, C, A> AppMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Lists all the services in the application. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp`. + pub fn services_list(&self, apps_id: &str) -> AppServiceListCall<'a, C, A> { + AppServiceListCall { + hub: self.hub, + _apps_id: apps_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: + /// + /// Lists information about the supported locations for this service. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. The resource that owns the locations collection, if applicable. + pub fn locations_list(&self, apps_id: &str) -> AppLocationListCall<'a, C, A> { + AppLocationListCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _page_token: Default::default(), + _page_size: 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: + /// + /// Gets instance information. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// * `servicesId` - Part of `name`. See documentation of `appsId`. + /// * `versionsId` - Part of `name`. See documentation of `appsId`. + /// * `instancesId` - Part of `name`. See documentation of `appsId`. + pub fn services_versions_instances_get(&self, apps_id: &str, services_id: &str, versions_id: &str, instances_id: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + AppServiceVersionInstanceGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _services_id: services_id.to_string(), + _versions_id: versions_id.to_string(), + _instances_id: instances_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. @@ -1087,7 +1342,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn services_versions_delete(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionDeleteCall<'a, C, A> { @@ -1102,6 +1357,25 @@ impl<'a, C, A> AppMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Get information about a location. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Resource name for the location. + /// * `locationsId` - Part of `name`. See documentation of `appsId`. + pub fn locations_get(&self, apps_id: &str, locations_id: &str) -> AppLocationGetCall<'a, C, A> { + AppLocationGetCall { + hub: self.hub, + _apps_id: apps_id.to_string(), + _locations_id: locations_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Updates the configuration of the specified service. @@ -1109,7 +1383,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// # Arguments /// /// * `request` - No description provided. - /// * `appsId` - Part of `name`. Name of the resource to update. For example: "apps/myapp/services/default". + /// * `appsId` - Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. pub fn services_patch(&self, request: Service, apps_id: &str, services_id: &str) -> AppServicePatchCall<'a, C, A> { AppServicePatchCall { @@ -1131,7 +1405,7 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the application to get. For example: "apps/myapp". + /// * `appsId` - Part of `name`. Name of the application to get. Example: `apps/myapp`. pub fn get(&self, apps_id: &str) -> AppGetCall<'a, C, A> { AppGetCall { hub: self.hub, @@ -1145,11 +1419,11 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a service and all enclosed versions. + /// Deletes the specified service and all enclosed versions. /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default". + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. pub fn services_delete(&self, apps_id: &str, services_id: &str) -> AppServiceDeleteCall<'a, C, A> { AppServiceDeleteCall { @@ -1164,11 +1438,28 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets application deployment information. + /// Creates an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project). /// /// # Arguments /// - /// * `appsId` - Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1". + /// * `request` - No description provided. + pub fn create(&self, request: Application) -> AppCreateCall<'a, C, A> { + AppCreateCall { + 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: + /// + /// Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource. + /// + /// # Arguments + /// + /// * `appsId` - Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. /// * `servicesId` - Part of `name`. See documentation of `appsId`. /// * `versionsId` - Part of `name`. See documentation of `appsId`. pub fn services_versions_get(&self, apps_id: &str, services_id: &str, versions_id: &str) -> AppServiceVersionGetCall<'a, C, A> { @@ -1193,9 +1484,9 @@ impl<'a, C, A> AppMethods<'a, C, A> { // CallBuilders ### // ################# -/// Lists all the services in the application. +/// Lists the instances of a version. /// -/// A builder for the *services.list* method supported by a *app* resource. +/// A builder for the *services.versions.instances.list* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. /// /// # Example @@ -1219,17 +1510,19 @@ impl<'a, C, A> AppMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.apps().services_list("appsId") -/// .page_token("justo") -/// .page_size(-1) +/// let result = hub.apps().services_versions_instances_list("appsId", "servicesId", "versionsId") +/// .page_token("erat") +/// .page_size(-35) /// .doit(); /// # } /// ``` -pub struct AppServiceListCall<'a, C, A> +pub struct AppServiceVersionInstanceListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Appengine, _apps_id: String, + _services_id: String, + _versions_id: String, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut Delegate>, @@ -1237,13 +1530,13 @@ pub struct AppServiceListCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for AppServiceListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceListCall<'a, C, A> {} -impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> AppServiceVersionInstanceListCall<'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, ListServicesResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListInstancesResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1251,17 +1544,19 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "appengine.apps.services.list", + dlg.begin(MethodInfo { id: "appengine.apps.services.versions.instances.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_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", "appsId", "pageToken", "pageSize"].iter() { + for &field in ["alt", "appsId", "servicesId", "versionsId", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1273,12 +1568,12 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://appengine.googleapis.com/v1beta5/apps/{appsId}/services".to_string(); + let mut url = "https://appengine.googleapis.com/v1beta5/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{appsId}", "appsId")].iter() { + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -1289,8 +1584,8 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A 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 ["appsId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["versionsId", "servicesId", "appsId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -1376,27 +1671,47 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A } - /// Part of `name`. Name of the resource requested. For example: "apps/myapp". + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1`. /// /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + pub fn apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { self._apps_id = new_value.to_string(); self } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } /// Continuation token for fetching the next page of results. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> AppServiceVersionInstanceListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Maximum results to return per page. /// /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> AppServiceListCall<'a, C, A> { + pub fn page_size(mut self, new_value: i32) -> AppServiceVersionInstanceListCall<'a, C, A> { self._page_size = Some(new_value); self } @@ -1406,7 +1721,7 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AppServiceListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AppServiceVersionInstanceListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1433,7 +1748,7 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A /// * *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) -> AppServiceListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> AppServiceVersionInstanceListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1450,7 +1765,7 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A /// 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) -> AppServiceListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> AppServiceVersionInstanceListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -1458,7 +1773,7 @@ impl<'a, C, A> AppServiceListCall<'a, C, A> where C: BorrowMut, A } -/// Deploys new code and resource files to a version. +/// Deploys new code and resource files to a new version. /// /// A builder for the *services.versions.create* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -1742,7 +2057,315 @@ impl<'a, C, A> AppServiceVersionCreateCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Appengine::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 = DebugInstanceRequest::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.apps().services_versions_instances_debug(req, "appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceDebugCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: DebugInstanceRequest, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceDebugCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceDebugCall<'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: "appengine.apps.services.versions.instances.debug", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta5/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}:debug".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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: DebugInstanceRequest) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._request = new_value; + self + } + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceDebugCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceDebugCall<'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) -> AppServiceVersionInstanceDebugCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the current configuration of the specified service. /// /// A builder for the *services.get* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -1917,7 +2540,7 @@ impl<'a, C, A> AppServiceGetCall<'a, C, A> where C: BorrowMut, A: } - /// Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default". + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -1995,7 +2618,284 @@ impl<'a, C, A> AppServiceGetCall<'a, C, A> where C: BorrowMut, A: } -/// Updates an existing version. Note: UNIMPLEMENTED. +/// Stops a running instance. +/// +/// A builder for the *services.versions.instances.delete* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta5 as appengine1_beta5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta5::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_instances_delete("appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceDeleteCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceDeleteCall<'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: "appengine.apps.services.versions.instances.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta5/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default/versions/v1/instances/instance-1". + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceDeleteCall<'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) -> AppServiceVersionInstanceDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses: * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.serving_status): For Version resources that use basic scaling, manual scaling, or run in the App Engine flexible environment. * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.instance_class): For Version resources that run in the App Engine standard environment. * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#Version.FIELDS.automatic_scaling): For Version resources that use automatic scaling and run in the App Engine standard environment. /// /// A builder for the *services.versions.patch* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -2028,7 +2928,7 @@ impl<'a, C, A> AppServiceGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().services_versions_patch(req, "appsId", "servicesId", "versionsId") -/// .mask("aliquyam") +/// .mask("et") /// .doit(); /// # } /// ``` @@ -2208,7 +3108,7 @@ impl<'a, C, A> AppServiceVersionPatchCall<'a, C, A> where C: BorrowMut AppServiceVersionPatchCall<'a, C, A> where C: BorrowMut AppServiceVersionListCall<'a, C, A> where C: BorrowMut AppOperationGetCall<'a, C, A> where C: BorrowMut, } +/// Lists all the services in the application. +/// +/// A builder for the *services.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta5 as appengine1_beta5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta5::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_list("appsId") +/// .page_token("eirmod") +/// .page_size(-43) +/// .doit(); +/// # } +/// ``` +pub struct AppServiceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceListCall<'a, C, A> {} + +impl<'a, C, A> AppServiceListCall<'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, ListServicesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.services.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("appsId", self._apps_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", "appsId", "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://appengine.googleapis.com/v1beta5/apps/{appsId}/services".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Continuation token for fetching the next page of results. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppServiceListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum results to return per page. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppServiceListCall<'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) -> AppServiceListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceListCall<'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) -> AppServiceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists information about the supported locations for this service. +/// +/// A builder for the *locations.list* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta5 as appengine1_beta5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta5::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().locations_list("appsId") +/// .page_token("no") +/// .page_size(-36) +/// .filter("eirmod") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _page_token: Option, + _page_size: Option, + _filter: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationListCall<'a, C, A> {} + +impl<'a, C, A> AppLocationListCall<'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, ListLocationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_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 { + params.push(("filter", value.to_string())); + } + for &field in ["alt", "appsId", "pageToken", "pageSize", "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://appengine.googleapis.com/v1beta5/apps/{appsId}/locations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId")].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 ["appsId"].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) + } + } + } + } + + + /// Part of `name`. The resource that owns the locations collection, if applicable. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// The standard list page token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AppLocationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The standard list page size. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AppLocationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// The standard list filter. + /// + /// Sets the *filter* query property to the given value. + pub fn filter(mut self, new_value: &str) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationListCall<'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) -> AppLocationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets instance information. +/// +/// A builder for the *services.versions.instances.get* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta5 as appengine1_beta5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta5::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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.apps().services_versions_instances_get("appsId", "servicesId", "versionsId", "instancesId") +/// .doit(); +/// # } +/// ``` +pub struct AppServiceVersionInstanceGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _services_id: String, + _versions_id: String, + _instances_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppServiceVersionInstanceGetCall<'a, C, A> {} + +impl<'a, C, A> AppServiceVersionInstanceGetCall<'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: "appengine.apps.services.versions.instances.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("servicesId", self._services_id.to_string())); + params.push(("versionsId", self._versions_id.to_string())); + params.push(("instancesId", self._instances_id.to_string())); + for &field in ["alt", "appsId", "servicesId", "versionsId", "instancesId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta5/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{servicesId}", "servicesId"), ("{versionsId}", "versionsId"), ("{instancesId}", "instancesId")].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 ["instancesId", "versionsId", "servicesId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default/versions/v1/instances/instance-1`. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *services 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 services_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._services_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *versions 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 versions_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._versions_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *instances 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 instances_id(mut self, new_value: &str) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._instances_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) -> AppServiceVersionInstanceGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppServiceVersionInstanceGetCall<'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) -> AppServiceVersionInstanceGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. /// /// A builder for the *operations.list* method supported by a *app* resource. @@ -2872,7 +4591,7 @@ impl<'a, C, A> AppOperationGetCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().operations_list("appsId") -/// .page_token("Lorem") +/// .page_token("sea") /// .page_size(-21) /// .filter("duo") /// .doit(); @@ -3299,7 +5018,7 @@ impl<'a, C, A> AppServiceVersionDeleteCall<'a, C, A> where C: BorrowMut AppServiceVersionDeleteCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Appengine::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.apps().locations_get("appsId", "locationsId") +/// .doit(); +/// # } +/// ``` +pub struct AppLocationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _apps_id: String, + _locations_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppLocationGetCall<'a, C, A> {} + +impl<'a, C, A> AppLocationGetCall<'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, Location)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "appengine.apps.locations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("appsId", self._apps_id.to_string())); + params.push(("locationsId", self._locations_id.to_string())); + for &field in ["alt", "appsId", "locationsId"].iter() { + if self._additional_params.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://appengine.googleapis.com/v1beta5/apps/{appsId}/locations/{locationsId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{appsId}", "appsId"), ("{locationsId}", "locationsId")].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 ["locationsId", "appsId"].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) + } + } + } + } + + + /// Part of `name`. Resource name for the location. + /// + /// Sets the *apps 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 apps_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._apps_id = new_value.to_string(); + self + } + /// Part of `name`. See documentation of `appsId`. + /// + /// Sets the *locations 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 locations_id(mut self, new_value: &str) -> AppLocationGetCall<'a, C, A> { + self._locations_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) -> AppLocationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppLocationGetCall<'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) -> AppLocationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates the configuration of the specified service. /// /// A builder for the *services.patch* method supported by a *app* resource. @@ -3420,8 +5392,8 @@ impl<'a, C, A> AppServiceVersionDeleteCall<'a, C, A> where C: BorrowMut AppServicePatchCall<'a, C, A> where C: BorrowMut, self._request = new_value; self } - /// Part of `name`. Name of the resource to update. For example: "apps/myapp/services/default". + /// Part of `name`. Name of the resource to update. Example: `apps/myapp/services/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -3623,7 +5595,7 @@ impl<'a, C, A> AppServicePatchCall<'a, C, A> where C: BorrowMut, self._services_id = new_value.to_string(); self } - /// Whether to use Traffic Migration to shift traffic gradually. Traffic can only be migrated from a single version to another single version. + /// Set to `true` to gradually shift traffic from one version to another single version. By default, traffic is shifted immediately. For gradual traffic migration, the target version must be located within instances that are configured for both [warmup requests](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#inboundservicetype) and [automatic scaling](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions#automaticscaling). You must specify the [`shardBy`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services#shardby) field in the Service resource. Gradual traffic migration is not supported in the App Engine flexible environment. For examples, see [Migrating and Splitting Traffic](https://cloud.google.com/appengine/docs/admin-api/migrating-splitting-traffic). /// /// Sets the *migrate traffic* query property to the given value. pub fn migrate_traffic(mut self, new_value: bool) -> AppServicePatchCall<'a, C, A> { @@ -3873,7 +5845,7 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut, A: oauth2 } - /// Part of `name`. Name of the application to get. For example: "apps/myapp". + /// Part of `name`. Name of the application to get. Example: `apps/myapp`. /// /// Sets the *apps id* path property to the given value. /// @@ -3948,7 +5920,7 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut, A: oauth2 } -/// Deletes a service and all enclosed versions. +/// Deletes the specified service and all enclosed versions. /// /// A builder for the *services.delete* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -4123,7 +6095,7 @@ impl<'a, C, A> AppServiceDeleteCall<'a, C, A> where C: BorrowMut, } - /// Part of `name`. Name of the resource requested. For example: "apps/myapp/services/default". + /// Part of `name`. Name of the resource requested. Example: `apps/myapp/services/default`. /// /// Sets the *apps id* path property to the given value. /// @@ -4201,7 +6173,246 @@ impl<'a, C, A> AppServiceDeleteCall<'a, C, A> where C: BorrowMut, } -/// Gets application deployment information. +/// Creates an App Engine application for a Google Cloud Platform project. This requires a project that excludes an App Engine application. For details about creating a project without an application, see the [Google Cloud Resource Manager create project topic](https://cloud.google.com/resource-manager/docs/creating-project). +/// +/// A builder for the *create* method supported by a *app* resource. +/// It is not used directly, but through a `AppMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_appengine1_beta5 as appengine1_beta5; +/// use appengine1_beta5::Application; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use appengine1_beta5::Appengine; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Appengine::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 = Application::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.apps().create(req) +/// .doit(); +/// # } +/// ``` +pub struct AppCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Appengine, + _request: Application, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AppCreateCall<'a, C, A> {} + +impl<'a, C, A> AppCreateCall<'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: "appengine.apps.create", + 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://appengine.googleapis.com/v1beta5/apps".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.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: Application) -> AppCreateCall<'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) -> AppCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AppCreateCall<'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) -> AppCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify the `FULL_VIEW` parameter to get the full resource. /// /// A builder for the *services.versions.get* method supported by a *app* resource. /// It is not used directly, but through a `AppMethods` instance. @@ -4228,7 +6439,7 @@ impl<'a, C, A> AppServiceDeleteCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().services_versions_get("appsId", "servicesId", "versionsId") -/// .view("invidunt") +/// .view("voluptua.") /// .doit(); /// # } /// ``` @@ -4383,7 +6594,7 @@ impl<'a, C, A> AppServiceVersionGetCall<'a, C, A> where C: BorrowMut"] description = "A complete library to interact with appsactivity (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/appsactivity1-cli" @@ -19,10 +19,10 @@ name = "appsactivity1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-appsactivity1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appsactivity1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appsactivity1] diff --git a/gen/appsactivity1-cli/README.md b/gen/appsactivity1-cli/README.md index 6daa2ea634..9c70becf02 100644 --- a/gen/appsactivity1-cli/README.md +++ b/gen/appsactivity1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *appsactivity* API at revision *20160129*. The CLI is at version *0.3.6*. +This documentation was generated from the *appsactivity* API at revision *20160805*. The CLI is at version *0.3.6*. ```bash appsactivity1 [options] diff --git a/gen/appsactivity1-cli/mkdocs.yml b/gen/appsactivity1-cli/mkdocs.yml index 99c887eac3..0e01a2a38a 100644 --- a/gen/appsactivity1-cli/mkdocs.yml +++ b/gen/appsactivity1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: appsactivity v0.3.6+20160129 +site_name: appsactivity v0.3.6+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 a651cc81e4..fc1f358601 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+20160129") + .version("0.3.6+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/appsactivity1/Cargo.toml b/gen/appsactivity1/Cargo.toml index 1b98175b02..cd47b27bed 100644 --- a/gen/appsactivity1/Cargo.toml +++ b/gen/appsactivity1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appsactivity1" -version = "0.1.14+20160129" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/appsactivity1/README.md b/gen/appsactivity1/README.md index 7d7423fbef..a107d486e4 100644 --- a/gen/appsactivity1/README.md +++ b/gen/appsactivity1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appsactivity1` library allows access to all features of the *Google appsactivity* service. -This documentation was generated from *appsactivity* crate version *0.1.14+20160129*, where *20160129* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *appsactivity* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *appsactivity* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/activity/). diff --git a/gen/appsactivity1/src/lib.rs b/gen/appsactivity1/src/lib.rs index 30cfec332b..855820b612 100644 --- a/gen/appsactivity1/src/lib.rs +++ b/gen/appsactivity1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *appsactivity* crate version *0.1.14+20160129*, where *20160129* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *appsactivity* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *appsactivity:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *appsactivity* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/activity/). diff --git a/gen/appstate1-cli/Cargo.toml b/gen/appstate1-cli/Cargo.toml index 6708fa5144..c96cbbe3b7 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+20160331" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "appstate1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-appstate1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-appstate1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-appstate1] diff --git a/gen/appstate1-cli/README.md b/gen/appstate1-cli/README.md index 648a84a499..b2e7214827 100644 --- a/gen/appstate1-cli/README.md +++ b/gen/appstate1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *App State* API at revision *20160331*. 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 *0.3.6*. ```bash appstate1 [options] diff --git a/gen/appstate1-cli/mkdocs.yml b/gen/appstate1-cli/mkdocs.yml index 36c22ed48c..1f9306f105 100644 --- a/gen/appstate1-cli/mkdocs.yml +++ b/gen/appstate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: App State v0.3.6+20160331 +site_name: App State v0.3.6+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 da373980bf..78f775a2c9 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+20160331") + .version("0.3.6+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/appstate1/Cargo.toml b/gen/appstate1/Cargo.toml index 3cffbfab29..9c7d4e4f85 100644 --- a/gen/appstate1/Cargo.toml +++ b/gen/appstate1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-appstate1" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/appstate1/README.md b/gen/appstate1/README.md index a5d8066d32..43923f1c95 100644 --- a/gen/appstate1/README.md +++ b/gen/appstate1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-appstate1` library allows access to all features of the *Google App State* service. -This documentation was generated from *App State* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *App State* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *App State* *v1* API can be found at the [official documentation site](https://developers.google.com/games/services/web/api/states). diff --git a/gen/appstate1/src/lib.rs b/gen/appstate1/src/lib.rs index 252c212a25..fdba3ac697 100644 --- a/gen/appstate1/src/lib.rs +++ b/gen/appstate1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *App State* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *App State* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *appstate:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *App State* *v1* API can be found at the //! [official documentation site](https://developers.google.com/games/services/web/api/states). diff --git a/gen/autoscaler1_beta2-cli/Cargo.toml b/gen/autoscaler1_beta2-cli/Cargo.toml index 7c1c2f57e1..5606fae5eb 100644 --- a/gen/autoscaler1_beta2-cli/Cargo.toml +++ b/gen/autoscaler1_beta2-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "autoscaler1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-autoscaler1_beta2] diff --git a/gen/autoscaler1_beta2/Cargo.toml b/gen/autoscaler1_beta2/Cargo.toml index e55f3e9628..652437ec4f 100644 --- a/gen/autoscaler1_beta2/Cargo.toml +++ b/gen/autoscaler1_beta2/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/bigquery2-cli/Cargo.toml b/gen/bigquery2-cli/Cargo.toml index a0d9334c75..67b88f6a38 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+20160408" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "bigquery2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-bigquery2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-bigquery2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-bigquery2] diff --git a/gen/bigquery2-cli/README.md b/gen/bigquery2-cli/README.md index 0beb9bd928..a3971f3f73 100644 --- a/gen/bigquery2-cli/README.md +++ b/gen/bigquery2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *bigquery* API at revision *20160408*. The CLI is at version *0.3.6*. +This documentation was generated from the *bigquery* API at revision *20160903*. The CLI is at version *0.3.6*. ```bash bigquery2 [options] diff --git a/gen/bigquery2-cli/mkdocs.yml b/gen/bigquery2-cli/mkdocs.yml index 36c0588d5c..b6c27b4b41 100644 --- a/gen/bigquery2-cli/mkdocs.yml +++ b/gen/bigquery2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: bigquery v0.3.6+20160408 +site_name: bigquery v0.3.6+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 51f065a5c2..9608b686cc 100644 --- a/gen/bigquery2-cli/src/main.rs +++ b/gen/bigquery2-cli/src/main.rs @@ -172,6 +172,7 @@ impl<'n> Engine<'n> { "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.project-id" => Some(("datasetReference.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.dataset-id" => Some(("datasetReference.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-table-expiration-ms" => Some(("defaultTableExpirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -181,7 +182,7 @@ impl<'n> Engine<'n> { "id" => Some(("id", 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-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "last-modified-time", "location", "project-id", "self-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "labels", "last-modified-time", "location", "project-id", "self-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -253,6 +254,9 @@ impl<'n> Engine<'n> { "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, + "filter" => { + call = call.filter(value.unwrap_or("")); + }, "all" => { call = call.all(arg_from_str(value.unwrap_or("false"), err, "all", "boolean")); }, @@ -269,7 +273,7 @@ impl<'n> Engine<'n> { 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", "all", "max-results"].iter().map(|v|*v)); + v.extend(["filter", "page-token", "all", "max-results"].iter().map(|v|*v)); v } )); } } @@ -330,6 +334,7 @@ impl<'n> Engine<'n> { "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.project-id" => Some(("datasetReference.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.dataset-id" => Some(("datasetReference.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-table-expiration-ms" => Some(("defaultTableExpirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -339,7 +344,7 @@ impl<'n> Engine<'n> { "id" => Some(("id", 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-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "last-modified-time", "location", "project-id", "self-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "labels", "last-modified-time", "location", "project-id", "self-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -426,6 +431,7 @@ impl<'n> Engine<'n> { "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.project-id" => Some(("datasetReference.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-reference.dataset-id" => Some(("datasetReference.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-table-expiration-ms" => Some(("defaultTableExpirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -435,7 +441,7 @@ impl<'n> Engine<'n> { "id" => Some(("id", 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-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "last-modified-time", "location", "project-id", "self-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "dataset-id", "dataset-reference", "default-table-expiration-ms", "description", "etag", "friendly-name", "id", "kind", "labels", "last-modified-time", "location", "project-id", "self-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -703,6 +709,7 @@ impl<'n> Engine<'n> { "statistics.query.cache-hit" => Some(("statistics.query.cacheHit", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "statistics.query.billing-tier" => Some(("statistics.query.billingTier", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "statistics.query.total-bytes-billed" => Some(("statistics.query.totalBytesBilled", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "statistics.query.num-dml-affected-rows" => Some(("statistics.query.numDmlAffectedRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.query.total-bytes-processed" => Some(("statistics.query.totalBytesProcessed", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.end-time" => Some(("statistics.endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.extract.destination-uri-file-counts" => Some(("statistics.extract.destinationUriFileCounts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), @@ -710,14 +717,16 @@ impl<'n> Engine<'n> { "job-reference.job-id" => Some(("jobReference.jobId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-email" => Some(("user_email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "configuration.load.encoding" => Some(("configuration.load.encoding", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.skip-leading-rows" => Some(("configuration.load.skipLeadingRows", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "configuration.load.encoding" => Some(("configuration.load.encoding", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "configuration.load.ignore-unknown-values" => Some(("configuration.load.ignoreUnknownValues", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "configuration.load.quote" => Some(("configuration.load.quote", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "configuration.load.source-format" => Some(("configuration.load.sourceFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "configuration.load.autodetect" => Some(("configuration.load.autodetect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "configuration.load.destination-table.project-id" => Some(("configuration.load.destinationTable.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.destination-table.table-id" => Some(("configuration.load.destinationTable.tableId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.destination-table.dataset-id" => Some(("configuration.load.destinationTable.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.max-bad-records" => Some(("configuration.load.maxBadRecords", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "configuration.load.schema-update-options" => Some(("configuration.load.schemaUpdateOptions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "configuration.load.allow-jagged-rows" => Some(("configuration.load.allowJaggedRows", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "configuration.load.write-disposition" => Some(("configuration.load.writeDisposition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.source-uris" => Some(("configuration.load.sourceUris", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), @@ -727,7 +736,7 @@ impl<'n> Engine<'n> { "configuration.load.schema-inline" => Some(("configuration.load.schemaInline", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.load.allow-quoted-newlines" => Some(("configuration.load.allowQuotedNewlines", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "configuration.load.projection-fields" => Some(("configuration.load.projectionFields", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "configuration.load.ignore-unknown-values" => Some(("configuration.load.ignoreUnknownValues", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "configuration.load.source-format" => Some(("configuration.load.sourceFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.extract.destination-uri" => Some(("configuration.extract.destinationUri", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.extract.compression" => Some(("configuration.extract.compression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.extract.field-delimiter" => Some(("configuration.extract.fieldDelimiter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -755,16 +764,19 @@ impl<'n> Engine<'n> { "configuration.query.destination-table.project-id" => Some(("configuration.query.destinationTable.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.destination-table.table-id" => Some(("configuration.query.destinationTable.tableId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.destination-table.dataset-id" => Some(("configuration.query.destinationTable.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "configuration.query.schema-update-options" => Some(("configuration.query.schemaUpdateOptions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "configuration.query.priority" => Some(("configuration.query.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.write-disposition" => Some(("configuration.query.writeDisposition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.allow-large-results" => Some(("configuration.query.allowLargeResults", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "configuration.query.create-disposition" => Some(("configuration.query.createDisposition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.query" => Some(("configuration.query.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "configuration.query.preserve-nulls" => Some(("configuration.query.preserveNulls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "configuration.query.maximum-bytes-billed" => Some(("configuration.query.maximumBytesBilled", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "configuration.query.parameter-mode" => Some(("configuration.query.parameterMode", 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 })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-large-results", "allow-quoted-newlines", "billing-tier", "cache-hit", "compression", "configuration", "copy", "create-disposition", "creation-time", "dataset-id", "debug-info", "default-dataset", "destination-format", "destination-table", "destination-uri", "destination-uri-file-counts", "destination-uris", "dry-run", "encoding", "end-time", "error-result", "etag", "extract", "field-delimiter", "flatten-results", "id", "ignore-unknown-values", "input-file-bytes", "input-files", "job-id", "job-reference", "kind", "load", "location", "max-bad-records", "maximum-billing-tier", "message", "output-bytes", "output-rows", "preserve-nulls", "print-header", "priority", "project-id", "projection-fields", "query", "quote", "reason", "schema-inline", "schema-inline-format", "self-link", "skip-leading-rows", "source-format", "source-table", "source-uris", "start-time", "state", "statistics", "status", "table-id", "total-bytes-billed", "total-bytes-processed", "use-legacy-sql", "use-query-cache", "user-email", "write-disposition"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-large-results", "allow-quoted-newlines", "autodetect", "billing-tier", "cache-hit", "compression", "configuration", "copy", "create-disposition", "creation-time", "dataset-id", "debug-info", "default-dataset", "destination-format", "destination-table", "destination-uri", "destination-uri-file-counts", "destination-uris", "dry-run", "encoding", "end-time", "error-result", "etag", "extract", "field-delimiter", "flatten-results", "id", "ignore-unknown-values", "input-file-bytes", "input-files", "job-id", "job-reference", "kind", "load", "location", "max-bad-records", "maximum-billing-tier", "maximum-bytes-billed", "message", "num-dml-affected-rows", "output-bytes", "output-rows", "parameter-mode", "preserve-nulls", "print-header", "priority", "project-id", "projection-fields", "query", "quote", "reason", "schema-inline", "schema-inline-format", "schema-update-options", "self-link", "skip-leading-rows", "source-format", "source-table", "source-uris", "start-time", "state", "statistics", "status", "table-id", "total-bytes-billed", "total-bytes-processed", "use-legacy-sql", "use-query-cache", "user-email", "write-disposition"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -922,6 +934,7 @@ impl<'n> Engine<'n> { "timeout-ms" => Some(("timeoutMs", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dry-run" => Some(("dryRun", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "parameter-mode" => Some(("parameterMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "use-query-cache" => Some(("useQueryCache", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "default-dataset.project-id" => Some(("defaultDataset.projectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-dataset.dataset-id" => Some(("defaultDataset.datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -930,7 +943,7 @@ impl<'n> Engine<'n> { "query" => Some(("query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "preserve-nulls" => Some(("preserveNulls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "default-dataset", "dry-run", "kind", "max-results", "preserve-nulls", "project-id", "query", "timeout-ms", "use-legacy-sql", "use-query-cache"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "default-dataset", "dry-run", "kind", "max-results", "parameter-mode", "preserve-nulls", "project-id", "query", "timeout-ms", "use-legacy-sql", "use-query-cache"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1335,24 +1348,30 @@ impl<'n> Engine<'n> { "external-data-configuration.csv-options.encoding" => Some(("externalDataConfiguration.csvOptions.encoding", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.quote" => Some(("externalDataConfiguration.csvOptions.quote", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-jagged-rows" => Some(("externalDataConfiguration.csvOptions.allowJaggedRows", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.field-delimiter" => Some(("externalDataConfiguration.csvOptions.fieldDelimiter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-quoted-newlines" => Some(("externalDataConfiguration.csvOptions.allowQuotedNewlines", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.autodetect" => Some(("externalDataConfiguration.autodetect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.max-bad-records" => Some(("externalDataConfiguration.maxBadRecords", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "external-data-configuration.ignore-unknown-values" => Some(("externalDataConfiguration.ignoreUnknownValues", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-uris" => Some(("externalDataConfiguration.sourceUris", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "external-data-configuration.bigtable-options.read-rowkey-as-string" => Some(("externalDataConfiguration.bigtableOptions.readRowkeyAsString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.bigtable-options.ignore-unspecified-column-families" => Some(("externalDataConfiguration.bigtableOptions.ignoreUnspecifiedColumnFamilies", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-format" => Some(("externalDataConfiguration.sourceFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-data-configuration.google-sheets-options.skip-leading-rows" => Some(("externalDataConfiguration.googleSheetsOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "friendly-name" => Some(("friendlyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.type" => Some(("timePartitioning.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.expiration-ms" => Some(("timePartitioning.expirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.use-legacy-sql" => Some(("view.useLegacySql", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "type" => Some(("type", 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 })), - "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "num-long-term-bytes" => Some(("numLongTermBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "type", "view"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-ms", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "google-sheets-options", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-long-term-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "read-rowkey-as-string", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "time-partitioning", "type", "use-legacy-sql", "view"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1511,24 +1530,30 @@ impl<'n> Engine<'n> { "external-data-configuration.csv-options.encoding" => Some(("externalDataConfiguration.csvOptions.encoding", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.quote" => Some(("externalDataConfiguration.csvOptions.quote", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-jagged-rows" => Some(("externalDataConfiguration.csvOptions.allowJaggedRows", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.field-delimiter" => Some(("externalDataConfiguration.csvOptions.fieldDelimiter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-quoted-newlines" => Some(("externalDataConfiguration.csvOptions.allowQuotedNewlines", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.autodetect" => Some(("externalDataConfiguration.autodetect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.max-bad-records" => Some(("externalDataConfiguration.maxBadRecords", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "external-data-configuration.ignore-unknown-values" => Some(("externalDataConfiguration.ignoreUnknownValues", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-uris" => Some(("externalDataConfiguration.sourceUris", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "external-data-configuration.bigtable-options.read-rowkey-as-string" => Some(("externalDataConfiguration.bigtableOptions.readRowkeyAsString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.bigtable-options.ignore-unspecified-column-families" => Some(("externalDataConfiguration.bigtableOptions.ignoreUnspecifiedColumnFamilies", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-format" => Some(("externalDataConfiguration.sourceFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-data-configuration.google-sheets-options.skip-leading-rows" => Some(("externalDataConfiguration.googleSheetsOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "friendly-name" => Some(("friendlyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.type" => Some(("timePartitioning.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.expiration-ms" => Some(("timePartitioning.expirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.use-legacy-sql" => Some(("view.useLegacySql", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "type" => Some(("type", 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 })), - "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "num-long-term-bytes" => Some(("numLongTermBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "type", "view"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-ms", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "google-sheets-options", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-long-term-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "read-rowkey-as-string", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "time-partitioning", "type", "use-legacy-sql", "view"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1628,24 +1653,30 @@ impl<'n> Engine<'n> { "external-data-configuration.csv-options.encoding" => Some(("externalDataConfiguration.csvOptions.encoding", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.quote" => Some(("externalDataConfiguration.csvOptions.quote", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-jagged-rows" => Some(("externalDataConfiguration.csvOptions.allowJaggedRows", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "external-data-configuration.csv-options.skip-leading-rows" => Some(("externalDataConfiguration.csvOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.field-delimiter" => Some(("externalDataConfiguration.csvOptions.fieldDelimiter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "external-data-configuration.csv-options.allow-quoted-newlines" => Some(("externalDataConfiguration.csvOptions.allowQuotedNewlines", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.autodetect" => Some(("externalDataConfiguration.autodetect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.max-bad-records" => Some(("externalDataConfiguration.maxBadRecords", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "external-data-configuration.ignore-unknown-values" => Some(("externalDataConfiguration.ignoreUnknownValues", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-uris" => Some(("externalDataConfiguration.sourceUris", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "external-data-configuration.bigtable-options.read-rowkey-as-string" => Some(("externalDataConfiguration.bigtableOptions.readRowkeyAsString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.bigtable-options.ignore-unspecified-column-families" => Some(("externalDataConfiguration.bigtableOptions.ignoreUnspecifiedColumnFamilies", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "external-data-configuration.source-format" => Some(("externalDataConfiguration.sourceFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-data-configuration.google-sheets-options.skip-leading-rows" => Some(("externalDataConfiguration.googleSheetsOptions.skipLeadingRows", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "friendly-name" => Some(("friendlyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.type" => Some(("timePartitioning.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "time-partitioning.expiration-ms" => Some(("timePartitioning.expirationMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "view.use-legacy-sql" => Some(("view.useLegacySql", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "type" => Some(("type", 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 })), - "view.query" => Some(("view.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "num-long-term-bytes" => Some(("numLongTermBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "type", "view"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-jagged-rows", "allow-quoted-newlines", "autodetect", "bigtable-options", "compression", "creation-time", "csv-options", "dataset-id", "description", "encoding", "estimated-bytes", "estimated-rows", "etag", "expiration-ms", "expiration-time", "external-data-configuration", "field-delimiter", "friendly-name", "google-sheets-options", "id", "ignore-unknown-values", "ignore-unspecified-column-families", "kind", "last-modified-time", "location", "max-bad-records", "num-bytes", "num-long-term-bytes", "num-rows", "oldest-entry-time", "project-id", "query", "quote", "read-rowkey-as-string", "self-link", "skip-leading-rows", "source-format", "source-uris", "streaming-buffer", "table-id", "table-reference", "time-partitioning", "type", "use-legacy-sql", "view"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2545,7 +2576,7 @@ fn main() { let mut app = App::new("bigquery2") .author("Sebastian Thiel ") - .version("0.3.6+20160408") + .version("0.3.6+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/bigquery2/Cargo.toml b/gen/bigquery2/Cargo.toml index 89275070db..a4c0a4ea4c 100644 --- a/gen/bigquery2/Cargo.toml +++ b/gen/bigquery2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-bigquery2" -version = "0.1.14+20160408" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/bigquery2/README.md b/gen/bigquery2/README.md index 3fd8ede158..024d3254b6 100644 --- a/gen/bigquery2/README.md +++ b/gen/bigquery2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-bigquery2` library allows access to all features of the *Google bigquery* service. -This documentation was generated from *bigquery* crate version *0.1.14+20160408*, where *20160408* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *bigquery* crate version *0.1.14+20160903*, where *20160903* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *bigquery* *v2* API can be found at the [official documentation site](https://cloud.google.com/bigquery/). diff --git a/gen/bigquery2/src/lib.rs b/gen/bigquery2/src/lib.rs index 8ed6c9b1d8..6a5b469204 100644 --- a/gen/bigquery2/src/lib.rs +++ b/gen/bigquery2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *bigquery* crate version *0.1.14+20160408*, where *20160408* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *bigquery* crate version *0.1.14+20160903*, where *20160903* is the exact revision of the *bigquery:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *bigquery* *v2* API can be found at the //! [official documentation site](https://cloud.google.com/bigquery/). diff --git a/gen/bigquery2/src/lib.rs.in b/gen/bigquery2/src/lib.rs.in index f646aef42d..8910694271 100644 --- a/gen/bigquery2/src/lib.rs.in +++ b/gen/bigquery2/src/lib.rs.in @@ -242,18 +242,24 @@ pub struct QueryRequest { /// [Optional] If set to true, BigQuery doesn't run the job. Instead, if the query is valid, BigQuery returns statistics about the job such as how many bytes would be processed. If the query is invalid, an error returns. The default value is false. #[serde(rename="dryRun")] pub dry_run: Option, + /// [Experimental] Standard SQL only. Whether to use positional (?) or named (@myparam) query parameters in this query. + #[serde(rename="parameterMode")] + pub parameter_mode: Option, /// [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. The default value is true. #[serde(rename="useQueryCache")] pub use_query_cache: Option, /// [Optional] Specifies the default datasetId and projectId to assume for any unqualified table names in the query. If not set, all table names in the query string must be qualified in the format 'datasetId.tableId'. #[serde(rename="defaultDataset")] pub default_dataset: Option, - /// [Experimental] Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's updated SQL dialect with improved standards compliance. When using BigQuery's updated SQL, the values of allowLargeResults and flattenResults are ignored. Queries with useLegacySql set to false will be run as if allowLargeResults is true and flattenResults is false. + /// [Experimental] Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the values of allowLargeResults and flattenResults are ignored; query will be run as if allowLargeResults is true and flattenResults is false. #[serde(rename="useLegacySql")] pub use_legacy_sql: Option, /// [Optional] The maximum number of rows of data to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large. In addition to this limit, responses are also limited to 10 MB. By default, there is no maximum row count, and only the byte limit applies. #[serde(rename="maxResults")] pub max_results: Option, + /// [Experimental] Query parameters for Standard SQL queries. + #[serde(rename="queryParameters")] + pub query_parameters: Option>, /// [Required] A query string, following the BigQuery query syntax, of the query to execute. Example: "SELECT count(f1) FROM [myProjectId:myDatasetId.myTableId]". pub query: Option, /// [Deprecated] This property is deprecated. @@ -270,24 +276,32 @@ impl RequestValue for QueryRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobStatistics2 { - /// [Output-only] Whether the query result was fetched from the query cache. - #[serde(rename="cacheHit")] - pub cache_hit: Option, - /// [Output-only, Experimental] Describes execution plan for the query as a list of stages. + /// [Output-only, Experimental] Describes execution plan for the query. #[serde(rename="queryPlan")] pub query_plan: Option>, - /// [Output-only, Experimental] Referenced tables for the job. Queries that reference more than 50 tables will not have a complete list. - #[serde(rename="referencedTables")] - pub referenced_tables: Option>, - /// [Output-only] Billing tier for the job. - #[serde(rename="billingTier")] - pub billing_tier: Option, /// [Output-only] Total bytes billed for the job. #[serde(rename="totalBytesBilled")] pub total_bytes_billed: Option, /// [Output-only] Total bytes processed for the job. #[serde(rename="totalBytesProcessed")] pub total_bytes_processed: Option, + /// [Output-only] Whether the query result was fetched from the query cache. + #[serde(rename="cacheHit")] + pub cache_hit: Option, + /// [Output-only, Experimental] Standard SQL only: list of undeclared query parameters detected during a dry run validation. + #[serde(rename="undeclaredQueryParameters")] + pub undeclared_query_parameters: Option>, + /// [Output-only, Experimental] Referenced tables for the job. Queries that reference more than 50 tables will not have a complete list. + #[serde(rename="referencedTables")] + pub referenced_tables: Option>, + /// [Output-only] Billing tier for the job. + #[serde(rename="billingTier")] + pub billing_tier: Option, + /// [Output-only, Experimental] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. + #[serde(rename="numDmlAffectedRows")] + pub num_dml_affected_rows: Option, + /// [Output-only, Experimental] The schema of the results. Present only for successful dry run of non-legacy SQL queries. + pub schema: Option, } impl Part for JobStatistics2 {} @@ -376,6 +390,25 @@ pub struct TableFieldSchema { impl Part for TableFieldSchema {} +/// 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 QueryParameter { + /// [Required] The type of this parameter. + #[serde(rename="parameterType")] + pub parameter_type: Option, + /// [Required] The value of this parameter. + #[serde(rename="parameterValue")] + pub parameter_value: Option, + /// [Optional] If unset, this is a positional parameter. Otherwise, should be unique within a query. + pub name: Option, +} + +impl Part for QueryParameter {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -384,7 +417,7 @@ impl Part for TableFieldSchema {} pub struct BigtableColumnFamily { /// [Optional] The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. This can be overridden for a specific column by listing that column in 'columns' and specifying an encoding for it. pub encoding: Option, - /// [Optional] The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Defaut type is BYTES. This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it. + /// [Optional] The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it. #[serde(rename="type")] pub type_: Option, /// [Optional] If this is set only the latest version of value are exposed for all columns in this column family. This can be overridden for a specific column by listing that column in 'columns' and specifying a different setting for that column. @@ -406,6 +439,9 @@ impl Part for BigtableColumnFamily {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BigtableOptions { + /// [Optional] If field is true, then the rowkey column families will be read and converted to string. Otherwise they are read with BYTES type values and users need to manually cast them with CAST if necessary. The default value is false. + #[serde(rename="readRowkeyAsString")] + pub read_rowkey_as_string: Option, /// [Optional] If field is true, then the column families that are not specified in columnFamilies list are not exposed in the table schema. Otherwise, they are read with BYTES type values. The default value is false. #[serde(rename="ignoreUnspecifiedColumnFamilies")] pub ignore_unspecified_column_families: Option, @@ -437,7 +473,7 @@ pub struct BigtableColumn { /// no description provided #[serde(rename="qualifierString")] pub qualifier_string: Option, - /// [Optional] The type to convert the value in cells of this column. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Defaut type is BYTES. 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels. + /// [Optional] The type to convert the value in cells of this column. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive) - BYTES STRING INTEGER FLOAT BOOLEAN Default type is BYTES. 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels. #[serde(rename="type")] pub type_: Option, } @@ -474,6 +510,26 @@ pub struct TableCell { impl Part for TableCell {} +/// 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 QueryParameterType { + /// [Optional] The types of the fields of this struct, in order, if this is a struct. + #[serde(rename="structTypes")] + pub struct_types: Option>, + /// [Required] The top level type of this field. + #[serde(rename="type")] + pub type_: Option, + /// [Optional] The type of the array's elements, if this is an array. + #[serde(rename="arrayType")] + pub array_type: Option>>, +} + +impl Part for QueryParameterType {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -549,6 +605,8 @@ pub struct DatasetListDatasets { pub friendly_name: Option, /// The resource type. This property always returns the value "bigquery#dataset". pub kind: Option, + /// [Experimental] The labels associated with this dataset. You can use these to organize and group your datasets. + pub labels: Option>, /// The fully-qualified, unique, opaque ID of the dataset. pub id: Option, /// The dataset reference. Use this property to access specific parts of the dataset's ID, such as project ID or dataset ID. @@ -580,17 +638,21 @@ pub struct Streamingbuffer { impl Part for Streamingbuffer {} -/// [Required] A partition configuration. Only one type of partition should be configured. +/// 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 TablePartitionConfiguration { - /// [Pick one] Configures an interval partition. - pub interval: Option, +pub struct UserDefinedFunctionResource { + /// [Pick one] A code resource to load from a Google Cloud Storage URI (gs://bucket/path). + #[serde(rename="resourceUri")] + pub resource_uri: Option, + /// [Pick one] An inline resource that contains code for a user-defined function (UDF). Providing a inline code resource is equivalent to providing a URI for a file containing the same code. + #[serde(rename="inlineCode")] + pub inline_code: Option, } -impl Part for TablePartitionConfiguration {} +impl Part for UserDefinedFunctionResource {} /// Tables in the requested dataset. @@ -763,6 +825,23 @@ impl NestedType for JobListJobs {} impl Part for JobListJobs {} +/// 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 TimePartitioning { + /// [Required] The only type supported is DAY, which will generate one partition per day based on data loading time. + #[serde(rename="type")] + pub type_: Option, + /// [Optional] Number of milliseconds for which to keep the storage for a partition. + #[serde(rename="expirationMs")] + pub expiration_ms: Option, +} + +impl Part for TimePartitioning {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -773,6 +852,8 @@ pub struct JobConfigurationLoad { pub encoding: Option, /// [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. pub quote: Option, + /// [Experimental] Indicates if we should automatically infer the options and schema for CSV and JSON sources. + pub autodetect: Option, /// [Required] The destination table to load the data into. #[serde(rename="destinationTable")] pub destination_table: Option, @@ -797,6 +878,9 @@ pub struct JobConfigurationLoad { /// [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If the number of bad records exceeds this value, an invalid error is returned in the job result. The default value is 0, which requires that all records are valid. #[serde(rename="maxBadRecords")] pub max_bad_records: Option, + /// [Experimental] Allows the schema of the desitination table to be updated as a side effect of the load job. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. + #[serde(rename="schemaUpdateOptions")] + pub schema_update_options: Option>, /// [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names #[serde(rename="ignoreUnknownValues")] pub ignore_unknown_values: Option, @@ -878,23 +962,6 @@ pub struct JobConfigurationExtract { impl Part for JobConfigurationExtract {} -/// 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 UserDefinedFunctionResource { - /// [Pick one] A code resource to load from a Google Cloud Storage URI (gs://bucket/path). - #[serde(rename="resourceUri")] - pub resource_uri: Option, - /// [Pick one] An inline resource that contains code for a user-defined function (UDF). Providing a inline code resource is equivalent to providing a URI for a file containing the same code. - #[serde(rename="inlineCode")] - pub inline_code: Option, -} - -impl Part for UserDefinedFunctionResource {} - - /// There is no detailed description. /// /// # Activities @@ -932,6 +999,9 @@ pub struct GetQueryResultsResponse { pub etag: Option, /// An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. Present only when the query completes successfully. pub rows: Option>, + /// [Output-only, Experimental] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. + #[serde(rename="numDmlAffectedRows")] + pub num_dml_affected_rows: Option, /// The schema of the results. Present only when the query completes successfully. pub schema: Option, } @@ -970,7 +1040,7 @@ pub struct CsvOptions { pub allow_jagged_rows: Option, /// [Optional] The number of rows at the top of a CSV file that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. #[serde(rename="skipLeadingRows")] - pub skip_leading_rows: Option, + pub skip_leading_rows: Option, /// [Optional] The separator for fields in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). #[serde(rename="fieldDelimiter")] pub field_delimiter: Option, @@ -1005,15 +1075,18 @@ pub struct ExternalDataConfiguration { /// [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names Google Cloud Bigtable: This setting is ignored. Google Cloud Datastore backups: This setting is ignored. Avro: This setting is ignored. #[serde(rename="ignoreUnknownValues")] pub ignore_unknown_values: Option, - /// [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources, plus an additional limit of 10 GB maximum size across all URIs. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified, and it must end with '.backup_info'. Also, the '*' wildcard character is not allowed. + /// [Required] The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified, and it must end with '.backup_info'. Also, the '*' wildcard character is not allowed. #[serde(rename="sourceUris")] pub source_uris: Option>, /// [Optional] Additional options if sourceFormat is set to BIGTABLE. #[serde(rename="bigtableOptions")] pub bigtable_options: Option, - /// [Required] The data format. For CSV files, specify "CSV". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro files, specify "AVRO". For Google Cloud Datastore backups, specify "DATASTORE_BACKUP". [Experimental] For Google Cloud Bigtable, specify "BIGTABLE". Please note that reading from Google Cloud Bigtable is experimental and has to be enabled for your project. Please contact Google Cloud Support to enable this for your project. + /// [Required] The data format. For CSV files, specify "CSV". For Google sheets, specify "GOOGLE_SHEETS". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro files, specify "AVRO". For Google Cloud Datastore backups, specify "DATASTORE_BACKUP". [Experimental] For Google Cloud Bigtable, specify "BIGTABLE". Please note that reading from Google Cloud Bigtable is experimental and has to be enabled for your project. Please contact Google Cloud Support to enable this for your project. #[serde(rename="sourceFormat")] pub source_format: Option, + /// [Optional] Additional options if sourceFormat is set to GOOGLE_SHEETS. + #[serde(rename="googleSheetsOptions")] + pub google_sheets_options: Option, /// [Optional] The schema for the data. Schema is required for CSV and JSON formats. Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, and Avro formats. pub schema: Option, } @@ -1064,6 +1137,9 @@ impl Part for ErrorProto {} pub struct ViewDefinition { /// [Required] A query that BigQuery executes when the view is referenced. pub query: Option, + /// [Experimental] Specifies whether to use BigQuery's legacy SQL for this view. The default value is true. If set to false, the view will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ Queries and views that reference this view must use the same flag value. + #[serde(rename="useLegacySql")] + pub use_legacy_sql: Option, /// [Experimental] Describes user-defined function resources used in the query. #[serde(rename="userDefinedFunctionResources")] pub user_defined_function_resources: Option>, @@ -1202,6 +1278,25 @@ pub struct DatasetList { impl ResponseResult for DatasetList {} +/// [Optional] The types of the fields of this struct, in order, if this is a struct. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct QueryParameterTypeStructTypes { + /// [Required] The type of this field. + #[serde(rename="type")] + pub type_: Option, + /// [Optional] Human-oriented description of the field. + pub description: Option, + /// [Optional] The name of this field. + pub name: Option, +} + +impl NestedType for QueryParameterTypeStructTypes {} +impl Part for QueryParameterTypeStructTypes {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1240,21 +1335,38 @@ pub struct JobConfigurationQuery { /// [Optional] Flattens all nested and repeated fields in the query results. The default value is true. allowLargeResults must be true if this is set to false. #[serde(rename="flattenResults")] pub flatten_results: Option, - /// [Optional] Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default. - #[serde(rename="maximumBillingTier")] - pub maximum_billing_tier: Option, /// [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available when a query does not have a destination table specified. The default value is true. #[serde(rename="useQueryCache")] pub use_query_cache: Option, - /// [Optional] Specifies the default dataset to use for unqualified table names in the query. - #[serde(rename="defaultDataset")] - pub default_dataset: Option, - /// [Experimental] Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's updated SQL dialect with improved standards compliance. When using BigQuery's updated SQL, the values of allowLargeResults and flattenResults are ignored. Queries with useLegacySql set to false will be run as if allowLargeResults is true and flattenResults is false. - #[serde(rename="useLegacySql")] - pub use_legacy_sql: Option, /// [Optional] Describes the table where the query results should be stored. If not present, a new table will be created to store the results. #[serde(rename="destinationTable")] pub destination_table: Option, + /// [Experimental] Query parameters for Standard SQL queries. + #[serde(rename="queryParameters")] + pub query_parameters: Option>, + /// [Required] BigQuery SQL query to execute. + pub query: Option, + /// [Deprecated] This property is deprecated. + #[serde(rename="preserveNulls")] + pub preserve_nulls: Option, + /// [Optional] Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit will fail (without incurring a charge). If unspecified, this will be set to your project default. + #[serde(rename="maximumBytesBilled")] + pub maximum_bytes_billed: Option, + /// [Optional] Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). If unspecified, this will be set to your project default. + #[serde(rename="maximumBillingTier")] + pub maximum_billing_tier: Option, + /// [Experimental] Standard SQL only. Whether to use positional (?) or named (@myparam) query parameters in this query. + #[serde(rename="parameterMode")] + pub parameter_mode: Option, + /// [Optional] Specifies the default dataset to use for unqualified table names in the query. + #[serde(rename="defaultDataset")] + pub default_dataset: Option, + /// [Experimental] Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. If set to false, the query will use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/ When useLegacySql is set to false, the values of allowLargeResults and flattenResults are ignored; query will be run as if allowLargeResults is true and flattenResults is false. + #[serde(rename="useLegacySql")] + pub use_legacy_sql: Option, + /// [Experimental] Allows the schema of the desitination table to be updated as a side effect of the query job. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable. + #[serde(rename="schemaUpdateOptions")] + pub schema_update_options: Option>, /// [Optional] Specifies a priority for the query. Possible values include INTERACTIVE and BATCH. The default value is INTERACTIVE. pub priority: Option, /// [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. @@ -1266,17 +1378,12 @@ pub struct JobConfigurationQuery { /// [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="createDisposition")] pub create_disposition: Option, - /// [Required] BigQuery SQL query to execute. - pub query: Option, - /// [Deprecated] This property is deprecated. - #[serde(rename="preserveNulls")] - pub preserve_nulls: Option, - /// [Optional] If querying an external data source outside of BigQuery, describes the data format, location and other properties of the data source. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. - #[serde(rename="tableDefinitions")] - pub table_definitions: Option>, /// [Experimental] Describes user-defined function resources used in the query. #[serde(rename="userDefinedFunctionResources")] pub user_defined_function_resources: Option>, + /// [Optional] If querying an external data source outside of BigQuery, describes the data format, location and other properties of the data source. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. + #[serde(rename="tableDefinitions")] + pub table_definitions: Option>, } impl Part for JobConfigurationQuery {} @@ -1379,23 +1486,6 @@ pub struct JobCancelResponse { impl ResponseResult for JobCancelResponse {} -/// 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 IntervalPartitionConfiguration { - /// no description provided - #[serde(rename="type")] - pub type_: Option, - /// no description provided - #[serde(rename="expirationMs")] - pub expiration_ms: Option, -} - -impl Part for IntervalPartitionConfiguration {} - - /// There is no detailed description. /// /// # Activities @@ -1419,6 +1509,8 @@ pub struct Dataset { /// [Required] A reference that identifies the dataset. #[serde(rename="datasetReference")] pub dataset_reference: Option, + /// [Experimental] The labels associated with this dataset. You can use these to organize and group your datasets. You can set this property when inserting or updating a dataset. See Labeling Datasets for more information. + pub labels: Option>, /// [Output-only] The time when this dataset was created, in milliseconds since the epoch. #[serde(rename="creationTime")] pub creation_time: Option, @@ -1449,6 +1541,25 @@ impl Resource for Dataset {} impl ResponseResult for Dataset {} +/// 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 QueryParameterValue { + /// [Optional] The struct field values, in order of the struct type's declaration. + #[serde(rename="structValues")] + pub struct_values: Option>, + /// [Optional] The array values, if this is an array type. + #[serde(rename="arrayValues")] + pub array_values: Option>, + /// [Optional] The value of this value, if a simple scalar type. + pub value: Option, +} + +impl Part for QueryParameterValue {} + + /// There is no detailed description. /// /// # Activities @@ -1473,9 +1584,9 @@ pub struct Table { /// [Output-only] The size of this table in bytes, excluding any data in the streaming buffer. #[serde(rename="numBytes")] pub num_bytes: Option, - /// [Experimental] List of partition configurations for this table. Currently only one configuration can be specified and it can only be an interval partition with type daily. - #[serde(rename="partitionConfigurations")] - pub partition_configurations: Option>, + /// [Experimental] If specified, configures time-based partitioning for this table. + #[serde(rename="timePartitioning")] + pub time_partitioning: Option, /// [Output-only] The time when this table was last modified, in milliseconds since the epoch. #[serde(rename="lastModifiedTime")] pub last_modified_time: Option, @@ -1489,6 +1600,8 @@ pub struct Table { /// [Optional] Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. #[serde(rename="externalDataConfiguration")] pub external_data_configuration: Option, + /// [Output-only] The geographic location where the table resides. This value is inherited from the dataset. + pub location: Option, /// [Required] Reference describing the ID of this table. #[serde(rename="tableReference")] pub table_reference: Option, @@ -1497,24 +1610,25 @@ pub struct Table { pub num_rows: Option, /// [Output-only] A hash of this resource. pub etag: Option, - /// [Output-only] The geographic location where the table resides. This value is inherited from the dataset. - pub location: Option, + /// [Output-only] The number of bytes in the table that are considered "long-term storage". + #[serde(rename="numLongTermBytes")] + pub num_long_term_bytes: Option, /// [Optional] A descriptive name for this table. #[serde(rename="friendlyName")] pub friendly_name: Option, /// [Optional] The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. #[serde(rename="expirationTime")] pub expiration_time: Option, - /// [Optional] Describes the schema of this table. - pub schema: Option, + /// [Optional] The view definition. + pub view: Option, /// [Output-only] Describes the table type. The following values are supported: TABLE: A normal BigQuery table. VIEW: A virtual table defined by a SQL query. EXTERNAL: A table that references data stored in an external storage system, such as Google Cloud Storage. The default value is TABLE. #[serde(rename="type")] pub type_: Option, /// [Output-only] A URL that can be used to access this resource again. #[serde(rename="selfLink")] pub self_link: Option, - /// [Optional] The view definition. - pub view: Option, + /// [Optional] Describes the schema of this table. + pub schema: Option, } impl RequestValue for Table {} @@ -1578,6 +1692,9 @@ pub struct QueryResponse { pub page_token: Option, /// An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. pub rows: Option>, + /// [Output-only, Experimental] The number of rows affected by a DML statement. Present only for DML statements INSERT, UPDATE or DELETE. + #[serde(rename="numDmlAffectedRows")] + pub num_dml_affected_rows: Option, /// The schema of the results. Present only when the query completes successfully. pub schema: Option, } @@ -1611,6 +1728,20 @@ pub struct JobConfigurationTableCopy { impl Part for JobConfigurationTableCopy {} +/// 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 GoogleSheetsOptions { + /// [Optional] The number of rows at the top of a sheet that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows that should be skipped. When autodetect is on, behavior is the following: * skipLeadingRows unspecified - Autodetect tries to detect headers in the first row. If they are not detected, the row is read as data. Otherwise data is read starting from the second row. * skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row. * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N. If headers are not detected, row N is just skipped. Otherwise row N is used to extract column names for the detected schema. + #[serde(rename="skipLeadingRows")] + pub skip_leading_rows: Option, +} + +impl Part for GoogleSheetsOptions {} + + // ################### // MethodBuilders ### @@ -1878,6 +2009,7 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { _project_id: project_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), + _filter: Default::default(), _all: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -4449,7 +4581,8 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut, A: oa /// let result = hub.datasets().list("projectId") /// .page_token("duo") /// .max_results(69) -/// .all(true) +/// .filter("sea") +/// .all(false) /// .doit(); /// # } /// ``` @@ -4460,6 +4593,7 @@ pub struct DatasetListCall<'a, C, A> _project_id: String, _page_token: Option, _max_results: Option, + _filter: Option, _all: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, @@ -4482,7 +4616,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "bigquery.datasets.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + 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())); @@ -4490,10 +4624,13 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o 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())); + } if let Some(value) = self._all { params.push(("all", value.to_string())); } - for &field in ["alt", "projectId", "pageToken", "maxResults", "all"].iter() { + for &field in ["alt", "projectId", "pageToken", "maxResults", "filter", "all"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4632,6 +4769,13 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o self._max_results = Some(new_value); self } + /// An expression for filtering the results of the request by label. The syntax is "labels.[:]". Multiple filters can be ANDed together by connecting with a space. Example: "labels.department:receiving labels.active". See Filtering datasets using labels for details. + /// + /// Sets the *filter* query property to the given value. + pub fn filter(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { + self._filter = Some(new_value.to_string()); + self + } /// Whether to list all datasets, including hidden ones /// /// Sets the *all* query property to the given value. @@ -5555,7 +5699,7 @@ impl<'a, C, A> JobCancelCall<'a, C, A> where C: BorrowMut, A: oau params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/bigquery/v2/project/{projectId}/jobs/{jobId}/cancel".to_string(); + let mut url = "https://www.googleapis.com/bigquery/v2/projects/{projectId}/jobs/{jobId}/cancel".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -6023,10 +6167,10 @@ impl<'a, C, A> JobQueryCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().get_query_results("projectId", "jobId") -/// .timeout_ms(68) -/// .start_index("invidunt") -/// .page_token("aliquyam") -/// .max_results(28) +/// .timeout_ms(64) +/// .start_index("aliquyam") +/// .page_token("accusam") +/// .max_results(45) /// .doit(); /// # } /// ``` @@ -6318,11 +6462,11 @@ impl<'a, C, A> JobGetQueryResultCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().list("projectId") -/// .add_state_filter("sea") -/// .projection("et") -/// .page_token("duo") -/// .max_results(80) -/// .all_users(true) +/// .add_state_filter("et") +/// .projection("duo") +/// .page_token("et") +/// .max_results(61) +/// .all_users(false) /// .doit(); /// # } /// ``` @@ -7530,8 +7674,8 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut TabledataListCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().list() -/// .page_token("consetetur") -/// .max_results(49) +/// .page_token("amet.") +/// .max_results(74) /// .doit(); /// # } /// ``` diff --git a/gen/blogger3-cli/Cargo.toml b/gen/blogger3-cli/Cargo.toml index bb18d7e663..45ff29a61b 100644 --- a/gen/blogger3-cli/Cargo.toml +++ b/gen/blogger3-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "blogger3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-blogger3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-blogger3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-blogger3] diff --git a/gen/blogger3/Cargo.toml b/gen/blogger3/Cargo.toml index 140f275001..7c5d12c66f 100644 --- a/gen/blogger3/Cargo.toml +++ b/gen/blogger3/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/books1-cli/Cargo.toml b/gen/books1-cli/Cargo.toml index 70b815952d..95c3251ceb 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+20160226" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "books1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-books1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-books1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-books1] diff --git a/gen/books1-cli/README.md b/gen/books1-cli/README.md index ed118efbbd..ca4c48b8fa 100644 --- a/gen/books1-cli/README.md +++ b/gen/books1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *books* API at revision *20160226*. The CLI is at version *0.3.6*. +This documentation was generated from the *books* API at revision *20160823*. The CLI is at version *0.3.6*. ```bash books1 [options] diff --git a/gen/books1-cli/mkdocs.yml b/gen/books1-cli/mkdocs.yml index e6cd0d29b8..efbbaf9d38 100644 --- a/gen/books1-cli/mkdocs.yml +++ b/gen/books1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: books v0.3.6+20160226 +site_name: books v0.3.6+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 eb90d91501..4ecb7b04ee 100644 --- a/gen/books1-cli/src/main.rs +++ b/gen/books1-cli/src/main.rs @@ -1158,12 +1158,13 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "notification.more-from-series.opted-state" => Some(("notification.moreFromSeries.opted_state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "notification.more-from-authors.opted-state" => Some(("notification.moreFromAuthors.opted_state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "notes-export.is-enabled" => Some(("notesExport.isEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "notes-export.folder-name" => Some(("notesExport.folderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["folder-name", "is-enabled", "kind", "more-from-authors", "notes-export", "notification", "opted-state"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["folder-name", "is-enabled", "kind", "more-from-authors", "more-from-series", "notes-export", "notification", "opted-state"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2919,6 +2920,9 @@ impl<'n> Engine<'n> { "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, + "max-allowed-maturity-rating" => { + call = call.max_allowed_maturity_rating(value.unwrap_or("")); + }, "library-restrict" => { call = call.library_restrict(value.unwrap_or("")); }, @@ -2944,7 +2948,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["order-by", "projection", "library-restrict", "lang-restrict", "print-type", "show-preorders", "max-results", "filter", "source", "start-index", "download", "partner"].iter().map(|v|*v)); + v.extend(["order-by", "projection", "library-restrict", "lang-restrict", "print-type", "show-preorders", "max-results", "filter", "source", "start-index", "max-allowed-maturity-rating", "download", "partner"].iter().map(|v|*v)); v } )); } } @@ -4697,8 +4701,8 @@ fn main() { let mut app = App::new("books1") .author("Sebastian Thiel ") - .version("0.3.6+20160226") - .about("Lets you search for books and manage your Google Books library.") + .version("0.3.6+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") .long("scope") diff --git a/gen/books1/Cargo.toml b/gen/books1/Cargo.toml index 380a535225..9ef7bdb4b1 100644 --- a/gen/books1/Cargo.toml +++ b/gen/books1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-books1" -version = "0.1.14+20160226" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/books1/README.md b/gen/books1/README.md index 16a67b04bc..691caadf43 100644 --- a/gen/books1/README.md +++ b/gen/books1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-books1` library allows access to all features of the *Google books* service. -This documentation was generated from *books* crate version *0.1.14+20160226*, where *20160226* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *books* crate version *0.1.14+20160823*, where *20160823* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *books* *v1* API can be found at the [official documentation site](https://developers.google.com/books/docs/v1/getting_started). @@ -130,10 +130,11 @@ let result = hub.volumes().list("q") .partner("kasd") .order_by("accusam") .max_results(93) - .library_restrict("justo") - .lang_restrict("amet.") - .filter("erat") - .download("labore") + .max_allowed_maturity_rating("justo") + .library_restrict("amet.") + .lang_restrict("erat") + .filter("labore") + .download("sea") .doit(); match result { diff --git a/gen/books1/src/lib.rs b/gen/books1/src/lib.rs index 70d0238bbe..983505ac34 100644 --- a/gen/books1/src/lib.rs +++ b/gen/books1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *books* crate version *0.1.14+20160226*, where *20160226* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *books* crate version *0.1.14+20160823*, where *20160823* is the exact revision of the *books:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *books* *v1* API can be found at the //! [official documentation site](https://developers.google.com/books/docs/v1/getting_started). @@ -124,16 +124,17 @@ //! // Values shown here are possibly random and not representative ! //! let result = hub.volumes().list("q") //! .start_index(22) -//! .source("nonumy") +//! .source("magna") //! .show_preorders(false) -//! .projection("diam") -//! .print_type("magna") -//! .partner("dolor") -//! .order_by("Lorem") -//! .max_results(52) -//! .library_restrict("vero") -//! .lang_restrict("nonumy") -//! .filter("takimata") +//! .projection("Lorem") +//! .print_type("dolor") +//! .partner("vero") +//! .order_by("nonumy") +//! .max_results(93) +//! .max_allowed_maturity_rating("dolores") +//! .library_restrict("consetetur") +//! .lang_restrict("erat") +//! .filter("amet.") //! .download("dolores") //! .doit(); //! diff --git a/gen/books1/src/lib.rs.in b/gen/books1/src/lib.rs.in index 94a5b4766c..8712fe1ddb 100644 --- a/gen/books1/src/lib.rs.in +++ b/gen/books1/src/lib.rs.in @@ -92,18 +92,19 @@ impl Default for Scope { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.volumes().list("q") -/// .start_index(11) -/// .source("dolores") +/// .start_index(82) +/// .source("gubergren") /// .show_preorders(false) -/// .projection("sadipscing") -/// .print_type("aliquyam") -/// .partner("ea") -/// .order_by("no") +/// .projection("aliquyam") +/// .print_type("ea") +/// .partner("no") +/// .order_by("justo") /// .max_results(80) -/// .library_restrict("justo") -/// .lang_restrict("et") -/// .filter("et") -/// .download("diam") +/// .max_allowed_maturity_rating("et") +/// .library_restrict("et") +/// .lang_restrict("diam") +/// .filter("ipsum") +/// .download("Lorem") /// .doit(); /// /// match result { @@ -387,6 +388,8 @@ pub struct VolumeSaleInfoOffers { /// Offer retail (=discounted) price in Micros #[serde(rename="retailPrice")] pub retail_price: Option, + /// Indicates whether the offer is giftable. + pub giftable: Option, /// Offer list (=undiscounted) price in Micros. #[serde(rename="listPrice")] pub list_price: Option, @@ -442,18 +445,25 @@ pub struct Discoveryclusters { impl ResponseResult for Discoveryclusters {} -/// Recommendation related information for this volume. +/// Information on the ability to share with the family. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VolumeRecommendedInfo { - /// A text explaining why this volume is recommended. - pub explanation: Option, +pub struct VolumeUserInfoFamilySharing { + /// Whether or not sharing this volume is temporarily disabled due to issues with the Family Wallet. + #[serde(rename="isSharingDisabledByFop")] + pub is_sharing_disabled_by_fop: Option, + /// The role of the user in the family. + #[serde(rename="familyRole")] + pub family_role: Option, + /// Whether or not this volume can be shared with the family by the user. This includes sharing eligibility of both the volume and the user. If the value is true, the user can initiate a family sharing action. + #[serde(rename="isSharingAllowed")] + pub is_sharing_allowed: Option, } -impl NestedType for VolumeRecommendedInfo {} -impl Part for VolumeRecommendedInfo {} +impl NestedType for VolumeUserInfoFamilySharing {} +impl Part for VolumeUserInfoFamilySharing {} /// There is no detailed description. @@ -492,10 +502,15 @@ impl Part for VolumeseriesinfoVolumeSeries {} pub struct Notification { /// no description provided pub body: Option, + /// no description provided + pub doc_type: Option, /// Resource type. pub kind: Option, /// no description provided pub title: Option, + /// The list of crm experiment ids. + #[serde(rename="crmExperimentIds")] + pub crm_experiment_ids: Option>, /// no description provided pub dont_show_notification: Option, /// no description provided @@ -512,6 +527,8 @@ pub struct Notification { pub notification_type: Option, /// no description provided pub pcampaign_id: Option, + /// no description provided + pub doc_id: Option, } impl ResponseResult for Notification {} @@ -1329,6 +1346,20 @@ pub struct Review { impl Part for Review {} +/// Recommendation related information for this volume. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VolumeRecommendedInfo { + /// A text explaining why this volume is recommended. + pub explanation: Option, +} + +impl NestedType for VolumeRecommendedInfo {} +impl Part for VolumeRecommendedInfo {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1381,6 +1412,20 @@ impl RequestValue for Usersettings {} impl ResponseResult for Usersettings {} +/// 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 UsersettingsNotificationMoreFromSeries { + /// no description provided + pub opted_state: Option, +} + +impl NestedType for UsersettingsNotificationMoreFromSeries {} +impl Part for UsersettingsNotificationMoreFromSeries {} + + /// There is no detailed description. /// /// # Activities @@ -1577,6 +1622,9 @@ pub struct VolumeVolumeInfo { /// The main category to which this volume belongs. It will be the category from the categories list returned below that has the highest weight. #[serde(rename="mainCategory")] pub main_category: Option, + /// A top-level summary of the panelization info in this volume. + #[serde(rename="panelizationSummary")] + pub panelization_summary: Option, /// The names of the authors and/or editors for this volume. (In LITE projection) pub authors: Option>, /// A list of subject categories, such as "Fiction", "Suspense", etc. @@ -1831,6 +1879,9 @@ impl Part for VolumeVolumeInfoIndustryIdentifiers {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UsersettingsNotification { + /// no description provided + #[serde(rename="moreFromSeries")] + pub more_from_series: Option, /// no description provided #[serde(rename="moreFromAuthors")] pub more_from_authors: Option, @@ -1936,6 +1987,9 @@ pub struct VolumeUserInfo { pub is_preordered: Option, /// Copy/Paste accounting information. pub copy: Option, + /// Deprecated: Replaced by familySharing. + #[serde(rename="isFamilySharingDisabledByFop")] + pub is_family_sharing_disabled_by_fop: Option, /// Whether or not this volume was user uploaded. #[serde(rename="isUploaded")] pub is_uploaded: Option, @@ -1948,10 +2002,13 @@ pub struct VolumeUserInfo { /// no description provided #[serde(rename="userUploadedVolumeInfo")] pub user_uploaded_volume_info: Option, + /// Information on the ability to share with the family. + #[serde(rename="familySharing")] + pub family_sharing: Option, /// Whether this book is an active or an expired rental. #[serde(rename="rentalState")] pub rental_state: Option, - /// Whether or not this volume can be shared with the family by the user. This includes sharing eligibility of both the volume and the user. If the value is true, the user can initiate a family sharing action. + /// Deprecated: Replaced by familySharing. #[serde(rename="isFamilySharingAllowed")] pub is_family_sharing_allowed: Option, /// The user's current reading position in the volume, if one is available. (In LITE projection.) @@ -2112,6 +2169,30 @@ pub struct Series { impl ResponseResult for Series {} +/// A top-level summary of the panelization info in this volume. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VolumeVolumeInfoPanelizationSummary { + /// no description provided + #[serde(rename="containsEpubBubbles")] + pub contains_epub_bubbles: Option, + /// no description provided + #[serde(rename="containsImageBubbles")] + pub contains_image_bubbles: Option, + /// no description provided + #[serde(rename="epubBubbleVersion")] + pub epub_bubble_version: Option, + /// no description provided + #[serde(rename="imageBubbleVersion")] + pub image_bubble_version: Option, +} + +impl NestedType for VolumeVolumeInfoPanelizationSummary {} +impl Part for VolumeVolumeInfoPanelizationSummary {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2462,6 +2543,7 @@ impl<'a, C, A> VolumeMethods<'a, C, A> { _partner: Default::default(), _order_by: Default::default(), _max_results: Default::default(), + _max_allowed_maturity_rating: Default::default(), _library_restrict: Default::default(), _lang_restrict: Default::default(), _filter: Default::default(), @@ -3638,12 +3720,12 @@ impl<'a, C, A> CloudloadingMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.layers().annotation_data_get("volumeId", "layerId", "annotationDataId", "contentVersion") -/// .w(-32) -/// .source("sea") -/// .scale(-55) -/// .locale("eos") -/// .h(-81) -/// .allow_web_definitions(false) +/// .w(-55) +/// .source("eos") +/// .scale(-81) +/// .locale("sadipscing") +/// .h(-48) +/// .allow_web_definitions(true) /// .doit(); /// # } /// ``` @@ -3981,8 +4063,8 @@ impl<'a, C, A> LayerAnnotationDataGetCall<'a, C, A> where C: BorrowMut LayerVolumeAnnotationGetCall<'a, C, A> where C: BorrowMut LayerListCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.layers().get("volumeId", "summaryId") -/// .source("sea") +/// .source("duo") /// .content_version("et") /// .doit(); /// # } @@ -4818,18 +4900,18 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.layers().volume_annotations_list("volumeId", "layerId", "contentVersion") -/// .volume_annotations_version("sanctus") +/// .volume_annotations_version("amet") /// .updated_min("et") -/// .updated_max("amet") -/// .start_position("et") -/// .start_offset("consetetur") -/// .source("ut") +/// .updated_max("consetetur") +/// .start_position("ut") +/// .start_offset("ea") +/// .source("sed") /// .show_deleted(true) -/// .page_token("sed") -/// .max_results(98) -/// .locale("dolor") -/// .end_position("dolor") -/// .end_offset("et") +/// .page_token("dolor") +/// .max_results(53) +/// .locale("et") +/// .end_position("consetetur") +/// .end_offset("amet.") /// .doit(); /// # } /// ``` @@ -5221,16 +5303,16 @@ impl<'a, C, A> LayerVolumeAnnotationListCall<'a, C, A> where C: BorrowMut LayerAnnotationDataListCall<'a, C, A> where C: BorrowMut VolumeRecommendedRateCall<'a, C, A> where C: BorrowMut VolumeGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.volumes().mybooks_list() -/// .start_index(61) -/// .source("kasd") -/// .add_processing_state("sanctus") -/// .max_results(43) -/// .locale("At") -/// .country("labore") -/// .add_acquire_method("invidunt") +/// .start_index(94) +/// .source("takimata") +/// .add_processing_state("At") +/// .max_results(15) +/// .locale("invidunt") +/// .country("ea") +/// .add_acquire_method("sadipscing") /// .doit(); /// # } /// ``` @@ -6364,7 +6446,7 @@ impl<'a, C, A> VolumeMybookListCall<'a, C, A> where C: BorrowMut, self._country = Some(new_value.to_string()); self } - /// How the book was aquired + /// How the book was acquired /// /// Append the given value to the *acquire method* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. @@ -6451,18 +6533,19 @@ impl<'a, C, A> VolumeMybookListCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.volumes().list("q") -/// .start_index(6) -/// .source("rebum.") +/// .start_index(68) +/// .source("nonumy") /// .show_preorders(true) -/// .projection("nonumy") -/// .print_type("sed") -/// .partner("aliquyam") -/// .order_by("sit") -/// .max_results(61) -/// .library_restrict("consetetur") -/// .lang_restrict("labore") -/// .filter("sed") -/// .download("ea") +/// .projection("aliquyam") +/// .print_type("sit") +/// .partner("eirmod") +/// .order_by("consetetur") +/// .max_results(16) +/// .max_allowed_maturity_rating("sed") +/// .library_restrict("ea") +/// .lang_restrict("gubergren") +/// .filter("aliquyam") +/// .download("eos") /// .doit(); /// # } /// ``` @@ -6479,6 +6562,7 @@ pub struct VolumeListCall<'a, C, A> _partner: Option, _order_by: Option, _max_results: Option, + _max_allowed_maturity_rating: Option, _library_restrict: Option, _lang_restrict: Option, _filter: Option, @@ -6504,7 +6588,7 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa }; dlg.begin(MethodInfo { id: "books.volumes.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); params.push(("q", self._q.to_string())); if let Some(value) = self._start_index { params.push(("startIndex", value.to_string())); @@ -6530,6 +6614,9 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } + if let Some(value) = self._max_allowed_maturity_rating { + params.push(("maxAllowedMaturityRating", value.to_string())); + } if let Some(value) = self._library_restrict { params.push(("libraryRestrict", value.to_string())); } @@ -6542,7 +6629,7 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa if let Some(value) = self._download { params.push(("download", value.to_string())); } - for &field in ["alt", "q", "startIndex", "source", "showPreorders", "projection", "printType", "partner", "orderBy", "maxResults", "libraryRestrict", "langRestrict", "filter", "download"].iter() { + for &field in ["alt", "q", "startIndex", "source", "showPreorders", "projection", "printType", "partner", "orderBy", "maxResults", "maxAllowedMaturityRating", "libraryRestrict", "langRestrict", "filter", "download"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6702,6 +6789,13 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa self._max_results = Some(new_value); self } + /// The maximum allowed maturity rating of returned recommendations. Books with a higher maturity rating are filtered out. + /// + /// Sets the *max allowed maturity rating* query property to the given value. + pub fn max_allowed_maturity_rating(mut self, new_value: &str) -> VolumeListCall<'a, C, A> { + self._max_allowed_maturity_rating = Some(new_value.to_string()); + self + } /// Restrict search to this user's library. /// /// Sets the *library restrict* query property to the given value. @@ -6809,12 +6903,12 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.volumes().useruploaded_list() -/// .add_volume_id("gubergren") -/// .start_index(19) -/// .source("eos") -/// .add_processing_state("tempor") -/// .max_results(42) -/// .locale("labore") +/// .add_volume_id("tempor") +/// .start_index(42) +/// .source("labore") +/// .add_processing_state("ipsum") +/// .max_results(70) +/// .locale("dolores") /// .doit(); /// # } /// ``` @@ -7089,10 +7183,10 @@ impl<'a, C, A> VolumeUseruploadedListCall<'a, C, A> where C: BorrowMut VolumeAssociatedListCall<'a, C, A> where C: BorrowMut SeryGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.series().membership_get("series_id") -/// .page_token("diam") -/// .page_size(30) +/// .page_token("clita") +/// .page_size(64) /// .doit(); /// # } /// ``` @@ -8281,10 +8375,10 @@ impl<'a, C, A> SeryMembershipGetCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.bookshelves().volumes_list("userId", "shelf") -/// .start_index(64) -/// .source("ut") +/// .start_index(77) +/// .source("voluptua.") /// .show_preorders(true) -/// .max_results(77) +/// .max_results(8) /// .doit(); /// # } /// ``` @@ -8576,7 +8670,7 @@ impl<'a, C, A> BookshelveVolumeListCall<'a, C, A> where C: BorrowMut BookshelveListCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.bookshelves().get("userId", "shelf") -/// .source("ea") +/// .source("dolor") /// .doit(); /// # } /// ``` @@ -9082,14 +9176,14 @@ impl<'a, C, A> BookshelveGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.promooffer().accept() -/// .volume_id("ea") -/// .serial("et") -/// .product("dolor") -/// .offer_id("diam") -/// .model("kasd") -/// .manufacturer("invidunt") -/// .device("rebum.") -/// .android_id("Lorem") +/// .volume_id("diam") +/// .serial("kasd") +/// .product("invidunt") +/// .offer_id("rebum.") +/// .model("Lorem") +/// .manufacturer("clita") +/// .device("invidunt") +/// .android_id("eirmod") /// .doit(); /// # } /// ``` @@ -9368,13 +9462,13 @@ impl<'a, C, A> PromoofferAcceptCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.promooffer().dismiss() -/// .serial("clita") -/// .product("invidunt") -/// .offer_id("eirmod") -/// .model("At") -/// .manufacturer("consetetur") -/// .device("et") -/// .android_id("sed") +/// .serial("At") +/// .product("consetetur") +/// .offer_id("et") +/// .model("sed") +/// .manufacturer("sit") +/// .device("takimata") +/// .android_id("elitr") /// .doit(); /// # } /// ``` @@ -9643,12 +9737,12 @@ impl<'a, C, A> PromoofferDismisCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.promooffer().get() -/// .serial("sit") -/// .product("takimata") -/// .model("elitr") -/// .manufacturer("nonumy") -/// .device("rebum.") -/// .android_id("Lorem") +/// .serial("nonumy") +/// .product("rebum.") +/// .model("Lorem") +/// .manufacturer("Lorem") +/// .device("diam") +/// .android_id("ut") /// .doit(); /// # } /// ``` @@ -9917,9 +10011,9 @@ impl<'a, C, A> PromoofferGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.personalizedstream().get() -/// .source("Lorem") -/// .max_allowed_maturity_rating("diam") -/// .locale("ut") +/// .source("ut") +/// .max_allowed_maturity_rating("amet.") +/// .locale("ipsum") /// .doit(); /// # } /// ``` @@ -10369,11 +10463,11 @@ impl<'a, C, A> OnboardingListCategoryCall<'a, C, A> where C: BorrowMut OnboardingListCategoryVolumeCall<'a, C, A> where C: BorrowMut MyconfigRequestAccesCall<'a, C, A> where C: BorrowMut MyconfigReleaseDownloadAccesCall<'a, C, A> where C: BorrowMut MyconfigUpdateUserSettingCall<'a, C, A> where C: BorrowMut MylibraryBookshelveClearVolumeCall<'a, C, A> where C: BorrowMut MylibraryBookshelveMoveVolumeCall<'a, C, A> where C: BorrowMut MylibraryAnnotationSummaryCall<'a, C, A> where C: BorrowMut MylibraryAnnotationDeleteCall<'a, C, A> where C: BorrowMut MylibraryBookshelveAddVolumeCall<'a, C, A> where C: BorrowMut MylibraryAnnotationInsertCall<'a, C, A> where C: BorrowMut MylibraryBookshelveRemoveVolumeCall<'a, C, A> where C: BorrowMut< /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mylibrary().annotations_list() -/// .volume_id("Lorem") -/// .updated_min("consetetur") -/// .updated_max("consetetur") -/// .source("eirmod") +/// .volume_id("eirmod") +/// .updated_min("labore") +/// .updated_max("gubergren") +/// .source("et") /// .show_deleted(true) -/// .page_token("gubergren") -/// .max_results(28) -/// .add_layer_ids("sadipscing") -/// .layer_id("accusam") -/// .content_version("magna") +/// .page_token("accusam") +/// .max_results(69) +/// .add_layer_ids("Lorem") +/// .layer_id("rebum.") +/// .content_version("et") /// .doit(); /// # } /// ``` @@ -14304,7 +14398,7 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut MylibraryAnnotationUpdateCall<'a, C, A> where C: BorrowMut MylibraryReadingpositionSetPositionCall<'a, C, A> where C: Borrow /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mylibrary().bookshelves_get("shelf") -/// .source("eos") +/// .source("gubergren") /// .doit(); /// # } /// ``` @@ -15119,7 +15213,7 @@ impl<'a, C, A> MylibraryBookshelveGetCall<'a, C, A> where C: BorrowMut MylibraryBookshelveListCall<'a, C, A> where C: BorrowMut MylibraryReadingpositionGetCall<'a, C, A> where C: BorrowMut NotificationGetCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.cloudloading().add_book() -/// .upload_client_token("elitr") -/// .name("magna") -/// .mime_type("ipsum") -/// .drive_document_id("invidunt") +/// .upload_client_token("invidunt") +/// .name("accusam") +/// .mime_type("labore") +/// .drive_document_id("diam") /// .doit(); /// # } /// ``` diff --git a/gen/calendar3-cli/Cargo.toml b/gen/calendar3-cli/Cargo.toml index 8d81bdde22..2013b1d0bc 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+20160405" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "calendar3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-calendar3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-calendar3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-calendar3] diff --git a/gen/calendar3-cli/README.md b/gen/calendar3-cli/README.md index aaace4b76f..466ead93e6 100644 --- a/gen/calendar3-cli/README.md +++ b/gen/calendar3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *calendar* API at revision *20160405*. The CLI is at version *0.3.6*. +This documentation was generated from the *calendar* API at revision *20160830*. The CLI is at version *0.3.6*. ```bash calendar3 [options] diff --git a/gen/calendar3-cli/mkdocs.yml b/gen/calendar3-cli/mkdocs.yml index 20011e269f..e8ba32e892 100644 --- a/gen/calendar3-cli/mkdocs.yml +++ b/gen/calendar3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: calendar v0.3.6+20160405 +site_name: calendar v0.3.6+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 d311bcd3ec..3fd099bf64 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+20160405") + .version("0.3.6+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/calendar3/Cargo.toml b/gen/calendar3/Cargo.toml index 7c8bd547f4..1a049c8087 100644 --- a/gen/calendar3/Cargo.toml +++ b/gen/calendar3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-calendar3" -version = "0.1.14+20160405" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/calendar3/README.md b/gen/calendar3/README.md index c39cda8b35..3d05506d9c 100644 --- a/gen/calendar3/README.md +++ b/gen/calendar3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-calendar3` library allows access to all features of the *Google calendar* service. -This documentation was generated from *calendar* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *calendar* crate version *0.1.14+20160830*, where *20160830* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *calendar* *v3* API can be found at the [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). diff --git a/gen/calendar3/src/lib.rs b/gen/calendar3/src/lib.rs index 4f95af0c27..917fed6f22 100644 --- a/gen/calendar3/src/lib.rs +++ b/gen/calendar3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *calendar* crate version *0.1.14+20160405*, where *20160405* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *calendar* crate version *0.1.14+20160830*, where *20160830* is the exact revision of the *calendar:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *calendar* *v3* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). diff --git a/gen/civicinfo2-cli/Cargo.toml b/gen/civicinfo2-cli/Cargo.toml index 84bfc743c6..b8b5df0b5f 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+20150820" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "civicinfo2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-civicinfo2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-civicinfo2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-civicinfo2] diff --git a/gen/civicinfo2-cli/README.md b/gen/civicinfo2-cli/README.md index 104e45c9fb..65283cc58d 100644 --- a/gen/civicinfo2-cli/README.md +++ b/gen/civicinfo2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Civic Info* API at revision *20150820*. 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 *0.3.6*. ```bash civicinfo2 [options] diff --git a/gen/civicinfo2-cli/mkdocs.yml b/gen/civicinfo2-cli/mkdocs.yml index 7e5feef242..93c59370bb 100644 --- a/gen/civicinfo2-cli/mkdocs.yml +++ b/gen/civicinfo2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Civic Info v0.3.6+20150820 +site_name: Civic Info v0.3.6+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 767a593a3e..ce8d828750 100644 --- a/gen/civicinfo2-cli/src/main.rs +++ b/gen/civicinfo2-cli/src/main.rs @@ -153,6 +153,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "return-all-available-data" => { + call = call.return_all_available_data(arg_from_str(value.unwrap_or("false"), err, "return-all-available-data", "boolean")); + }, "official-only" => { call = call.official_only(arg_from_str(value.unwrap_or("false"), err, "official-only", "boolean")); }, @@ -172,7 +175,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["election-id", "official-only"].iter().map(|v|*v)); + v.extend(["election-id", "official-only", "return-all-available-data"].iter().map(|v|*v)); v } )); } } @@ -555,8 +558,8 @@ fn main() { let mut app = App::new("civicinfo2") .author("Sebastian Thiel ") - .version("0.3.6+20150820") - .about("An API for accessing civic information.") + .version("0.3.6+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") .long("config-dir") diff --git a/gen/civicinfo2/Cargo.toml b/gen/civicinfo2/Cargo.toml index 15dd05745a..4f631dec7f 100644 --- a/gen/civicinfo2/Cargo.toml +++ b/gen/civicinfo2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-civicinfo2" -version = "0.1.14+20150820" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/civicinfo2/README.md b/gen/civicinfo2/README.md index 85614f27af..3b2f47c837 100644 --- a/gen/civicinfo2/README.md +++ b/gen/civicinfo2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-civicinfo2` library allows access to all features of the *Google Civic Info* service. -This documentation was generated from *Civic Info* crate version *0.1.14+20150820*, where *20150820* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Civic Info* crate version *0.1.14+20160823*, where *20160823* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Civic Info* *v2* API can be found at the [official documentation site](https://developers.google.com/civic-information). @@ -98,8 +98,9 @@ let mut hub = CivicInfo::new(hyper::Client::new(), auth); // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! let result = hub.elections().voter_info_query("address") - .official_only(true) - .election_id("Stet") + .return_all_available_data(true) + .official_only(false) + .election_id("sed") .doit(); match result { diff --git a/gen/civicinfo2/src/lib.rs b/gen/civicinfo2/src/lib.rs index 1262eb6641..961f11ae81 100644 --- a/gen/civicinfo2/src/lib.rs +++ b/gen/civicinfo2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Civic Info* crate version *0.1.14+20150820*, where *20150820* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Civic Info* crate version *0.1.14+20160823*, where *20160823* is the exact revision of the *civicinfo:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Civic Info* *v2* API can be found at the //! [official documentation site](https://developers.google.com/civic-information). @@ -99,8 +99,9 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.elections().voter_info_query("address") -//! .official_only(false) -//! .election_id("no") +//! .return_all_available_data(true) +//! .official_only(true) +//! .election_id("et") //! .doit(); //! //! match result { diff --git a/gen/civicinfo2/src/lib.rs.in b/gen/civicinfo2/src/lib.rs.in index e791284d9d..eadcc176c9 100644 --- a/gen/civicinfo2/src/lib.rs.in +++ b/gen/civicinfo2/src/lib.rs.in @@ -70,8 +70,9 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.elections().voter_info_query("address") +/// .return_all_available_data(true) /// .official_only(false) -/// .election_id("dolores") +/// .election_id("accusam") /// .doit(); /// /// match result { @@ -194,6 +195,9 @@ impl Part for Official {} pub struct ElectoralDistrict { /// The geographic scope of this district. If unspecified the district's geography is not known. One of: national, statewide, congressional, stateUpper, stateLower, countywide, judicial, schoolBoard, cityWide, township, countyCouncil, cityCouncil, ward, special pub scope: Option, + /// no description provided + #[serde(rename="kgForeignKey")] + pub kg_foreign_key: Option, /// An identifier for this district, relative to its scope. For example, the 34th State Senate district would have id "34" and a scope of stateUpper. pub id: Option, /// The name of the district. @@ -312,7 +316,7 @@ pub struct Contest { /// A number specifying the position of this contest on the voter's ballot. #[serde(rename="ballotPlacement")] pub ballot_placement: Option, - /// The set of ballot responses for the referendum. A ballot response represents a line on the ballot. Common examples might include "yes" or "no" for referenda, or a judge's name for a retention contest. This field is only populated for contests of type 'Referendum'. + /// The set of ballot responses for the referendum. A ballot response represents a line on the ballot. Common examples might include "yes" or "no" for referenda. This field is only populated for contests of type 'Referendum'. #[serde(rename="referendumBallotResponses")] pub referendum_ballot_responses: Option>, /// A statement in favor of the referendum. It does not necessarily appear on the ballot. This field is only populated for contests of type 'Referendum'. @@ -320,7 +324,7 @@ pub struct Contest { pub referendum_pro_statement: Option, /// The candidate choices for this contest. pub candidates: Option>, - /// The type of contest. Usually this will be 'General', 'Primary', or 'Run-off' for contests with candidates. For referenda this will be 'Referendum'. + /// The type of contest. Usually this will be 'General', 'Primary', or 'Run-off' for contests with candidates. For referenda this will be 'Referendum'. For Retention contests this will typically be 'Retention'. #[serde(rename="type")] pub type_: Option, } @@ -443,9 +447,9 @@ pub struct AdministrativeBody { /// The mailing address of this administrative body. #[serde(rename="correspondenceAddress")] pub correspondence_address: Option, - /// A URL provided by this administrative body describing election rules to the voter. - #[serde(rename="electionRulesUrl")] - pub election_rules_url: Option, + /// no description provided + #[serde(rename="addressLines")] + pub address_lines: Option>, /// A description of the services this administrative body may provide. pub voter_services: Option>, /// A URL provided by this administrative body to give contest information to the voter. @@ -457,6 +461,9 @@ pub struct AdministrativeBody { /// The physical address of this administrative body. #[serde(rename="physicalAddress")] pub physical_address: Option, + /// A URL provided by this administrative body describing election rules to the voter. + #[serde(rename="electionRulesUrl")] + pub election_rules_url: Option, } impl Part for AdministrativeBody {} @@ -815,6 +822,7 @@ impl<'a, C, A> ElectionMethods<'a, C, A> { ElectionVoterInfoQueryCall { hub: self.hub, _address: address.to_string(), + _return_all_available_data: Default::default(), _official_only: Default::default(), _election_id: Default::default(), _delegate: Default::default(), @@ -933,7 +941,7 @@ impl<'a, C, A> RepresentativeMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.divisions().search() -/// .query("kasd") +/// .query("takimata") /// .doit(); /// # } /// ``` @@ -1305,8 +1313,9 @@ impl<'a, C, A> ElectionElectionQueryCall<'a, C, A> where C: BorrowMut hub: &'a CivicInfo, _address: String, + _return_all_available_data: Option, _official_only: Option, _election_id: Option, _delegate: Option<&'a mut Delegate>, @@ -1337,15 +1347,18 @@ impl<'a, C, A> ElectionVoterInfoQueryCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("address", self._address.to_string())); + if let Some(value) = self._return_all_available_data { + params.push(("returnAllAvailableData", value.to_string())); + } if let Some(value) = self._official_only { params.push(("officialOnly", value.to_string())); } if let Some(value) = self._election_id { params.push(("electionId", value.to_string())); } - for &field in ["alt", "address", "officialOnly", "electionId"].iter() { + for &field in ["alt", "address", "returnAllAvailableData", "officialOnly", "electionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1444,6 +1457,13 @@ impl<'a, C, A> ElectionVoterInfoQueryCall<'a, C, A> where C: BorrowMut ElectionVoterInfoQueryCall<'a, C, A> { + self._return_all_available_data = Some(new_value); + self + } /// If set to true, only data from official state sources will be returned. /// /// Sets the *official only* query property to the given value. @@ -1521,10 +1541,10 @@ impl<'a, C, A> ElectionVoterInfoQueryCall<'a, C, A> where C: BorrowMut RepresentativeRepresentativeInfoByAddresCall<'a, C, A> where C: B /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.representatives().representative_info_by_division("ocdId") -/// .add_roles("dolores") +/// .add_roles("aliquyam") /// .recursive(false) -/// .add_levels("sadipscing") +/// .add_levels("no") /// .doit(); /// # } /// ``` diff --git a/gen/classroom1-cli/Cargo.toml b/gen/classroom1-cli/Cargo.toml index e115438fc1..1a65b6feb1 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+20151013" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "classroom1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-classroom1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-classroom1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-classroom1] diff --git a/gen/classroom1-cli/README.md b/gen/classroom1-cli/README.md index 036b3fe803..33628f44c6 100644 --- a/gen/classroom1-cli/README.md +++ b/gen/classroom1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *classroom* API at revision *20151013*. The CLI is at version *0.3.6*. +This documentation was generated from the *classroom* API at revision *20160816*. The CLI is at version *0.3.6*. ```bash classroom1 [options] @@ -32,6 +32,16 @@ classroom1 [options] aliases-create (-r )... [-p ]... [-o ] aliases-delete [-p ]... [-o ] aliases-list [-p ]... [-o ] + course-work-create (-r )... [-p ]... [-o ] + course-work-get [-p ]... [-o ] + course-work-list [-p ]... [-o ] + course-work-student-submissions-get [-p ]... [-o ] + course-work-student-submissions-list [-p ]... [-o ] + course-work-student-submissions-modify-attachments (-r )... [-p ]... [-o ] + course-work-student-submissions-patch (-r )... [-p ]... [-o ] + course-work-student-submissions-reclaim (-r )... [-p ]... [-o ] + course-work-student-submissions-return (-r )... [-p ]... [-o ] + course-work-student-submissions-turn-in (-r )... [-p ]... [-o ] create (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] @@ -54,6 +64,13 @@ classroom1 [options] list [-p ]... [-o ] user-profiles get [-p ]... [-o ] + guardian-invitations-create (-r )... [-p ]... [-o ] + guardian-invitations-get [-p ]... [-o ] + guardian-invitations-list [-p ]... [-o ] + guardian-invitations-patch (-r )... [-p ]... [-o ] + guardians-delete [-p ]... [-o ] + guardians-get [-p ]... [-o ] + guardians-list [-p ]... [-o ] classroom1 --help Configuration: diff --git a/gen/classroom1-cli/mkdocs.yml b/gen/classroom1-cli/mkdocs.yml index 5436ab26fb..84b86a6e10 100644 --- a/gen/classroom1-cli/mkdocs.yml +++ b/gen/classroom1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: classroom v0.3.6+20151013 +site_name: classroom v0.3.6+20160816 site_url: http://byron.github.io/google-apis-rs/google-classroom1-cli site_description: Write integrating applications with bcore @@ -12,6 +12,16 @@ pages: - ['courses_aliases-create.md', 'Courses', 'Aliases Create'] - ['courses_aliases-delete.md', 'Courses', 'Aliases Delete'] - ['courses_aliases-list.md', 'Courses', 'Aliases List'] +- ['courses_course-work-create.md', 'Courses', 'Course Work Create'] +- ['courses_course-work-get.md', 'Courses', 'Course Work Get'] +- ['courses_course-work-list.md', 'Courses', 'Course Work List'] +- ['courses_course-work-student-submissions-get.md', 'Courses', 'Course Work Student Submissions Get'] +- ['courses_course-work-student-submissions-list.md', 'Courses', 'Course Work Student Submissions List'] +- ['courses_course-work-student-submissions-modify-attachments.md', 'Courses', 'Course Work Student Submissions Modify Attachments'] +- ['courses_course-work-student-submissions-patch.md', 'Courses', 'Course Work Student Submissions Patch'] +- ['courses_course-work-student-submissions-reclaim.md', 'Courses', 'Course Work Student Submissions Reclaim'] +- ['courses_course-work-student-submissions-return.md', 'Courses', 'Course Work Student Submissions Return'] +- ['courses_course-work-student-submissions-turn-in.md', 'Courses', 'Course Work Student Submissions Turn In'] - ['courses_create.md', 'Courses', 'Create'] - ['courses_delete.md', 'Courses', 'Delete'] - ['courses_get.md', 'Courses', 'Get'] @@ -32,6 +42,13 @@ pages: - ['invitations_get.md', 'Invitations', 'Get'] - ['invitations_list.md', 'Invitations', 'List'] - ['user-profiles_get.md', 'User Profiles', 'Get'] +- ['user-profiles_guardian-invitations-create.md', 'User Profiles', 'Guardian Invitations Create'] +- ['user-profiles_guardian-invitations-get.md', 'User Profiles', 'Guardian Invitations Get'] +- ['user-profiles_guardian-invitations-list.md', 'User Profiles', 'Guardian Invitations List'] +- ['user-profiles_guardian-invitations-patch.md', 'User Profiles', 'Guardian Invitations Patch'] +- ['user-profiles_guardians-delete.md', 'User Profiles', 'Guardians Delete'] +- ['user-profiles_guardians-get.md', 'User Profiles', 'Guardians Get'] +- ['user-profiles_guardians-list.md', 'User Profiles', 'Guardians List'] theme: readthedocs diff --git a/gen/classroom1-cli/src/main.rs b/gen/classroom1-cli/src/main.rs index 400eed6a46..8f715765f5 100644 --- a/gen/classroom1-cli/src/main.rs +++ b/gen/classroom1-cli/src/main.rs @@ -241,6 +241,789 @@ impl<'n> Engine<'n> { } } + fn _courses_course_work_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()[..] { + "update-time" => Some(("updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "submission-modification-mode" => Some(("submissionModificationMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "title" => Some(("title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-id" => Some(("courseId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "assignment.student-work-folder.alternate-link" => Some(("assignment.studentWorkFolder.alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "assignment.student-work-folder.id" => Some(("assignment.studentWorkFolder.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "assignment.student-work-folder.title" => Some(("assignment.studentWorkFolder.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "alternate-link" => Some(("alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "associated-with-developer" => Some(("associatedWithDeveloper", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "due-date.month" => Some(("dueDate.month", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "due-date.day" => Some(("dueDate.day", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "due-date.year" => Some(("dueDate.year", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "max-points" => Some(("maxPoints", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "multiple-choice-question.choices" => Some(("multipleChoiceQuestion.choices", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "due-time.hours" => Some(("dueTime.hours", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "due-time.seconds" => Some(("dueTime.seconds", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "due-time.minutes" => Some(("dueTime.minutes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "due-time.nanos" => Some(("dueTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "work-type" => Some(("workType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "assignment", "associated-with-developer", "choices", "course-id", "creation-time", "day", "description", "due-date", "due-time", "hours", "id", "max-points", "minutes", "month", "multiple-choice-question", "nanos", "seconds", "state", "student-work-folder", "submission-modification-mode", "title", "update-time", "work-type", "year"]); + 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::CourseWork = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_create(request, opt.value_of("course-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 _courses_course_work_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.courses().course_work_get(opt.value_of("course-id").unwrap_or(""), opt.value_of("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 _courses_course_work_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.courses().course_work_list(opt.value_of("course-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")); + }, + "order-by" => { + call = call.order_by(value.unwrap_or("")); + }, + "course-work-states" => { + call = call.add_course_work_states(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(["order-by", "page-token", "course-work-states", "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 _courses_course_work_student_submissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.courses().course_work_student_submissions_get(opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 _courses_course_work_student_submissions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.courses().course_work_student_submissions_list(opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-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 { + "user-id" => { + call = call.user_id(value.unwrap_or("")); + }, + "states" => { + call = call.add_states(value.unwrap_or("")); + }, + "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")); + }, + "late" => { + call = call.late(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(["states", "page-token", "user-id", "page-size", "late"].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 _courses_course_work_student_submissions_modify_attachments(&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::ModifyAttachmentsRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_student_submissions_modify_attachments(request, opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 _courses_course_work_student_submissions_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()[..] { + "draft-grade" => Some(("draftGrade", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "update-time" => Some(("updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "alternate-link" => Some(("alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-id" => Some(("courseId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "multiple-choice-submission.answer" => Some(("multipleChoiceSubmission.answer", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-id" => Some(("userId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "short-answer-submission.answer" => Some(("shortAnswerSubmission.answer", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "associated-with-developer" => Some(("associatedWithDeveloper", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "late" => Some(("late", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-work-id" => Some(("courseWorkId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-work-type" => Some(("courseWorkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "assigned-grade" => Some(("assignedGrade", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "answer", "assigned-grade", "associated-with-developer", "course-id", "course-work-id", "course-work-type", "creation-time", "draft-grade", "id", "late", "multiple-choice-submission", "short-answer-submission", "state", "update-time", "user-id"]); + 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::StudentSubmission = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_student_submissions_patch(request, opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 { + "update-mask" => { + call = call.update_mask(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(["update-mask"].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 _courses_course_work_student_submissions_reclaim(&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::ReclaimStudentSubmissionRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_student_submissions_reclaim(request, opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 _courses_course_work_student_submissions_return(&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::ReturnStudentSubmissionRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_student_submissions_return(request, opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 _courses_course_work_student_submissions_turn_in(&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::TurnInStudentSubmissionRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.courses().course_work_student_submissions_turn_in(request, opt.value_of("course-id").unwrap_or(""), opt.value_of("course-work-id").unwrap_or(""), opt.value_of("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 _courses_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { @@ -269,15 +1052,20 @@ impl<'n> Engine<'n> { "alternate-link" => Some(("alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "enrollment-code" => Some(("enrollmentCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "section" => Some(("section", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-group-email" => Some(("courseGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-group-email" => Some(("teacherGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner-id" => Some(("ownerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.alternate-link" => Some(("teacherFolder.alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.id" => Some(("teacherFolder.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.title" => Some(("teacherFolder.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "description-heading" => Some(("descriptionHeading", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "room" => Some(("room", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "update-time"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-group-email", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "teacher-folder", "teacher-group-email", "title", "update-time"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -534,15 +1322,20 @@ impl<'n> Engine<'n> { "alternate-link" => Some(("alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "enrollment-code" => Some(("enrollmentCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "section" => Some(("section", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-group-email" => Some(("courseGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-group-email" => Some(("teacherGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner-id" => Some(("ownerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.alternate-link" => Some(("teacherFolder.alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.id" => Some(("teacherFolder.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.title" => Some(("teacherFolder.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "description-heading" => Some(("descriptionHeading", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "room" => Some(("room", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "update-time"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-group-email", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "teacher-folder", "teacher-group-email", "title", "update-time"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -636,9 +1429,12 @@ impl<'n> Engine<'n> { "profile.name.given-name" => Some(("profile.name.givenName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "profile.name.family-name" => Some(("profile.name.familyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "profile.photo-url" => Some(("profile.photoUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "student-work-folder.alternate-link" => Some(("studentWorkFolder.alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "student-work-folder.id" => Some(("studentWorkFolder.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "student-work-folder.title" => Some(("studentWorkFolder.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-id" => Some(("userId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["course-id", "email-address", "family-name", "full-name", "given-name", "id", "name", "photo-url", "profile", "user-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-id", "email-address", "family-name", "full-name", "given-name", "id", "name", "photo-url", "profile", "student-work-folder", "title", "user-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1148,15 +1944,20 @@ impl<'n> Engine<'n> { "alternate-link" => Some(("alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "enrollment-code" => Some(("enrollmentCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "section" => Some(("section", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-group-email" => Some(("courseGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-group-email" => Some(("teacherGroupEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner-id" => Some(("ownerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.alternate-link" => Some(("teacherFolder.alternateLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.id" => Some(("teacherFolder.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "teacher-folder.title" => Some(("teacherFolder.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "course-state" => Some(("courseState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "description-heading" => Some(("descriptionHeading", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "room" => Some(("room", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "update-time"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["alternate-link", "course-group-email", "course-state", "creation-time", "description", "description-heading", "enrollment-code", "id", "name", "owner-id", "room", "section", "teacher-folder", "teacher-group-email", "title", "update-time"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1577,6 +2378,450 @@ impl<'n> Engine<'n> { } } + fn _user_profiles_guardian_invitations_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()[..] { + "invitation-id" => Some(("invitationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "student-id" => Some(("studentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "invited-email-address" => Some(("invitedEmailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "invitation-id", "invited-email-address", "state", "student-id"]); + 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::GuardianInvitation = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_profiles().guardian_invitations_create(request, opt.value_of("student-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); + 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 _user_profiles_guardian_invitations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().guardian_invitations_get(opt.value_of("student-id").unwrap_or(""), opt.value_of("invitation-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); + 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 _user_profiles_guardian_invitations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().guardian_invitations_list(opt.value_of("student-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 { + "states" => { + call = call.add_states(value.unwrap_or("")); + }, + "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")); + }, + "invited-email-address" => { + call = call.invited_email_address(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(["states", "page-token", "invited-email-address", "page-size"].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 _user_profiles_guardian_invitations_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()[..] { + "invitation-id" => Some(("invitationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "student-id" => Some(("studentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "invited-email-address" => Some(("invitedEmailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "invitation-id", "invited-email-address", "state", "student-id"]); + 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::GuardianInvitation = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_profiles().guardian_invitations_patch(request, opt.value_of("student-id").unwrap_or(""), opt.value_of("invitation-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 { + "update-mask" => { + call = call.update_mask(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(["update-mask"].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 _user_profiles_guardians_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().guardians_delete(opt.value_of("student-id").unwrap_or(""), opt.value_of("guardian-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); + 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 _user_profiles_guardians_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().guardians_get(opt.value_of("student-id").unwrap_or(""), opt.value_of("guardian-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); + 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 _user_profiles_guardians_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().guardians_list(opt.value_of("student-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")); + }, + "invited-email-address" => { + call = call.invited_email_address(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", "invited-email-address", "page-size"].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 _doit(&self, dry_run: bool) -> Result, Option> { let mut err = InvalidOptionsError::new(); let mut call_result: Result<(), DoitError> = Ok(()); @@ -1593,6 +2838,36 @@ impl<'n> Engine<'n> { ("aliases-list", Some(opt)) => { call_result = self._courses_aliases_list(opt, dry_run, &mut err); }, + ("course-work-create", Some(opt)) => { + call_result = self._courses_course_work_create(opt, dry_run, &mut err); + }, + ("course-work-get", Some(opt)) => { + call_result = self._courses_course_work_get(opt, dry_run, &mut err); + }, + ("course-work-list", Some(opt)) => { + call_result = self._courses_course_work_list(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-get", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_get(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-list", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_list(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-modify-attachments", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_modify_attachments(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-patch", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_patch(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-reclaim", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_reclaim(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-return", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_return(opt, dry_run, &mut err); + }, + ("course-work-student-submissions-turn-in", Some(opt)) => { + call_result = self._courses_course_work_student_submissions_turn_in(opt, dry_run, &mut err); + }, ("create", Some(opt)) => { call_result = self._courses_create(opt, dry_run, &mut err); }, @@ -1669,6 +2944,27 @@ impl<'n> Engine<'n> { ("get", Some(opt)) => { call_result = self._user_profiles_get(opt, dry_run, &mut err); }, + ("guardian-invitations-create", Some(opt)) => { + call_result = self._user_profiles_guardian_invitations_create(opt, dry_run, &mut err); + }, + ("guardian-invitations-get", Some(opt)) => { + call_result = self._user_profiles_guardian_invitations_get(opt, dry_run, &mut err); + }, + ("guardian-invitations-list", Some(opt)) => { + call_result = self._user_profiles_guardian_invitations_list(opt, dry_run, &mut err); + }, + ("guardian-invitations-patch", Some(opt)) => { + call_result = self._user_profiles_guardian_invitations_patch(opt, dry_run, &mut err); + }, + ("guardians-delete", Some(opt)) => { + call_result = self._user_profiles_guardians_delete(opt, dry_run, &mut err); + }, + ("guardians-get", Some(opt)) => { + call_result = self._user_profiles_guardians_get(opt, dry_run, &mut err); + }, + ("guardians-list", Some(opt)) => { + call_result = self._user_profiles_guardians_list(opt, dry_run, &mut err); + }, _ => { err.issues.push(CLIError::MissingMethodError("user-profiles".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); @@ -1761,7 +3057,7 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("courses", "methods: 'aliases-create', 'aliases-delete', 'aliases-list', 'create', 'delete', 'get', 'list', 'patch', 'students-create', 'students-delete', 'students-get', 'students-list', 'teachers-create', 'teachers-delete', 'teachers-get', 'teachers-list' and 'update'", vec![ + ("courses", "methods: 'aliases-create', 'aliases-delete', 'aliases-list', 'course-work-create', 'course-work-get', 'course-work-list', 'course-work-student-submissions-get', 'course-work-student-submissions-list', 'course-work-student-submissions-modify-attachments', 'course-work-student-submissions-patch', 'course-work-student-submissions-reclaim', 'course-work-student-submissions-return', 'course-work-student-submissions-turn-in', 'create', 'delete', 'get', 'list', 'patch', 'students-create', 'students-delete', 'students-get', 'students-list', 'teachers-create', 'teachers-delete', 'teachers-get', 'teachers-list' and 'update'", vec![ ("aliases-create", Some(r##"Creates an alias for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create the alias or for access errors. * `NOT_FOUND` if the course does not exist. * `ALREADY_EXISTS` if the alias already exists."##), "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_aliases-create", @@ -1834,6 +3130,346 @@ fn main() { 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)), + ]), + ("course-work-create", + Some(r##"Creates course work. The resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-create", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + 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)), + ]), + ("course-work-get", + Some(r##"Returns course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-get", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the course work."##), + 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)), + ]), + ("course-work-list", + Some(r##"Returns a list of course work that the requester is permitted to view. Course students may only view `PUBLISHED` course work. Course teachers and domain administrators may view all course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-list", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + 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)), + ]), + ("course-work-student-submissions-get", + Some(r##"Returns a student submission. * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, course work, or student submission or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-get", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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)), + ]), + ("course-work-student-submissions-list", + Some(r##"Returns a list of student submissions that the requester is permitted to view, factoring in the OAuth scopes of the request. `-` may be specified as the `course_work_id` to include student submissions for multiple course work items. Course students may only view their own work. Course teachers and domain administrators may view all student submissions. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-list", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifer of the student work to request. This may be set to the string literal `"-"` to request student work for all course work in the specified course."##), + 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)), + ]), + ("course-work-student-submissions-modify-attachments", + Some(r##"Modifies attachments of student submission. Attachments may only be added to student submissions whose type is `ASSIGNMENT`. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, if the user is not permitted to modify attachments on the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-modify-attachments", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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)), + ]), + ("course-work-student-submissions-patch", + Some(r##"Updates one or more fields of a student submission. See google.classroom.v1.StudentSubmission for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-patch", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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)), + ]), + ("course-work-student-submissions-reclaim", + Some(r##"Reclaims a student submission on behalf of the student that owns it. Reclaiming a student submission transfers ownership of attached Drive files to the student and update the submission state. Only the student that ownes the requested student submission may call this method, and only for a student submission that has been turned in. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, unsubmit the requested student submission, or for access errors. * `FAILED_PRECONDITION` if the student submission has not been turned in. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-reclaim", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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)), + ]), + ("course-work-student-submissions-return", + Some(r##"Returns a student submission. Returning a student submission transfers ownership of attached Drive files to the student and may also update the submission state. Unlike the Classroom application, returning a student submission does not set assignedGrade to the draftGrade value. Only a teacher of the course that contains the requested student submission may call this method. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, return the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-return", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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)), + ]), + ("course-work-student-submissions-turn-in", + Some(r##"Turns in a student submission. Turning in a student submission transfers ownership of attached Drive files to the teacher and may also update the submission state. This may only be called by the student that owns the specified student submission. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, turn in the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/courses_course-work-student-submissions-turn-in", + vec![ + (Some(r##"course-id"##), + None, + Some(r##"Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias."##), + Some(true), + Some(false)), + + (Some(r##"course-work-id"##), + None, + Some(r##"Identifier of the course work."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Identifier of the student submission."##), + 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"##), @@ -2299,7 +3935,7 @@ fn main() { ]), ]), - ("user-profiles", "methods: 'get'", vec![ + ("user-profiles", "methods: 'get', 'guardian-invitations-create', 'guardian-invitations-get', 'guardian-invitations-list', 'guardian-invitations-patch', 'guardians-delete', 'guardians-get' and 'guardians-list'", vec![ ("get", Some(r##"Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile or if no profile exists with the requested ID or for access errors."##), "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_get", @@ -2316,6 +3952,196 @@ fn main() { 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)), + ]), + ("guardian-invitations-create", + Some(r##"Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardian-invitations-create", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"ID of the student (in standard format)"##), + 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)), + ]), + ("guardian-invitations-get", + Some(r##"Returns a specific guardian invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian invitations for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `invitation_id`. May also be returned if the student exists, but the requesting user does not have access to see that student."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardian-invitations-get", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"The ID of the student whose guardian invitation is being requested."##), + Some(true), + Some(false)), + + (Some(r##"invitation-id"##), + None, + Some(r##"The `id` field of the `GuardianInvitation` being requested."##), + 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)), + ]), + ("guardian-invitations-list", + Some(r##"Returns a list of guardian invitations that the requesting user is permitted to view, filtered by the parameters provided. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian invitations for that student, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` or `state` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardian-invitations-list", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"The ID of the student whose guardian invitations are to be returned. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user"##), + 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)), + ]), + ("guardian-invitations-patch", + Some(r##"Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardian-invitations-patch", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"The ID of the student whose guardian invitation is to be modified."##), + Some(true), + Some(false)), + + (Some(r##"invitation-id"##), + None, + Some(r##"The `id` field of the `GuardianInvitation` to be modified."##), + 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)), + ]), + ("guardians-delete", + Some(r##"Deletes a guardian. The guardian will no longer receive guardian notifications and the guardian will no longer be accessible via the API. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to manage guardians for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API). * `NOT_FOUND` if Classroom cannot find any record of the given `student_id` or `guardian_id`, or if the guardian has already been disabled."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardians-delete", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"The student whose guardian is to be deleted. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user"##), + Some(true), + Some(false)), + + (Some(r##"guardian-id"##), + None, + Some(r##"The `id` field from a `Guardian`."##), + 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)), + ]), + ("guardians-get", + Some(r##"Returns a specific guardian. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian information for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `guardian_id`, or if the guardian has been disabled."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardians-get", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"The student whose guardian is being requested. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user"##), + Some(true), + Some(false)), + + (Some(r##"guardian-id"##), + None, + Some(r##"The `id` field from a `Guardian`."##), + 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)), + ]), + ("guardians-list", + Some(r##"Returns a list of guardians that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian information for that student, if guardians are not enabled for the domain in question, if the `invited_email_address` filter is set by a user who is not a domain administrator, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student."##), + "Details at http://byron.github.io/google-apis-rs/google_classroom1_cli/user-profiles_guardians-list", + vec![ + (Some(r##"student-id"##), + None, + Some(r##"Filter results by the student who the guardian is linked to. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user"##), + 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"##), @@ -2328,8 +4154,8 @@ fn main() { let mut app = App::new("classroom1") .author("Sebastian Thiel ") - .version("0.3.6+20151013") - .about("Google Classroom API") + .version("0.3.6+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") .long("scope") diff --git a/gen/classroom1/Cargo.toml b/gen/classroom1/Cargo.toml index 8da34f1233..abeabe1199 100644 --- a/gen/classroom1/Cargo.toml +++ b/gen/classroom1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-classroom1" -version = "0.1.14+20151013" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/classroom1/README.md b/gen/classroom1/README.md index f17e21499d..f76a26c839 100644 --- a/gen/classroom1/README.md +++ b/gen/classroom1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-classroom1` library allows access to all features of the *Google classroom* service. -This documentation was generated from *classroom* crate version *0.1.14+20151013*, where *20151013* is the exact revision of the *classroom:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *classroom* crate version *0.1.14+20160816*, where *20160816* is the exact revision of the *classroom:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *classroom* *v1* API can be found at the [official documentation site](https://developers.google.com/classroom/). @@ -14,11 +14,11 @@ Everything else about the *classroom* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_classroom1/struct.Classroom.html) ... * [courses](http://byron.github.io/google-apis-rs/google_classroom1/struct.Course.html) - * [*aliases create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseCreateCall.html), [*aliases delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseDeleteCall.html), [*aliases list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseListCall.html), [*create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CoursePatchCall.html), [*students create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentCreateCall.html), [*students delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentDeleteCall.html), [*students get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentGetCall.html), [*students list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentListCall.html), [*teachers create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherCreateCall.html), [*teachers delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherDeleteCall.html), [*teachers get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherGetCall.html), [*teachers list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseUpdateCall.html) + * [*aliases create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseCreateCall.html), [*aliases delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseDeleteCall.html), [*aliases list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseAliaseListCall.html), [*course work create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkCreateCall.html), [*course work get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkGetCall.html), [*course work list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkListCall.html), [*course work student submissions get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionGetCall.html), [*course work student submissions list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionListCall.html), [*course work student submissions modify attachments*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionModifyAttachmentCall.html), [*course work student submissions patch*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionPatchCall.html), [*course work student submissions reclaim*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionReclaimCall.html), [*course work student submissions return*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionReturnCall.html), [*course work student submissions turn in*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCourseWorkStudentSubmissionTurnInCall.html), [*create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CoursePatchCall.html), [*students create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentCreateCall.html), [*students delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentDeleteCall.html), [*students get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentGetCall.html), [*students list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseStudentListCall.html), [*teachers create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherCreateCall.html), [*teachers delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherDeleteCall.html), [*teachers get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherGetCall.html), [*teachers list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseTeacherListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_classroom1/struct.CourseUpdateCall.html) * [invitations](http://byron.github.io/google-apis-rs/google_classroom1/struct.Invitation.html) * [*accept*](http://byron.github.io/google-apis-rs/google_classroom1/struct.InvitationAcceptCall.html), [*create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.InvitationCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.InvitationDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.InvitationGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.InvitationListCall.html) * [user profiles](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfile.html) - * [*get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGetCall.html) + * [*get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGetCall.html), [*guardian invitations create*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianInvitationCreateCall.html), [*guardian invitations get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianInvitationGetCall.html), [*guardian invitations list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianInvitationListCall.html), [*guardian invitations patch*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianInvitationPatchCall.html), [*guardians delete*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianDeleteCall.html), [*guardians get*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianGetCall.html) and [*guardians list*](http://byron.github.io/google-apis-rs/google_classroom1/struct.UserProfileGuardianListCall.html) @@ -51,23 +51,33 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.courses().update(...).doit() -let r = hub.courses().list(...).doit() -let r = hub.courses().teachers_list(...).doit() +let r = hub.courses().course_work_student_submissions_patch(...).doit() +let r = hub.courses().course_work_student_submissions_list(...).doit() let r = hub.courses().get(...).doit() +let r = hub.courses().update(...).doit() let r = hub.courses().students_delete(...).doit() -let r = hub.courses().patch(...).doit() -let r = hub.courses().aliases_create(...).doit() -let r = hub.courses().teachers_delete(...).doit() -let r = hub.courses().students_create(...).doit() -let r = hub.courses().students_get(...).doit() -let r = hub.courses().aliases_delete(...).doit() -let r = hub.courses().teachers_create(...).doit() let r = hub.courses().teachers_get(...).doit() +let r = hub.courses().course_work_list(...).doit() +let r = hub.courses().teachers_list(...).doit() +let r = hub.courses().course_work_student_submissions_turn_in(...).doit() +let r = hub.courses().course_work_student_submissions_modify_attachments(...).doit() +let r = hub.courses().course_work_student_submissions_return(...).doit() +let r = hub.courses().course_work_get(...).doit() +let r = hub.courses().course_work_create(...).doit() +let r = hub.courses().list(...).doit() +let r = hub.courses().course_work_student_submissions_reclaim(...).doit() +let r = hub.courses().aliases_create(...).doit() +let r = hub.courses().students_create(...).doit() +let r = hub.courses().aliases_delete(...).doit() let r = hub.courses().create(...).doit() let r = hub.courses().students_list(...).doit() -let r = hub.courses().aliases_list(...).doit() let r = hub.courses().delete(...).doit() +let r = hub.courses().patch(...).doit() +let r = hub.courses().aliases_list(...).doit() +let r = hub.courses().teachers_delete(...).doit() +let r = hub.courses().teachers_create(...).doit() +let r = hub.courses().course_work_student_submissions_get(...).doit() +let r = hub.courses().students_get(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -112,11 +122,12 @@ let mut hub = Classroom::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.courses().list() - .teacher_id("eirmod") - .student_id("sit") - .page_token("Stet") - .page_size(-42) +let result = hub.courses().course_work_student_submissions_list("courseId", "courseWorkId") + .user_id("Stet") + .add_states("sed") + .page_token("et") + .page_size(-18) + .late("kasd") .doit(); match result { diff --git a/gen/classroom1/src/lib.rs b/gen/classroom1/src/lib.rs index dcc1884bb3..e6b78e1183 100644 --- a/gen/classroom1/src/lib.rs +++ b/gen/classroom1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *classroom* crate version *0.1.14+20151013*, where *20151013* is the exact revision of the *classroom:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *classroom* crate version *0.1.14+20160816*, where *20160816* is the exact revision of the *classroom:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *classroom* *v1* API can be found at the //! [official documentation site](https://developers.google.com/classroom/). @@ -12,11 +12,11 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Classroom.html) ... //! //! * [courses](struct.Course.html) -//! * [*aliases create*](struct.CourseAliaseCreateCall.html), [*aliases delete*](struct.CourseAliaseDeleteCall.html), [*aliases list*](struct.CourseAliaseListCall.html), [*create*](struct.CourseCreateCall.html), [*delete*](struct.CourseDeleteCall.html), [*get*](struct.CourseGetCall.html), [*list*](struct.CourseListCall.html), [*patch*](struct.CoursePatchCall.html), [*students create*](struct.CourseStudentCreateCall.html), [*students delete*](struct.CourseStudentDeleteCall.html), [*students get*](struct.CourseStudentGetCall.html), [*students list*](struct.CourseStudentListCall.html), [*teachers create*](struct.CourseTeacherCreateCall.html), [*teachers delete*](struct.CourseTeacherDeleteCall.html), [*teachers get*](struct.CourseTeacherGetCall.html), [*teachers list*](struct.CourseTeacherListCall.html) and [*update*](struct.CourseUpdateCall.html) +//! * [*aliases create*](struct.CourseAliaseCreateCall.html), [*aliases delete*](struct.CourseAliaseDeleteCall.html), [*aliases list*](struct.CourseAliaseListCall.html), [*course work create*](struct.CourseCourseWorkCreateCall.html), [*course work get*](struct.CourseCourseWorkGetCall.html), [*course work list*](struct.CourseCourseWorkListCall.html), [*course work student submissions get*](struct.CourseCourseWorkStudentSubmissionGetCall.html), [*course work student submissions list*](struct.CourseCourseWorkStudentSubmissionListCall.html), [*course work student submissions modify attachments*](struct.CourseCourseWorkStudentSubmissionModifyAttachmentCall.html), [*course work student submissions patch*](struct.CourseCourseWorkStudentSubmissionPatchCall.html), [*course work student submissions reclaim*](struct.CourseCourseWorkStudentSubmissionReclaimCall.html), [*course work student submissions return*](struct.CourseCourseWorkStudentSubmissionReturnCall.html), [*course work student submissions turn in*](struct.CourseCourseWorkStudentSubmissionTurnInCall.html), [*create*](struct.CourseCreateCall.html), [*delete*](struct.CourseDeleteCall.html), [*get*](struct.CourseGetCall.html), [*list*](struct.CourseListCall.html), [*patch*](struct.CoursePatchCall.html), [*students create*](struct.CourseStudentCreateCall.html), [*students delete*](struct.CourseStudentDeleteCall.html), [*students get*](struct.CourseStudentGetCall.html), [*students list*](struct.CourseStudentListCall.html), [*teachers create*](struct.CourseTeacherCreateCall.html), [*teachers delete*](struct.CourseTeacherDeleteCall.html), [*teachers get*](struct.CourseTeacherGetCall.html), [*teachers list*](struct.CourseTeacherListCall.html) and [*update*](struct.CourseUpdateCall.html) //! * [invitations](struct.Invitation.html) //! * [*accept*](struct.InvitationAcceptCall.html), [*create*](struct.InvitationCreateCall.html), [*delete*](struct.InvitationDeleteCall.html), [*get*](struct.InvitationGetCall.html) and [*list*](struct.InvitationListCall.html) //! * [user profiles](struct.UserProfile.html) -//! * [*get*](struct.UserProfileGetCall.html) +//! * [*get*](struct.UserProfileGetCall.html), [*guardian invitations create*](struct.UserProfileGuardianInvitationCreateCall.html), [*guardian invitations get*](struct.UserProfileGuardianInvitationGetCall.html), [*guardian invitations list*](struct.UserProfileGuardianInvitationListCall.html), [*guardian invitations patch*](struct.UserProfileGuardianInvitationPatchCall.html), [*guardians delete*](struct.UserProfileGuardianDeleteCall.html), [*guardians get*](struct.UserProfileGuardianGetCall.html) and [*guardians list*](struct.UserProfileGuardianListCall.html) //! //! //! @@ -51,23 +51,33 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.courses().update(...).doit() -//! let r = hub.courses().list(...).doit() -//! let r = hub.courses().teachers_list(...).doit() +//! let r = hub.courses().course_work_student_submissions_patch(...).doit() +//! let r = hub.courses().course_work_student_submissions_list(...).doit() //! let r = hub.courses().get(...).doit() +//! let r = hub.courses().update(...).doit() //! let r = hub.courses().students_delete(...).doit() -//! let r = hub.courses().patch(...).doit() -//! let r = hub.courses().aliases_create(...).doit() -//! let r = hub.courses().teachers_delete(...).doit() -//! let r = hub.courses().students_create(...).doit() -//! let r = hub.courses().students_get(...).doit() -//! let r = hub.courses().aliases_delete(...).doit() -//! let r = hub.courses().teachers_create(...).doit() //! let r = hub.courses().teachers_get(...).doit() +//! let r = hub.courses().course_work_list(...).doit() +//! let r = hub.courses().teachers_list(...).doit() +//! let r = hub.courses().course_work_student_submissions_turn_in(...).doit() +//! let r = hub.courses().course_work_student_submissions_modify_attachments(...).doit() +//! let r = hub.courses().course_work_student_submissions_return(...).doit() +//! let r = hub.courses().course_work_get(...).doit() +//! let r = hub.courses().course_work_create(...).doit() +//! let r = hub.courses().list(...).doit() +//! let r = hub.courses().course_work_student_submissions_reclaim(...).doit() +//! let r = hub.courses().aliases_create(...).doit() +//! let r = hub.courses().students_create(...).doit() +//! let r = hub.courses().aliases_delete(...).doit() //! let r = hub.courses().create(...).doit() //! let r = hub.courses().students_list(...).doit() -//! let r = hub.courses().aliases_list(...).doit() //! let r = hub.courses().delete(...).doit() +//! let r = hub.courses().patch(...).doit() +//! let r = hub.courses().aliases_list(...).doit() +//! let r = hub.courses().teachers_delete(...).doit() +//! let r = hub.courses().teachers_create(...).doit() +//! let r = hub.courses().course_work_student_submissions_get(...).doit() +//! let r = hub.courses().students_get(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -113,11 +123,12 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.courses().list() -//! .teacher_id("sea") -//! .student_id("et") -//! .page_token("duo") -//! .page_size(-21) +//! let result = hub.courses().course_work_student_submissions_list("courseId", "courseWorkId") +//! .user_id("gubergren") +//! .add_states("aliquyam") +//! .page_token("eos") +//! .page_size(-38) +//! .late("sea") //! .doit(); //! //! match result { diff --git a/gen/classroom1/src/lib.rs.in b/gen/classroom1/src/lib.rs.in index ceaec1fed2..0a4ef9d992 100644 --- a/gen/classroom1/src/lib.rs.in +++ b/gen/classroom1/src/lib.rs.in @@ -45,14 +45,35 @@ pub enum Scope { /// Manage your Google Classroom classes Course, - /// Manage your Google Classroom class rosters - Roster, + /// View course work and grades for students in the Google Classroom classes you teach or administer + CourseworkStudentReadonly, + + /// View instructions for teacher-assigned work in your Google Classroom classes + CourseWorkReadonly, + + /// View your course work and grades in Google Classroom + StudentSubmissionMeReadonly, + + /// View the profile photos of people in your classes + ProfilePhoto, + + /// View your course work and grades in Google Classroom + CourseworkMeReadonly, + + /// Manage course work and grades for students in the Google Classroom classes you teach and view the course work and grades for classes you administer + CourseworkStudent, + + /// View course work and grades for students in the Google Classroom classes you teach or administer + StudentSubmissionStudentReadonly, /// View your Google Classroom classes CourseReadonly, - /// View the profile photos of people in your classes - ProfilePhoto, + /// Manage your Google Classroom class rosters + Roster, + + /// Manage your course work and view your grades in Google Classroom + CourseworkMe, } impl AsRef for Scope { @@ -61,9 +82,16 @@ impl AsRef for Scope { Scope::ProfileEmail => "https://www.googleapis.com/auth/classroom.profile.emails", Scope::RosterReadonly => "https://www.googleapis.com/auth/classroom.rosters.readonly", Scope::Course => "https://www.googleapis.com/auth/classroom.courses", - Scope::Roster => "https://www.googleapis.com/auth/classroom.rosters", - Scope::CourseReadonly => "https://www.googleapis.com/auth/classroom.courses.readonly", + Scope::CourseworkStudentReadonly => "https://www.googleapis.com/auth/classroom.coursework.students.readonly", + Scope::CourseWorkReadonly => "https://www.googleapis.com/auth/classroom.course-work.readonly", + Scope::StudentSubmissionMeReadonly => "https://www.googleapis.com/auth/classroom.student-submissions.me.readonly", Scope::ProfilePhoto => "https://www.googleapis.com/auth/classroom.profile.photos", + Scope::CourseworkMeReadonly => "https://www.googleapis.com/auth/classroom.coursework.me.readonly", + Scope::CourseworkStudent => "https://www.googleapis.com/auth/classroom.coursework.students", + Scope::StudentSubmissionStudentReadonly => "https://www.googleapis.com/auth/classroom.student-submissions.students.readonly", + Scope::CourseReadonly => "https://www.googleapis.com/auth/classroom.courses.readonly", + Scope::Roster => "https://www.googleapis.com/auth/classroom.rosters", + Scope::CourseworkMe => "https://www.googleapis.com/auth/classroom.coursework.me", } } } @@ -111,11 +139,12 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.courses().list() -/// .teacher_id("et") -/// .student_id("dolores") -/// .page_token("kasd") -/// .page_size(-22) +/// let result = hub.courses().course_work_student_submissions_list("courseId", "courseWorkId") +/// .user_id("justo") +/// .add_states("amet.") +/// .page_token("erat") +/// .page_size(-35) +/// .late("sea") /// .doit(); /// /// match result { @@ -180,78 +209,320 @@ impl<'a, C, A> Classroom // ############ // SCHEMAS ### // ########## -/// Response when listing course aliases. +/// Response when listing guardians. /// /// # 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*). /// -/// * [aliases list courses](struct.CourseAliaseListCall.html) (response) +/// * [guardians list user profiles](struct.UserProfileGuardianListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListCourseAliasesResponse { +pub struct ListGuardiansResponse { /// Token identifying the next page of results to return. If empty, no further results are available. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// The course aliases. - pub aliases: Option>, + /// Guardians on this page of results that met the criteria specified in the request. + pub guardians: Option>, } -impl ResponseResult for ListCourseAliasesResponse {} +impl ResponseResult for ListGuardiansResponse {} -/// Response when listing invitations. +/// Student work for a multiple-choice question. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MultipleChoiceSubmission { + /// Student's select choice. + pub answer: Option, +} + +impl Part for MultipleChoiceSubmission {} + + +/// Request to modify the attachments of a student submission. /// /// # 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 invitations](struct.InvitationListCall.html) (response) +/// * [course work student submissions modify attachments courses](struct.CourseCourseWorkStudentSubmissionModifyAttachmentCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListInvitationsResponse { - /// Token identifying the next page of results to return. If empty, no further results are available. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Invitations that match the list request. - pub invitations: Option>, +pub struct ModifyAttachmentsRequest { + /// Attachments to add. A student submission may not have more than 20 attachments. This may only contain link attachments. + #[serde(rename="addAttachments")] + pub add_attachments: Option>, } -impl ResponseResult for ListInvitationsResponse {} +impl RequestValue for ModifyAttachmentsRequest {} -/// An invitation to join a course. +/// Student work for a short answer question. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShortAnswerSubmission { + /// Student response to a short-answer question. + pub answer: Option, +} + +impl Part for ShortAnswerSubmission {} + + +/// Attachment added to student assignment work. When creating attachments, only the Link field may 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 Attachment { + /// Youtube video attachment. + #[serde(rename="youTubeVideo")] + pub you_tube_video: Option, + /// Google Drive file attachment. + #[serde(rename="driveFile")] + pub drive_file: Option, + /// Link attachment. + pub link: Option, + /// Google Forms attachment. + pub form: Option
, +} + +impl Part for Attachment {} + + +/// Student work for an assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AssignmentSubmission { + /// Attachments added by the student. Drive files that correspond to materials with a share mode of SUBMISSION_COPY may not exist yet if the student has not accessed the assignment in Classroom. Some attachment metadata is only populated if the requesting user has permission to access it. Identifier and alternate_link fields are available, but others (e.g. title) may not be. + pub attachments: Option>, +} + +impl Part for AssignmentSubmission {} + + +/// Request to return a student submission. /// /// # 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 invitations](struct.InvitationListCall.html) (none) -/// * [delete invitations](struct.InvitationDeleteCall.html) (none) -/// * [create invitations](struct.InvitationCreateCall.html) (request|response) -/// * [get invitations](struct.InvitationGetCall.html) (response) -/// * [accept invitations](struct.InvitationAcceptCall.html) (none) +/// * [course work student submissions return courses](struct.CourseCourseWorkStudentSubmissionReturnCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Invitation { - /// Identifier of the course to invite the user to. - #[serde(rename="courseId")] - pub course_id: Option, - /// Identifier of the invited user. When specified as a parameter of a request, this identifier can be set to one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user - #[serde(rename="userId")] - pub user_id: Option, - /// Role to invite the user to have. Must not be `COURSE_ROLE_UNSPECIFIED`. - pub role: Option, - /// Identifier assigned by Classroom. Read-only. +pub struct ReturnStudentSubmissionRequest; + +impl RequestValue for ReturnStudentSubmissionRequest {} + + +/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON 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*). +/// +/// * [delete invitations](struct.InvitationDeleteCall.html) (response) +/// * [course work student submissions turn in courses](struct.CourseCourseWorkStudentSubmissionTurnInCall.html) (response) +/// * [course work student submissions reclaim courses](struct.CourseCourseWorkStudentSubmissionReclaimCall.html) (response) +/// * [teachers delete courses](struct.CourseTeacherDeleteCall.html) (response) +/// * [guardians delete user profiles](struct.UserProfileGuardianDeleteCall.html) (response) +/// * [students delete courses](struct.CourseStudentDeleteCall.html) (response) +/// * [aliases delete courses](struct.CourseAliaseDeleteCall.html) (response) +/// * [course work student submissions return courses](struct.CourseCourseWorkStudentSubmissionReturnCall.html) (response) +/// * [delete courses](struct.CourseDeleteCall.html) (response) +/// * [accept invitations](struct.InvitationAcceptCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Empty; + +impl ResponseResult for Empty {} + + +/// Global information for a 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*). +/// +/// * [guardian invitations list user profiles](struct.UserProfileGuardianInvitationListCall.html) (none) +/// * [guardian invitations patch user profiles](struct.UserProfileGuardianInvitationPatchCall.html) (none) +/// * [get user profiles](struct.UserProfileGetCall.html) (response) +/// * [guardian invitations get user profiles](struct.UserProfileGuardianInvitationGetCall.html) (none) +/// * [guardians delete user profiles](struct.UserProfileGuardianDeleteCall.html) (none) +/// * [guardians get user profiles](struct.UserProfileGuardianGetCall.html) (none) +/// * [guardians list user profiles](struct.UserProfileGuardianListCall.html) (none) +/// * [guardian invitations create user profiles](struct.UserProfileGuardianInvitationCreateCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserProfile { + /// URL of user's profile photo. Read-only. + #[serde(rename="photoUrl")] + pub photo_url: Option, + /// Email address of the user. Read-only. + #[serde(rename="emailAddress")] + pub email_address: Option, + /// Identifier of the user. Read-only. pub id: Option, + /// Name of the user. Read-only. + pub name: Option, + /// Global permissions of the user. Read-only. + pub permissions: Option>, } -impl RequestValue for Invitation {} -impl Resource for Invitation {} -impl ResponseResult for Invitation {} +impl Resource for UserProfile {} +impl ResponseResult for UserProfile {} + + +/// A set of materials that appears on the "About" page of the course. These materials might include a syllabus, schedule, or other background information relating to the course as a whole. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CourseMaterialSet { + /// Materials attached to this set. + pub materials: Option>, + /// Title for this set. + pub title: Option, +} + +impl Part for CourseMaterialSet {} + + +/// Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may chose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TimeOfDay { + /// Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time. + pub hours: Option, + /// Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds. + pub seconds: Option, + /// Minutes of hour of day. Must be from 0 to 59. + pub minutes: Option, + /// Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. + pub nanos: Option, +} + +impl Part for TimeOfDay {} + + +/// Google Forms item. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Form { + /// URL of the form. + #[serde(rename="formUrl")] + pub form_url: Option, + /// URL of a thumbnail image of the Form. Read-only. + #[serde(rename="thumbnailUrl")] + pub thumbnail_url: Option, + /// URL of the form responses document. Only set if respsonses have been recorded and only when the requesting user is an editor of the form. Read-only. + #[serde(rename="responseUrl")] + pub response_url: Option, + /// Title of the Form. Read-only. + pub title: Option, +} + +impl Part for Form {} + + +/// Association between a student and a guardian of that student. The guardian may receive information about the student's course work. +/// +/// # 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*). +/// +/// * [guardians get user profiles](struct.UserProfileGuardianGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Guardian { + /// Identifier for the guardian. + #[serde(rename="guardianId")] + pub guardian_id: Option, + /// The email address to which the initial guardian invitation was sent. This field is only visible to domain administrators. + #[serde(rename="invitedEmailAddress")] + pub invited_email_address: Option, + /// Identifier for the student to whom the guardian relationship applies. + #[serde(rename="studentId")] + pub student_id: Option, + /// User profile for the guardian. + #[serde(rename="guardianProfile")] + pub guardian_profile: Option, +} + +impl ResponseResult for Guardian {} + + +/// Request to turn in a student submission. +/// +/// # 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*). +/// +/// * [course work student submissions turn in courses](struct.CourseCourseWorkStudentSubmissionTurnInCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TurnInStudentSubmissionRequest; + +impl RequestValue for TurnInStudentSubmissionRequest {} + + +/// Material attached to course work. When creating attachments, only the Link field may 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 Material { + /// YouTube video material. + #[serde(rename="youtubeVideo")] + pub youtube_video: Option, + /// Google Drive file material. + #[serde(rename="driveFile")] + pub drive_file: Option, + /// Link material. + pub link: Option, + /// Google Forms material. + pub form: Option, +} + +impl Part for Material {} + + +/// YouTube video item. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct YouTubeVideo { + /// Title of the YouTube video. Read-only. + pub title: Option, + /// URL of a thumbnail image of the YouTube video. Read-only. + #[serde(rename="thumbnailUrl")] + pub thumbnail_url: Option, + /// YouTube API resource ID. + pub id: Option, + /// URL that can be used to view the YouTube video. Read-only. + #[serde(rename="alternateLink")] + pub alternate_link: Option, +} + +impl Part for YouTubeVideo {} /// Response when listing teachers. @@ -275,88 +546,43 @@ pub struct ListTeachersResponse { impl ResponseResult for ListTeachersResponse {} -/// A Course in Classroom. +/// Representation of a Google Drive file. /// -/// # 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 courses](struct.CourseUpdateCall.html) (request|response) -/// * [list courses](struct.CourseListCall.html) (none) -/// * [teachers list courses](struct.CourseTeacherListCall.html) (none) -/// * [get courses](struct.CourseGetCall.html) (response) -/// * [students delete courses](struct.CourseStudentDeleteCall.html) (none) -/// * [patch courses](struct.CoursePatchCall.html) (request|response) -/// * [aliases create courses](struct.CourseAliaseCreateCall.html) (none) -/// * [teachers delete courses](struct.CourseTeacherDeleteCall.html) (none) -/// * [students create courses](struct.CourseStudentCreateCall.html) (none) -/// * [students get courses](struct.CourseStudentGetCall.html) (none) -/// * [aliases delete courses](struct.CourseAliaseDeleteCall.html) (none) -/// * [teachers create courses](struct.CourseTeacherCreateCall.html) (none) -/// * [teachers get courses](struct.CourseTeacherGetCall.html) (none) -/// * [create courses](struct.CourseCreateCall.html) (request|response) -/// * [students list courses](struct.CourseStudentListCall.html) (none) -/// * [aliases list courses](struct.CourseAliaseListCall.html) (none) -/// * [delete courses](struct.CourseDeleteCall.html) (none) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Course { - /// Time of the most recent update to this course. Specifying this field in a course update mask will result in an error. Read-only. - #[serde(rename="updateTime")] - pub update_time: Option, - /// Optional description. For example, "We'll be learning about the structure of living creatures from a combination of textbooks, guest lectures, and lab work. Expect to be excited!" If set, this field must be a valid UTF-8 string and no longer than 30,000 characters. - pub description: Option, - /// Absolute link to this course in the Classroom web UI. Read-only. +pub struct DriveFile { + /// Title of the Drive item. Read-only. + pub title: Option, + /// URL of a thumbnail image of the Drive item. Read-only. + #[serde(rename="thumbnailUrl")] + pub thumbnail_url: Option, + /// Drive API resource ID. + pub id: Option, + /// URL that can be used to access the Drive item. Read-only. #[serde(rename="alternateLink")] pub alternate_link: Option, - /// Enrollment code to use when joining this course. Specifying this field in a course update mask will result in an error. Read-only. - #[serde(rename="enrollmentCode")] - pub enrollment_code: Option, - /// Section of the course. For example, "Period 2". If set, this field must be a valid UTF-8 string and no longer than 2800 characters. - pub section: Option, - /// Creation time of the course. Specifying this field in a course update mask will result in an error. Read-only. - #[serde(rename="creationTime")] - pub creation_time: Option, - /// Optional room location. For example, "301". If set, this field must be a valid UTF-8 string and no longer than 650 characters. - pub room: Option, - /// The identifier of the owner of a course. When specified as a parameter of a create course request, this field is required. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user This must be set in a create request. Specifying this field in a course update mask will result in an `INVALID_ARGUMENT` error. - #[serde(rename="ownerId")] - pub owner_id: Option, - /// State of the course. If unspecified, the default state is `PROVISIONED`. - #[serde(rename="courseState")] - pub course_state: Option, - /// Identifier for this course assigned by Classroom. When creating a course, you may optionally set this identifier to an alias string in the request to create a corresponding alias. The `id` is still assigned by Classroom and cannot be updated after the course is created. Specifying this field in a course update mask will result in an error. - pub id: Option, - /// Optional heading for the description. For example, "Welcome to 10th Grade Biology." If set, this field must be a valid UTF-8 string and no longer than 3600 characters. - #[serde(rename="descriptionHeading")] - pub description_heading: Option, - /// Name of the course. For example, "10th Grade Biology". The name is required. It must be between 1 and 750 characters and a valid UTF-8 string. - pub name: Option, } -impl RequestValue for Course {} -impl Resource for Course {} -impl ResponseResult for Course {} +impl Part for DriveFile {} -/// Alternative identifier for a course. An alias uniquely identifies a course. It must be unique within one of the following scopes: * domain: A domain-scoped alias is visible to all users within the alias creator's domain and can be created only by a domain admin. A domain-scoped alias is often used when a course has an identifier external to Classroom. * project: A project-scoped alias is visible to any request from an application using the Developer Console project ID that created the alias and can be created by any project. A project-scoped alias is often used when an application has alternative identifiers. A random value can also be used to avoid duplicate courses in the event of transmission failures, as retrying a request will return `ALREADY_EXISTS` if a previous one has succeeded. +/// URL item. /// -/// # 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*). -/// -/// * [aliases create courses](struct.CourseAliaseCreateCall.html) (request|response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CourseAlias { - /// Alias string. The format of the string indicates the desired alias scoping. * `d:` indicates a domain-scoped alias. Example: `d:math_101` * `p:` indicates a project-scoped alias. Example: `p:abc123` This field has a maximum length of 256 characters. - pub alias: Option, +pub struct Link { + /// URL to link to. This must be a valid UTF-8 string containing between 1 and 2024 characters. + pub url: Option, + /// URL of a thumbnail image of the target URL. Read-only. + #[serde(rename="thumbnailUrl")] + pub thumbnail_url: Option, + /// Title of the target of the URL. Read-only. + pub title: Option, } -impl RequestValue for CourseAlias {} -impl ResponseResult for CourseAlias {} +impl Part for Link {} /// Student in a course. @@ -376,6 +602,9 @@ pub struct Student { pub course_id: Option, /// Global user information for the student. Read-only. pub profile: Option, + /// Information about a Drive Folder for this student's work in this course. Only visible to the student and domain administrators. Read-only. + #[serde(rename="studentWorkFolder")] + pub student_work_folder: Option, /// Identifier of the user. When specified as a parameter of a request, this identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user #[serde(rename="userId")] pub user_id: Option, @@ -385,67 +614,51 @@ impl RequestValue for Student {} impl ResponseResult for Student {} -/// Global user permission description. +/// Represents a whole calendar date, e.g. date of birth. The time of day and time zone are either specified elsewhere or are not significant. The date is relative to the Proleptic Gregorian Calendar. The day may be 0 to represent a year and month where the day is not significant, e.g. credit card expiration date. The year may be 0 to represent a month and day independent of year, e.g. anniversary date. Related types are google.type.TimeOfDay and `google.protobuf.Timestamp`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GlobalPermission { - /// Permission value. - pub permission: Option, +pub struct Date { + /// Year of date. Must be from 1 to 9999, or 0 if specifying a date without a year. + pub year: Option, + /// Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a year/month where the day is not significant. + pub day: Option, + /// Month of year. Must be from 1 to 12. + pub month: Option, } -impl Part for GlobalPermission {} +impl Part for Date {} -/// Response when listing students. +/// Drive file that is used as material for course work. /// -/// # 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*). -/// -/// * [students list courses](struct.CourseStudentListCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListStudentsResponse { - /// Students who match the list request. - pub students: Option>, - /// Token identifying the next page of results to return. If empty, no further results are available. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, +pub struct SharedDriveFile { + /// Drive file details. + #[serde(rename="driveFile")] + pub drive_file: Option, + /// Mechanism by which students access the Drive item. + #[serde(rename="shareMode")] + pub share_mode: Option, } -impl ResponseResult for ListStudentsResponse {} +impl Part for SharedDriveFile {} -/// Global information for a user. +/// Additional details for multiple-choice questions. /// -/// # 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 user profiles](struct.UserProfileGetCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UserProfile { - /// URL of user's profile photo. Read-only. - #[serde(rename="photoUrl")] - pub photo_url: Option, - /// Email address of the user. Read-only. - #[serde(rename="emailAddress")] - pub email_address: Option, - /// Identifier of the user. Read-only. - pub id: Option, - /// Name of the user. Read-only. - pub name: Option, - /// Global permissions of the user. Read-only. - pub permissions: Option>, +pub struct MultipleChoiceQuestion { + /// Possible choices. + pub choices: Option>, } -impl Resource for UserProfile {} -impl ResponseResult for UserProfile {} +impl Part for MultipleChoiceQuestion {} /// Response when listing courses. @@ -495,24 +708,25 @@ impl RequestValue for Teacher {} impl ResponseResult for Teacher {} -/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON object `{}`. +/// A material attached to a course as part of a material set. /// -/// # 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 invitations](struct.InvitationDeleteCall.html) (response) -/// * [teachers delete courses](struct.CourseTeacherDeleteCall.html) (response) -/// * [students delete courses](struct.CourseStudentDeleteCall.html) (response) -/// * [aliases delete courses](struct.CourseAliaseDeleteCall.html) (response) -/// * [delete courses](struct.CourseDeleteCall.html) (response) -/// * [accept invitations](struct.InvitationAcceptCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Empty; +pub struct CourseMaterial { + /// Youtube video attachment. + #[serde(rename="youTubeVideo")] + pub you_tube_video: Option, + /// Google Drive file attachment. + #[serde(rename="driveFile")] + pub drive_file: Option, + /// Link atatchment. + pub link: Option, + /// Google Forms attachment. + pub form: Option, +} -impl ResponseResult for Empty {} +impl Part for CourseMaterial {} /// Details of the user's name. @@ -535,6 +749,493 @@ pub struct Name { impl Part for Name {} +/// Response when listing invitations. +/// +/// # 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 invitations](struct.InvitationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListInvitationsResponse { + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Invitations that match the list request. + pub invitations: Option>, +} + +impl ResponseResult for ListInvitationsResponse {} + + +/// Representation of a Google Drive folder. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DriveFolder { + /// Title of the Drive folder. Read-only. + pub title: Option, + /// Drive API resource ID. + pub id: Option, + /// URL that can be used to access the Drive folder. Read-only. + #[serde(rename="alternateLink")] + pub alternate_link: Option, +} + +impl Part for DriveFolder {} + + +/// An invitation to join a course. +/// +/// # 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 invitations](struct.InvitationListCall.html) (none) +/// * [delete invitations](struct.InvitationDeleteCall.html) (none) +/// * [create invitations](struct.InvitationCreateCall.html) (request|response) +/// * [get invitations](struct.InvitationGetCall.html) (response) +/// * [accept invitations](struct.InvitationAcceptCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Invitation { + /// Identifier of the course to invite the user to. + #[serde(rename="courseId")] + pub course_id: Option, + /// Identifier of the invited user. When specified as a parameter of a request, this identifier can be set to one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + #[serde(rename="userId")] + pub user_id: Option, + /// Role to invite the user to have. Must not be `COURSE_ROLE_UNSPECIFIED`. + pub role: Option, + /// Identifier assigned by Classroom. Read-only. + pub id: Option, +} + +impl RequestValue for Invitation {} +impl Resource for Invitation {} +impl ResponseResult for Invitation {} + + +/// Response when listing students. +/// +/// # 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*). +/// +/// * [students list courses](struct.CourseStudentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListStudentsResponse { + /// Students who match the list request. + pub students: Option>, + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl ResponseResult for ListStudentsResponse {} + + +/// Response when listing student submissions. +/// +/// # 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*). +/// +/// * [course work student submissions list courses](struct.CourseCourseWorkStudentSubmissionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListStudentSubmissionsResponse { + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Student work that matches the request. + #[serde(rename="studentSubmissions")] + pub student_submissions: Option>, +} + +impl ResponseResult for ListStudentSubmissionsResponse {} + + +/// Response when listing course aliases. +/// +/// # 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*). +/// +/// * [aliases list courses](struct.CourseAliaseListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListCourseAliasesResponse { + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The course aliases. + pub aliases: Option>, +} + +impl ResponseResult for ListCourseAliasesResponse {} + + +/// Request to reclaim a student submission. +/// +/// # 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*). +/// +/// * [course work student submissions reclaim courses](struct.CourseCourseWorkStudentSubmissionReclaimCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReclaimStudentSubmissionRequest; + +impl RequestValue for ReclaimStudentSubmissionRequest {} + + +/// Course work created by a teacher for students of the course. +/// +/// # 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*). +/// +/// * [course work create courses](struct.CourseCourseWorkCreateCall.html) (request|response) +/// * [course work get courses](struct.CourseCourseWorkGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CourseWork { + /// Timestamp of the most recent change to this course work. Read-only. + #[serde(rename="updateTime")] + pub update_time: Option, + /// Optional description of this course work. If set, the description must be a valid UTF-8 string containing no more than 30,000 characters. + pub description: Option, + /// Identifier of the course. Read-only. + #[serde(rename="courseId")] + pub course_id: Option, + /// Assignment details. This is populated only when `work_type` is `ASSIGNMENT`. + pub assignment: Option, + /// Whether this course work item is associated with the Developer Console project making the request. See google.classroom.Work.CreateCourseWork for more details. Read-only. + #[serde(rename="associatedWithDeveloper")] + pub associated_with_developer: Option, + /// Maximum grade for this course work. If zero or unspecified, this assignment is considered ungraded. This must be a non-negative integer value. + #[serde(rename="maxPoints")] + pub max_points: Option, + /// Classroom-assigned identifier of this course work, unique per course. Read-only. + pub id: Option, + /// Type of this course work. The type is set when the course work is created and cannot be changed. When creating course work, this must be `ASSIGNMENT`. + #[serde(rename="workType")] + pub work_type: Option, + /// Setting to determine when students are allowed to modify submissions. If unspecified, the default value is `MODIFIABLE_UNTIL_TURNED_IN`. + #[serde(rename="submissionModificationMode")] + pub submission_modification_mode: Option, + /// Title of this course work. The title must be a valid UTF-8 string containing between 1 and 3000 characters. + pub title: Option, + /// Absolute link to this course work in the Classroom web UI. This is only populated if `state` is `PUBLISHED`. Read-only. + #[serde(rename="alternateLink")] + pub alternate_link: Option, + /// Timestamp when this course work was created. Read-only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// Optional date, in UTC, that submissions for this this course work are due. This must be specified if `due_time` is specified. + #[serde(rename="dueDate")] + pub due_date: Option, + /// Status of this course work. If unspecified, the default state is `DRAFT`. + pub state: Option, + /// Additional materials. CourseWork must have no more than 20 material items. + pub materials: Option>, + /// Optional time of day, in UTC, that submissions for this this course work are due. This must be specified if `due_date` is specified. + #[serde(rename="dueTime")] + pub due_time: Option, + /// Multiple choice question details. This is populated only when `work_type` is `MULTIPLE_CHOICE_QUESTION`. + #[serde(rename="multipleChoiceQuestion")] + pub multiple_choice_question: Option, +} + +impl RequestValue for CourseWork {} +impl ResponseResult for CourseWork {} + + +/// Student submission for course work. StudentSubmission items are generated when a CourseWork item is created. StudentSubmissions that have never been accessed (i.e. with `state` = NEW) may not have a creation time or update time. +/// +/// # 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*). +/// +/// * [course work student submissions patch courses](struct.CourseCourseWorkStudentSubmissionPatchCall.html) (request|response) +/// * [course work student submissions get courses](struct.CourseCourseWorkStudentSubmissionGetCall.html) (response) +/// * [course work student submissions modify attachments courses](struct.CourseCourseWorkStudentSubmissionModifyAttachmentCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct StudentSubmission { + /// Last update time of this submission. This may be unset if the student has not accessed this item. Read-only. + #[serde(rename="updateTime")] + pub update_time: Option, + /// Identifier of the course. Read-only. + #[serde(rename="courseId")] + pub course_id: Option, + /// Identifier for the student that owns this submission. Read-only. + #[serde(rename="userId")] + pub user_id: Option, + /// Whether this student submission is associated with the Developer Console project making the request. See google.classroom.Work.CreateCourseWork for more details. Read-only. + #[serde(rename="associatedWithDeveloper")] + pub associated_with_developer: Option, + /// Type of course work this submission is for. Read-only. + #[serde(rename="courseWorkType")] + pub course_work_type: Option, + /// Optional grade. If unset, no grade was set. This must be a non-negative integer value. This may be modified only by course teachers. + #[serde(rename="assignedGrade")] + pub assigned_grade: Option, + /// Classroom-assigned Identifier for the student submission. This is unique among submissions for the relevant course work. Read-only. + pub id: Option, + /// Optional pending grade. If unset, no grade was set. This must be a non-negative integer value. This is only visible to and modifiable by course teachers. + #[serde(rename="draftGrade")] + pub draft_grade: Option, + /// Absolute link to the submission in the Classroom web UI. Read-only. + #[serde(rename="alternateLink")] + pub alternate_link: Option, + /// Submission content when course_work_type is MULTIPLE_CHOICE_QUESTION. + #[serde(rename="multipleChoiceSubmission")] + pub multiple_choice_submission: Option, + /// Creation time of this submission. This may be unset if the student has not accessed this item. Read-only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// Submission content when course_work_type is SHORT_ANSWER_QUESTION. + #[serde(rename="shortAnswerSubmission")] + pub short_answer_submission: Option, + /// Whether this submission is late. Read-only. + pub late: Option, + /// State of this submission. Read-only. + pub state: Option, + /// Identifier for the course work this corresponds to. Read-only. + #[serde(rename="courseWorkId")] + pub course_work_id: Option, + /// Submission content when course_work_type is ASSIGNMENT . + #[serde(rename="assignmentSubmission")] + pub assignment_submission: Option, +} + +impl RequestValue for StudentSubmission {} +impl ResponseResult for StudentSubmission {} + + +/// Response when listing guardian invitations. +/// +/// # 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*). +/// +/// * [guardian invitations list user profiles](struct.UserProfileGuardianInvitationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListGuardianInvitationsResponse { + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Guardian invitations that matched the list request. + #[serde(rename="guardianInvitations")] + pub guardian_invitations: Option>, +} + +impl ResponseResult for ListGuardianInvitationsResponse {} + + +/// A Course in Classroom. +/// +/// # 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*). +/// +/// * [course work student submissions patch courses](struct.CourseCourseWorkStudentSubmissionPatchCall.html) (none) +/// * [course work student submissions list courses](struct.CourseCourseWorkStudentSubmissionListCall.html) (none) +/// * [get courses](struct.CourseGetCall.html) (response) +/// * [update courses](struct.CourseUpdateCall.html) (request|response) +/// * [students delete courses](struct.CourseStudentDeleteCall.html) (none) +/// * [teachers get courses](struct.CourseTeacherGetCall.html) (none) +/// * [course work list courses](struct.CourseCourseWorkListCall.html) (none) +/// * [teachers list courses](struct.CourseTeacherListCall.html) (none) +/// * [course work student submissions turn in courses](struct.CourseCourseWorkStudentSubmissionTurnInCall.html) (none) +/// * [course work student submissions modify attachments courses](struct.CourseCourseWorkStudentSubmissionModifyAttachmentCall.html) (none) +/// * [course work student submissions return courses](struct.CourseCourseWorkStudentSubmissionReturnCall.html) (none) +/// * [course work get courses](struct.CourseCourseWorkGetCall.html) (none) +/// * [course work create courses](struct.CourseCourseWorkCreateCall.html) (none) +/// * [list courses](struct.CourseListCall.html) (none) +/// * [course work student submissions reclaim courses](struct.CourseCourseWorkStudentSubmissionReclaimCall.html) (none) +/// * [aliases create courses](struct.CourseAliaseCreateCall.html) (none) +/// * [students create courses](struct.CourseStudentCreateCall.html) (none) +/// * [aliases delete courses](struct.CourseAliaseDeleteCall.html) (none) +/// * [create courses](struct.CourseCreateCall.html) (request|response) +/// * [students list courses](struct.CourseStudentListCall.html) (none) +/// * [delete courses](struct.CourseDeleteCall.html) (none) +/// * [patch courses](struct.CoursePatchCall.html) (request|response) +/// * [aliases list courses](struct.CourseAliaseListCall.html) (none) +/// * [teachers delete courses](struct.CourseTeacherDeleteCall.html) (none) +/// * [teachers create courses](struct.CourseTeacherCreateCall.html) (none) +/// * [course work student submissions get courses](struct.CourseCourseWorkStudentSubmissionGetCall.html) (none) +/// * [students get courses](struct.CourseStudentGetCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Course { + /// Time of the most recent update to this course. Specifying this field in a course update mask results in an error. Read-only. + #[serde(rename="updateTime")] + pub update_time: Option, + /// Optional description. For example, "We'll be learning about the structure of living creatures from a combination of textbooks, guest lectures, and lab work. Expect to be excited!" If set, this field must be a valid UTF-8 string and no longer than 30,000 characters. + pub description: Option, + /// Enrollment code to use when joining this course. Specifying this field in a course update mask results in an error. Read-only. + #[serde(rename="enrollmentCode")] + pub enrollment_code: Option, + /// The email address of a Google group containing all members of the course. This group does not accept email and can only be used for permissions. Read-only. + #[serde(rename="courseGroupEmail")] + pub course_group_email: Option, + /// Sets of materials that appear on the "about" page of this course. Read-only. + #[serde(rename="courseMaterialSets")] + pub course_material_sets: Option>, + /// State of the course. If unspecified, the default state is `PROVISIONED`. + #[serde(rename="courseState")] + pub course_state: Option, + /// Identifier for this course assigned by Classroom. When creating a course, you may optionally set this identifier to an alias string in the request to create a corresponding alias. The `id` is still assigned by Classroom and cannot be updated after the course is created. Specifying this field in a course update mask results in an error. + pub id: Option, + /// Optional room location. For example, "301". If set, this field must be a valid UTF-8 string and no longer than 650 characters. + pub room: Option, + /// Name of the course. For example, "10th Grade Biology". The name is required. It must be between 1 and 750 characters and a valid UTF-8 string. + pub name: Option, + /// Absolute link to this course in the Classroom web UI. Read-only. + #[serde(rename="alternateLink")] + pub alternate_link: Option, + /// Section of the course. For example, "Period 2". If set, this field must be a valid UTF-8 string and no longer than 2800 characters. + pub section: Option, + /// Creation time of the course. Specifying this field in a course update mask results in an error. Read-only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// The email address of a Google group containing all teachers of the course. This group does not accept email and can only be used for permissions. Read-only. + #[serde(rename="teacherGroupEmail")] + pub teacher_group_email: Option, + /// Information about a Drive Folder that is shared with all teachers of the course. This field will only be set for teachers of the course and domain administrators. Read-only. + #[serde(rename="teacherFolder")] + pub teacher_folder: Option, + /// The identifier of the owner of a course. When specified as a parameter of a create course request, this field is required. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user This must be set in a create request. Specifying this field in a course update mask results in an `INVALID_ARGUMENT` error. + #[serde(rename="ownerId")] + pub owner_id: Option, + /// Optional heading for the description. For example, "Welcome to 10th Grade Biology." If set, this field must be a valid UTF-8 string and no longer than 3600 characters. + #[serde(rename="descriptionHeading")] + pub description_heading: Option, +} + +impl RequestValue for Course {} +impl Resource for Course {} +impl ResponseResult for Course {} + + +/// Alternative identifier for a course. An alias uniquely identifies a course. It must be unique within one of the following scopes: * domain: A domain-scoped alias is visible to all users within the alias creator's domain and can be created only by a domain admin. A domain-scoped alias is often used when a course has an identifier external to Classroom. * project: A project-scoped alias is visible to any request from an application using the Developer Console project ID that created the alias and can be created by any project. A project-scoped alias is often used when an application has alternative identifiers. A random value can also be used to avoid duplicate courses in the event of transmission failures, as retrying a request will return `ALREADY_EXISTS` if a previous one has succeeded. +/// +/// # 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*). +/// +/// * [aliases create courses](struct.CourseAliaseCreateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CourseAlias { + /// Alias string. The format of the string indicates the desired alias scoping. * `d:` indicates a domain-scoped alias. Example: `d:math_101` * `p:` indicates a project-scoped alias. Example: `p:abc123` This field has a maximum length of 256 characters. + pub alias: Option, +} + +impl RequestValue for CourseAlias {} +impl ResponseResult for CourseAlias {} + + +/// Additional details for assignments. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Assignment { + /// Drive folder where attachments from student submissions are placed. This is only populated for course teachers. + #[serde(rename="studentWorkFolder")] + pub student_work_folder: Option, +} + +impl Part for Assignment {} + + +/// Global user permission 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 GlobalPermission { + /// Permission value. + pub permission: Option, +} + +impl Part for GlobalPermission {} + + +/// Response when listing course work. +/// +/// # 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*). +/// +/// * [course work list courses](struct.CourseCourseWorkListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListCourseWorkResponse { + /// Token identifying the next page of results to return. If empty, no further results are available. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Course work items that match the request. + #[serde(rename="courseWork")] + pub course_work: Option>, +} + +impl ResponseResult for ListCourseWorkResponse {} + + +/// An invitation to become the guardian of a specified user, sent to a specified email address. +/// +/// # 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*). +/// +/// * [guardian invitations create user profiles](struct.UserProfileGuardianInvitationCreateCall.html) (request|response) +/// * [guardian invitations patch user profiles](struct.UserProfileGuardianInvitationPatchCall.html) (request|response) +/// * [guardian invitations get user profiles](struct.UserProfileGuardianInvitationGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GuardianInvitation { + /// Unique identifier for this invitation. Read-only. + #[serde(rename="invitationId")] + pub invitation_id: Option, + /// ID of the student (in standard format) + #[serde(rename="studentId")] + pub student_id: Option, + /// The time that this invitation was created. Read-only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// Email address that the invitation was sent to. This field is only visible to domain administrators. + #[serde(rename="invitedEmailAddress")] + pub invited_email_address: Option, + /// The state that this invitation is in. + pub state: Option, +} + +impl RequestValue for GuardianInvitation {} +impl ResponseResult for GuardianInvitation {} + + // ################### // MethodBuilders ### @@ -563,7 +1264,7 @@ impl Part for Name {} /// ::default(), None); /// let mut hub = Classroom::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `aliases_create(...)`, `aliases_delete(...)`, `aliases_list(...)`, `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)`, `students_create(...)`, `students_delete(...)`, `students_get(...)`, `students_list(...)`, `teachers_create(...)`, `teachers_delete(...)`, `teachers_get(...)`, `teachers_list(...)` and `update(...)` +/// // like `aliases_create(...)`, `aliases_delete(...)`, `aliases_list(...)`, `course_work_create(...)`, `course_work_get(...)`, `course_work_list(...)`, `course_work_student_submissions_get(...)`, `course_work_student_submissions_list(...)`, `course_work_student_submissions_modify_attachments(...)`, `course_work_student_submissions_patch(...)`, `course_work_student_submissions_reclaim(...)`, `course_work_student_submissions_return(...)`, `course_work_student_submissions_turn_in(...)`, `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)`, `students_create(...)`, `students_delete(...)`, `students_get(...)`, `students_list(...)`, `teachers_create(...)`, `teachers_delete(...)`, `teachers_get(...)`, `teachers_list(...)` and `update(...)` /// // to build up your call. /// let rb = hub.courses(); /// # } @@ -580,17 +1281,46 @@ impl<'a, C, A> CourseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors. + /// Updates one or more fields of a student submission. See google.classroom.v1.StudentSubmission for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_patch(&self, request: StudentSubmission, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + CourseCourseWorkStudentSubmissionPatchCall { + hub: self.hub, + _request: request, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _id: id.to_string(), + _update_mask: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of student submissions that the requester is permitted to view, factoring in the OAuth scopes of the request. `-` may be specified as the `course_work_id` to include student submissions for multiple course work items. Course students may only view their own work. Course teachers and domain administrators may view all student submissions. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. /// /// # Arguments /// /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. - pub fn teachers_list(&self, course_id: &str) -> CourseTeacherListCall<'a, C, A> { - CourseTeacherListCall { + /// * `courseWorkId` - Identifer of the student work to request. This may be set to the string literal `"-"` to request student work for all course work in the specified course. + pub fn course_work_student_submissions_list(&self, course_id: &str, course_work_id: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { + CourseCourseWorkStudentSubmissionListCall { hub: self.hub, _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _user_id: Default::default(), + _states: Default::default(), _page_token: Default::default(), _page_size: Default::default(), + _late: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -614,6 +1344,25 @@ impl<'a, C, A> CourseMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `id` - Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias. + pub fn update(&self, request: Course, id: &str) -> CourseUpdateCall<'a, C, A> { + CourseUpdateCall { + hub: self.hub, + _request: request, + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. @@ -654,13 +1403,34 @@ impl<'a, C, A> CourseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist. + /// Returns a list of course work that the requester is permitted to view. Course students may only view `PUBLISHED` course work. Course teachers and domain administrators may view all course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. /// /// # Arguments /// - /// * `courseId` - The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. - pub fn aliases_list(&self, course_id: &str) -> CourseAliaseListCall<'a, C, A> { - CourseAliaseListCall { + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + pub fn course_work_list(&self, course_id: &str) -> CourseCourseWorkListCall<'a, C, A> { + CourseCourseWorkListCall { + hub: self.hub, + _course_id: course_id.to_string(), + _page_token: Default::default(), + _page_size: Default::default(), + _order_by: Default::default(), + _course_work_states: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors. + /// + /// # Arguments + /// + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + pub fn teachers_list(&self, course_id: &str) -> CourseTeacherListCall<'a, C, A> { + CourseTeacherListCall { hub: self.hub, _course_id: course_id.to_string(), _page_token: Default::default(), @@ -673,16 +1443,143 @@ impl<'a, C, A> CourseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable + /// Turns in a student submission. Turning in a student submission transfers ownership of attached Drive files to the teacher and may also update the submission state. This may only be called by the student that owns the specified student submission. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, turn in the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. /// /// # Arguments /// /// * `request` - No description provided. - /// * `id` - Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias. - pub fn update(&self, request: Course, id: &str) -> CourseUpdateCall<'a, C, A> { - CourseUpdateCall { + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_turn_in(&self, request: TurnInStudentSubmissionRequest, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { + CourseCourseWorkStudentSubmissionTurnInCall { hub: self.hub, _request: request, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Modifies attachments of student submission. Attachments may only be added to student submissions whose type is `ASSIGNMENT`. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, if the user is not permitted to modify attachments on the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_modify_attachments(&self, request: ModifyAttachmentsRequest, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + CourseCourseWorkStudentSubmissionModifyAttachmentCall { + hub: self.hub, + _request: request, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a student submission. Returning a student submission transfers ownership of attached Drive files to the student and may also update the submission state. Unlike the Classroom application, returning a student submission does not set assignedGrade to the draftGrade value. Only a teacher of the course that contains the requested student submission may call this method. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, return the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_return(&self, request: ReturnStudentSubmissionRequest, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + CourseCourseWorkStudentSubmissionReturnCall { + hub: self.hub, + _request: request, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. + /// + /// # Arguments + /// + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `id` - Identifier of the course work. + pub fn course_work_get(&self, course_id: &str, id: &str) -> CourseCourseWorkGetCall<'a, C, A> { + CourseCourseWorkGetCall { + hub: self.hub, + _course_id: course_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates course work. The resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + pub fn course_work_create(&self, request: CourseWork, course_id: &str) -> CourseCourseWorkCreateCall<'a, C, A> { + CourseCourseWorkCreateCall { + hub: self.hub, + _request: request, + _course_id: course_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist. + pub fn list(&self) -> CourseListCall<'a, C, A> { + CourseListCall { + hub: self.hub, + _teacher_id: Default::default(), + _student_id: Default::default(), + _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: + /// + /// Reclaims a student submission on behalf of the student that owns it. Reclaiming a student submission transfers ownership of attached Drive files to the student and update the submission state. Only the student that ownes the requested student submission may call this method, and only for a student submission that has been turned in. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, unsubmit the requested student submission, or for access errors. * `FAILED_PRECONDITION` if the student submission has not been turned in. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_reclaim(&self, request: ReclaimStudentSubmissionRequest, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + CourseCourseWorkStudentSubmissionReclaimCall { + hub: self.hub, + _request: request, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -709,22 +1606,6 @@ impl<'a, C, A> CourseMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist. - pub fn list(&self) -> CourseListCall<'a, C, A> { - CourseListCall { - hub: self.hub, - _teacher_id: Default::default(), - _student_id: Default::default(), - _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: /// /// Adds a user as a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if the user is already a student or teacher in the course. @@ -839,17 +1720,17 @@ impl<'a, C, A> CourseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. + /// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist. /// /// # Arguments /// - /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. - /// * `userId` - Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user - pub fn students_get(&self, course_id: &str, user_id: &str) -> CourseStudentGetCall<'a, C, A> { - CourseStudentGetCall { + /// * `courseId` - The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + pub fn aliases_list(&self, course_id: &str) -> CourseAliaseListCall<'a, C, A> { + CourseAliaseListCall { hub: self.hub, _course_id: course_id.to_string(), - _user_id: user_id.to_string(), + _page_token: Default::default(), + _page_size: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -893,6 +1774,46 @@ impl<'a, C, A> CourseMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Returns a student submission. * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, course work, or student submission or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. + /// + /// # Arguments + /// + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `courseWorkId` - Identifier of the course work. + /// * `id` - Identifier of the student submission. + pub fn course_work_student_submissions_get(&self, course_id: &str, course_work_id: &str, id: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> { + CourseCourseWorkStudentSubmissionGetCall { + hub: self.hub, + _course_id: course_id.to_string(), + _course_work_id: course_work_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. + /// + /// # Arguments + /// + /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// * `userId` - Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + pub fn students_get(&self, course_id: &str, user_id: &str) -> CourseStudentGetCall<'a, C, A> { + CourseStudentGetCall { + hub: self.hub, + _course_id: course_id.to_string(), + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -920,7 +1841,7 @@ impl<'a, C, A> CourseMethods<'a, C, A> { /// ::default(), None); /// let mut hub = Classroom::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` +/// // like `get(...)`, `guardian_invitations_create(...)`, `guardian_invitations_get(...)`, `guardian_invitations_list(...)`, `guardian_invitations_patch(...)`, `guardians_delete(...)`, `guardians_get(...)` and `guardians_list(...)` /// // to build up your call. /// let rb = hub.user_profiles(); /// # } @@ -935,6 +1856,42 @@ impl<'a, C, A> MethodsBuilder for UserProfileMethods<'a, C, A> {} impl<'a, C, A> UserProfileMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Returns a specific guardian. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian information for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `guardian_id`, or if the guardian has been disabled. + /// + /// # Arguments + /// + /// * `studentId` - The student whose guardian is being requested. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// * `guardianId` - The `id` field from a `Guardian`. + pub fn guardians_get(&self, student_id: &str, guardian_id: &str) -> UserProfileGuardianGetCall<'a, C, A> { + UserProfileGuardianGetCall { + hub: self.hub, + _student_id: student_id.to_string(), + _guardian_id: guardian_id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `studentId` - ID of the student (in standard format) + pub fn guardian_invitations_create(&self, request: GuardianInvitation, student_id: &str) -> UserProfileGuardianInvitationCreateCall<'a, C, A> { + UserProfileGuardianInvitationCreateCall { + hub: self.hub, + _request: request, + _student_id: student_id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile or if no profile exists with the requested ID or for access errors. @@ -951,6 +1908,102 @@ impl<'a, C, A> UserProfileMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `studentId` - The ID of the student whose guardian invitation is to be modified. + /// * `invitationId` - The `id` field of the `GuardianInvitation` to be modified. + pub fn guardian_invitations_patch(&self, request: GuardianInvitation, student_id: &str, invitation_id: &str) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + UserProfileGuardianInvitationPatchCall { + hub: self.hub, + _request: request, + _student_id: student_id.to_string(), + _invitation_id: invitation_id.to_string(), + _update_mask: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a specific guardian invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian invitations for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `invitation_id`. May also be returned if the student exists, but the requesting user does not have access to see that student. + /// + /// # Arguments + /// + /// * `studentId` - The ID of the student whose guardian invitation is being requested. + /// * `invitationId` - The `id` field of the `GuardianInvitation` being requested. + pub fn guardian_invitations_get(&self, student_id: &str, invitation_id: &str) -> UserProfileGuardianInvitationGetCall<'a, C, A> { + UserProfileGuardianInvitationGetCall { + hub: self.hub, + _student_id: student_id.to_string(), + _invitation_id: invitation_id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of guardians that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian information for that student, if guardians are not enabled for the domain in question, if the `invited_email_address` filter is set by a user who is not a domain administrator, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student. + /// + /// # Arguments + /// + /// * `studentId` - Filter results by the student who the guardian is linked to. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + pub fn guardians_list(&self, student_id: &str) -> UserProfileGuardianListCall<'a, C, A> { + UserProfileGuardianListCall { + hub: self.hub, + _student_id: student_id.to_string(), + _page_token: Default::default(), + _page_size: Default::default(), + _invited_email_address: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of guardian invitations that the requesting user is permitted to view, filtered by the parameters provided. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian invitations for that student, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` or `state` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student. + /// + /// # Arguments + /// + /// * `studentId` - The ID of the student whose guardian invitations are to be returned. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + pub fn guardian_invitations_list(&self, student_id: &str) -> UserProfileGuardianInvitationListCall<'a, C, A> { + UserProfileGuardianInvitationListCall { + hub: self.hub, + _student_id: student_id.to_string(), + _states: Default::default(), + _page_token: Default::default(), + _page_size: Default::default(), + _invited_email_address: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a guardian. The guardian will no longer receive guardian notifications and the guardian will no longer be accessible via the API. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to manage guardians for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API). * `NOT_FOUND` if Classroom cannot find any record of the given `student_id` or `guardian_id`, or if the guardian has already been disabled. + /// + /// # Arguments + /// + /// * `studentId` - The student whose guardian is to be deleted. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// * `guardianId` - The `id` field from a `Guardian`. + pub fn guardians_delete(&self, student_id: &str, guardian_id: &str) -> UserProfileGuardianDeleteCall<'a, C, A> { + UserProfileGuardianDeleteCall { + hub: self.hub, + _student_id: student_id.to_string(), + _guardian_id: guardian_id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } } @@ -1010,6 +2063,22 @@ impl<'a, C, A> InvitationMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. + pub fn list(&self) -> InvitationListCall<'a, C, A> { + InvitationListCall { + hub: self.hub, + _user_id: Default::default(), + _page_token: Default::default(), + _page_size: Default::default(), + _course_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 invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for access errors. * `NOT_FOUND` if the course or the user does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled or if the user already has this role or a role with greater permissions. * `ALREADY_EXISTS` if an invitation for the specified user and course already exists. @@ -1027,22 +2096,6 @@ impl<'a, C, A> InvitationMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. - pub fn list(&self) -> InvitationListCall<'a, C, A> { - InvitationListCall { - hub: self.hub, - _user_id: Default::default(), - _page_token: Default::default(), - _page_size: Default::default(), - _course_id: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Returns an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID. @@ -1086,9 +2139,317 @@ impl<'a, C, A> InvitationMethods<'a, C, A> { // CallBuilders ### // ################# -/// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors. +/// Updates one or more fields of a student submission. See google.classroom.v1.StudentSubmission for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. /// -/// A builder for the *teachers.list* method supported by a *course* resource. +/// A builder for the *courseWork.studentSubmissions.patch* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::StudentSubmission; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = StudentSubmission::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.courses().course_work_student_submissions_patch(req, "courseId", "courseWorkId", "id") +/// .update_mask("sadipscing") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: StudentSubmission, + _course_id: String, + _course_work_id: String, + _id: String, + _update_mask: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkStudentSubmissionPatchCall<'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, StudentSubmission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + params.push(("id", self._id.to_string())); + if let Some(value) = self._update_mask { + params.push(("updateMask", value.to_string())); + } + for &field in ["alt", "courseId", "courseWorkId", "id", "updateMask"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkMe.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].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 ["id", "courseWorkId", "courseId"].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: StudentSubmission) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// Mask that identifies which fields on the student submission to update. This field is required to do an update. The update fails if invalid fields are specified. The following fields may be specified by teachers: * `draft_grade` * `assigned_grade` + /// + /// Sets the *update mask* query property to the given value. + pub fn update_mask(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._update_mask = 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) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkStudentSubmissionPatchCall<'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::CourseworkMe`. + /// + /// 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) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a list of student submissions that the requester is permitted to view, factoring in the OAuth scopes of the request. `-` may be specified as the `course_work_id` to include student submissions for multiple course work items. Course students may only view their own work. Course teachers and domain administrators may view all student submissions. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. +/// +/// A builder for the *courseWork.studentSubmissions.list* method supported by a *course* resource. /// It is not used directly, but through a `CourseMethods` instance. /// /// # Example @@ -1112,31 +2473,38 @@ impl<'a, C, A> InvitationMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.courses().teachers_list("courseId") +/// let result = hub.courses().course_work_student_submissions_list("courseId", "courseWorkId") +/// .user_id("no") +/// .add_states("justo") /// .page_token("justo") -/// .page_size(-1) +/// .page_size(-34) +/// .late("et") /// .doit(); /// # } /// ``` -pub struct CourseTeacherListCall<'a, C, A> +pub struct CourseCourseWorkStudentSubmissionListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Classroom, _course_id: String, + _course_work_id: String, + _user_id: Option, + _states: Vec, _page_token: Option, _page_size: Option, + _late: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CourseTeacherListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionListCall<'a, C, A> {} -impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CourseCourseWorkStudentSubmissionListCall<'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, ListTeachersResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListStudentSubmissionsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1144,17 +2512,29 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "classroom.courses.teachers.list", + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + if let Some(value) = self._user_id { + params.push(("userId", value.to_string())); + } + if self._states.len() > 0 { + for f in self._states.iter() { + params.push(("states", f.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", "courseId", "pageToken", "pageSize"].iter() { + if let Some(value) = self._late { + params.push(("late", value.to_string())); + } + for &field in ["alt", "courseId", "courseWorkId", "userId", "states", "pageToken", "pageSize", "late"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1166,12 +2546,12 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/teachers".to_string(); + let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::RosterReadonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::CourseworkMeReadonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{courseId}", "courseId")].iter() { + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -1182,8 +2562,8 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut 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 ["courseId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["courseWorkId", "courseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -1275,31 +2655,63 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn course_id(mut self, new_value: &str) -> CourseTeacherListCall<'a, C, A> { + pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { self._course_id = new_value.to_string(); self } + /// Identifer of the student work to request. This may be set to the string literal `"-"` to request student work for all course work in the specified course. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Optional argument to restrict returned student work to those owned by the student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *user id* query property to the given value. + pub fn user_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { + self._user_id = Some(new_value.to_string()); + self + } + /// Requested submission states. If specified, returned student submissions match one of the specified submission states. + /// + /// Append the given value to the *states* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_states(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { + self._states.push(new_value.to_string()); + self + } /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> CourseTeacherListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } - /// Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results. + /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. /// /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> CourseTeacherListCall<'a, C, A> { + pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { self._page_size = Some(new_value); self } + /// Requested lateness value. If specified, returned student submissions are restricted by the requested value. If unspecified, submissions are returned regardless of `late` value. + /// + /// Sets the *late* query property to the given value. + pub fn late(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { + self._late = 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) -> CourseTeacherListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1326,7 +2738,7 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut /// * *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) -> CourseTeacherListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1335,7 +2747,7 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut /// 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::RosterReadonly`. + /// `Scope::CourseworkMeReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -1343,7 +2755,7 @@ impl<'a, C, A> CourseTeacherListCall<'a, C, A> where C: BorrowMut /// 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) -> CourseTeacherListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CourseCourseWorkStudentSubmissionListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -1592,6 +3004,278 @@ impl<'a, C, A> CourseGetCall<'a, C, A> where C: BorrowMut, A: oau } +/// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable +/// +/// A builder for the *update* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::Course; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = Course::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.courses().update(req, "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: Course, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseUpdateCall<'a, C, A> {} + +impl<'a, C, A> CourseUpdateCall<'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, Course)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Course.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{id}", "id")].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 ["id"].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: Course) -> CourseUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseUpdateCall<'a, C, A> { + self._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) -> CourseUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseUpdateCall<'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::Course`. + /// + /// 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) -> CourseUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Deletes a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. /// /// A builder for the *students.delete* method supported by a *course* resource. @@ -2098,9 +3782,9 @@ impl<'a, C, A> CourseTeacherGetCall<'a, C, A> where C: BorrowMut, } -/// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist. +/// Returns a list of course work that the requester is permitted to view. Course students may only view `PUBLISHED` course work. Course teachers and domain administrators may view all course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. /// -/// A builder for the *aliases.list* method supported by a *course* resource. +/// A builder for the *courseWork.list* method supported by a *course* resource. /// It is not used directly, but through a `CourseMethods` instance. /// /// # Example @@ -2124,31 +3808,35 @@ impl<'a, C, A> CourseTeacherGetCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.courses().aliases_list("courseId") -/// .page_token("sadipscing") -/// .page_size(-31) +/// let result = hub.courses().course_work_list("courseId") +/// .page_token("Lorem") +/// .page_size(-75) +/// .order_by("erat") +/// .add_course_work_states("sadipscing") /// .doit(); /// # } /// ``` -pub struct CourseAliaseListCall<'a, C, A> +pub struct CourseCourseWorkListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Classroom, _course_id: String, _page_token: Option, _page_size: Option, + _order_by: Option, + _course_work_states: Vec, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CourseAliaseListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CourseCourseWorkListCall<'a, C, A> {} -impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CourseCourseWorkListCall<'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, ListCourseAliasesResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListCourseWorkResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2156,9 +3844,9 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "classroom.courses.aliases.list", + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("courseId", self._course_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -2166,7 +3854,15 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } - for &field in ["alt", "courseId", "pageToken", "pageSize"].iter() { + if let Some(value) = self._order_by { + params.push(("orderBy", value.to_string())); + } + if self._course_work_states.len() > 0 { + for f in self._course_work_states.iter() { + params.push(("courseWorkStates", f.to_string())); + } + } + for &field in ["alt", "courseId", "pageToken", "pageSize", "orderBy", "courseWorkStates"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2178,9 +3874,9 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/aliases".to_string(); + let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/courseWork".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::CourseReadonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::CourseWorkReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{courseId}", "courseId")].iter() { @@ -2281,37 +3977,52 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, } - /// The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. /// /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseAliaseListCall<'a, C, A> { + pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C, A> { self._course_id = new_value.to_string(); self } /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> CourseAliaseListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. /// /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> CourseAliaseListCall<'a, C, A> { + pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkListCall<'a, C, A> { self._page_size = Some(new_value); self } + /// Optional sort ordering for results. A comma-separated list of fields with an optional sort direction keyword. Supported fields are `updateTime` and `dueDate`. Supported direction keywords are `asc` and `desc`. If not specified, `updateTime desc` is the default behavior. Examples: `dueDate asc,updateTime desc`, `updateTime,dueDate desc` + /// + /// Sets the *order by* query property to the given value. + pub fn order_by(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C, A> { + self._order_by = Some(new_value.to_string()); + self + } + /// Restriction on the work status to return. Only courseWork that matches is returned. If unspecified, items with a work status of `PUBLISHED` is returned. + /// + /// Append the given value to the *course work states* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_course_work_states(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C, A> { + self._course_work_states.push(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) -> CourseAliaseListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseCourseWorkListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -2338,7 +4049,7 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, /// * *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) -> CourseAliaseListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CourseCourseWorkListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -2347,7 +4058,7 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, /// 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::CourseReadonly`. + /// `Scope::CourseWorkReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -2355,7 +4066,7 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, /// 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) -> CourseAliaseListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CourseCourseWorkListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -2363,9 +4074,9 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, } -/// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable +/// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors. /// -/// A builder for the *update* method supported by a *course* resource. +/// A builder for the *teachers.list* method supported by a *course* resource. /// It is not used directly, but through a `CourseMethods` instance. /// /// # Example @@ -2376,7 +4087,272 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_classroom1 as classroom1; -/// use classroom1::Course; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.courses().teachers_list("courseId") +/// .page_token("eirmod") +/// .page_size(-43) +/// .doit(); +/// # } +/// ``` +pub struct CourseTeacherListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _course_id: String, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseTeacherListCall<'a, C, A> {} + +impl<'a, C, A> CourseTeacherListCall<'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, ListTeachersResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.teachers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("courseId", self._course_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", "courseId", "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://classroom.googleapis.com/v1/courses/{courseId}/teachers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::RosterReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId")].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 ["courseId"].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) + } + } + } + } + + + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseTeacherListCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CourseTeacherListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> CourseTeacherListCall<'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) -> CourseTeacherListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseTeacherListCall<'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::RosterReadonly`. + /// + /// 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) -> CourseTeacherListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Turns in a student submission. Turning in a student submission transfers ownership of attached Drive files to the teacher and may also update the submission state. This may only be called by the student that owns the specified student submission. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, turn in the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. +/// +/// A builder for the *courseWork.studentSubmissions.turnIn* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::TurnInStudentSubmissionRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -2390,33 +4366,35 @@ impl<'a, C, A> CourseAliaseListCall<'a, C, A> where C: BorrowMut, /// // 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 = Course::default(); +/// let mut req = TurnInStudentSubmissionRequest::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.courses().update(req, "id") +/// let result = hub.courses().course_work_student_submissions_turn_in(req, "courseId", "courseWorkId", "id") /// .doit(); /// # } /// ``` -pub struct CourseUpdateCall<'a, C, A> +pub struct CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Classroom, - _request: Course, + _request: TurnInStudentSubmissionRequest, + _course_id: String, + _course_work_id: String, _id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CourseUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> {} -impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CourseCourseWorkStudentSubmissionTurnInCall<'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, Course)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2424,11 +4402,13 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "classroom.courses.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.turnIn", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); params.push(("id", self._id.to_string())); - for &field in ["alt", "id"].iter() { + for &field in ["alt", "courseId", "courseWorkId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2440,12 +4420,12 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://classroom.googleapis.com/v1/courses/{id}".to_string(); + let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:turnIn".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Course.as_ref().to_string(), ()); + self._scopes.insert(Scope::CourseworkMe.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{id}", "id")].iter() { + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -2456,8 +4436,8 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: 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 ["id"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["id", "courseWorkId", "courseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -2502,7 +4482,7 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: 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) + 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())) @@ -2563,17 +4543,37 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// 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: Course) -> CourseUpdateCall<'a, C, A> { + pub fn request(mut self, new_value: TurnInStudentSubmissionRequest) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { self._request = new_value; self } - /// Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias. + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. /// /// Sets the *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 id(mut self, new_value: &str) -> CourseUpdateCall<'a, C, A> { + pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { self._id = new_value.to_string(); self } @@ -2583,7 +4583,7 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -2610,7 +4610,7 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: /// * *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) -> CourseUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -2619,7 +4619,7 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: /// 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::Course`. + /// `Scope::CourseworkMe`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -2627,7 +4627,1676 @@ impl<'a, C, A> CourseUpdateCall<'a, C, A> where C: BorrowMut, A: /// 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) -> CourseUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Modifies attachments of student submission. Attachments may only be added to student submissions whose type is `ASSIGNMENT`. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, if the user is not permitted to modify attachments on the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. +/// +/// A builder for the *courseWork.studentSubmissions.modifyAttachments* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::ModifyAttachmentsRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = ModifyAttachmentsRequest::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.courses().course_work_student_submissions_modify_attachments(req, "courseId", "courseWorkId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: ModifyAttachmentsRequest, + _course_id: String, + _course_work_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'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, StudentSubmission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.modifyAttachments", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "courseId", "courseWorkId", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:modifyAttachments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkMe.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].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 ["id", "courseWorkId", "courseId"].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: ModifyAttachmentsRequest) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + self._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) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'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::CourseworkMe`. + /// + /// 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) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a student submission. Returning a student submission transfers ownership of attached Drive files to the student and may also update the submission state. Unlike the Classroom application, returning a student submission does not set assignedGrade to the draftGrade value. Only a teacher of the course that contains the requested student submission may call this method. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, return the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. +/// +/// A builder for the *courseWork.studentSubmissions.return* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::ReturnStudentSubmissionRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = ReturnStudentSubmissionRequest::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.courses().course_work_student_submissions_return(req, "courseId", "courseWorkId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: ReturnStudentSubmissionRequest, + _course_id: String, + _course_work_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkStudentSubmissionReturnCall<'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, Empty)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.return", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "courseId", "courseWorkId", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:return".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkStudent.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].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 ["id", "courseWorkId", "courseId"].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: ReturnStudentSubmissionRequest) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + self._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) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkStudentSubmissionReturnCall<'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::CourseworkStudent`. + /// + /// 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) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. +/// +/// A builder for the *courseWork.get* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.courses().course_work_get("courseId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _course_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkGetCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkGetCall<'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, CourseWork)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "courseId", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseWorkReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].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 ["id", "courseId"].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) + } + } + } + } + + + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkGetCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkGetCall<'a, C, A> { + self._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) -> CourseCourseWorkGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkGetCall<'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::CourseWorkReadonly`. + /// + /// 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) -> CourseCourseWorkGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates course work. The resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. +/// +/// A builder for the *courseWork.create* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::CourseWork; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = CourseWork::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.courses().course_work_create(req, "courseId") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: CourseWork, + _course_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkCreateCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkCreateCall<'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, CourseWork)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + for &field in ["alt", "courseId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkStudent.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId")].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 ["courseId"].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: CourseWork) -> CourseCourseWorkCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkCreateCall<'a, C, A> { + self._course_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) -> CourseCourseWorkCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkCreateCall<'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::CourseworkStudent`. + /// + /// 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) -> CourseCourseWorkCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist. +/// +/// A builder for the *list* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.courses().list() +/// .teacher_id("et") +/// .student_id("eirmod") +/// .page_token("sanctus") +/// .page_size(-22) +/// .doit(); +/// # } +/// ``` +pub struct CourseListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _teacher_id: Option, + _student_id: Option, + _page_token: Option, + _page_size: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseListCall<'a, C, A> {} + +impl<'a, C, A> CourseListCall<'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, ListCoursesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + if let Some(value) = self._teacher_id { + params.push(("teacherId", value.to_string())); + } + if let Some(value) = self._student_id { + params.push(("studentId", value.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", "teacherId", "studentId", "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://classroom.googleapis.com/v1/courses".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseReadonly.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) + } + } + } + } + + + /// Restricts returned courses to those having a teacher with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *teacher id* query property to the given value. + pub fn teacher_id(mut self, new_value: &str) -> CourseListCall<'a, C, A> { + self._teacher_id = Some(new_value.to_string()); + self + } + /// Restricts returned courses to those having a student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *student id* query property to the given value. + pub fn student_id(mut self, new_value: &str) -> CourseListCall<'a, C, A> { + self._student_id = Some(new_value.to_string()); + self + } + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CourseListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> CourseListCall<'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) -> CourseListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseListCall<'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::CourseReadonly`. + /// + /// 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) -> CourseListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Reclaims a student submission on behalf of the student that owns it. Reclaiming a student submission transfers ownership of attached Drive files to the student and update the submission state. Only the student that ownes the requested student submission may call this method, and only for a student submission that has been turned in. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, unsubmit the requested student submission, or for access errors. * `FAILED_PRECONDITION` if the student submission has not been turned in. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist. +/// +/// A builder for the *courseWork.studentSubmissions.reclaim* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::ReclaimStudentSubmissionRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = ReclaimStudentSubmissionRequest::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.courses().course_work_student_submissions_reclaim(req, "courseId", "courseWorkId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: ReclaimStudentSubmissionRequest, + _course_id: String, + _course_work_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkStudentSubmissionReclaimCall<'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, Empty)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.reclaim", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "courseId", "courseWorkId", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:reclaim".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkMe.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].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 ["id", "courseWorkId", "courseId"].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: ReclaimStudentSubmissionRequest) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + self._request = new_value; + self + } + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + self._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) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkStudentSubmissionReclaimCall<'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::CourseworkMe`. + /// + /// 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) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -2907,262 +6576,6 @@ impl<'a, C, A> CourseAliaseCreateCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Classroom::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.courses().list() -/// .teacher_id("justo") -/// .student_id("justo") -/// .page_token("et") -/// .page_size(-17) -/// .doit(); -/// # } -/// ``` -pub struct CourseListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Classroom, - _teacher_id: Option, - _student_id: Option, - _page_token: Option, - _page_size: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for CourseListCall<'a, C, A> {} - -impl<'a, C, A> CourseListCall<'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, ListCoursesResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "classroom.courses.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - if let Some(value) = self._teacher_id { - params.push(("teacherId", value.to_string())); - } - if let Some(value) = self._student_id { - params.push(("studentId", value.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", "teacherId", "studentId", "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://classroom.googleapis.com/v1/courses".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CourseReadonly.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) - } - } - } - } - - - /// Restricts returned courses to those having a teacher with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user - /// - /// Sets the *teacher id* query property to the given value. - pub fn teacher_id(mut self, new_value: &str) -> CourseListCall<'a, C, A> { - self._teacher_id = Some(new_value.to_string()); - self - } - /// Restricts returned courses to those having a student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user - /// - /// Sets the *student id* query property to the given value. - pub fn student_id(mut self, new_value: &str) -> CourseListCall<'a, C, A> { - self._student_id = Some(new_value.to_string()); - self - } - /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> CourseListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> CourseListCall<'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) -> CourseListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> CourseListCall<'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::CourseReadonly`. - /// - /// 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) -> CourseListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Adds a user as a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if the user is already a student or teacher in the course. /// /// A builder for the *students.create* method supported by a *course* resource. @@ -3196,7 +6609,7 @@ impl<'a, C, A> CourseListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.courses().students_create(req, "courseId") -/// .enrollment_code("ipsum") +/// .enrollment_code("sed") /// .doit(); /// # } /// ``` @@ -3966,8 +7379,8 @@ impl<'a, C, A> CourseCreateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.courses().students_list("courseId") -/// .page_token("aliquyam") -/// .page_size(-9) +/// .page_token("et") +/// .page_size(-96) /// .doit(); /// # } /// ``` @@ -4478,7 +7891,7 @@ impl<'a, C, A> CourseDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.courses().patch(req, "id") -/// .update_mask("erat") +/// .update_mask("Lorem") /// .doit(); /// # } /// ``` @@ -4729,9 +8142,9 @@ impl<'a, C, A> CoursePatchCall<'a, C, A> where C: BorrowMut, A: o } -/// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. +/// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist. /// -/// A builder for the *students.get* method supported by a *course* resource. +/// A builder for the *aliases.list* method supported by a *course* resource. /// It is not used directly, but through a `CourseMethods` instance. /// /// # Example @@ -4755,28 +8168,31 @@ impl<'a, C, A> CoursePatchCall<'a, C, A> where C: BorrowMut, A: o /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.courses().students_get("courseId", "userId") +/// let result = hub.courses().aliases_list("courseId") +/// .page_token("justo") +/// .page_size(-52) /// .doit(); /// # } /// ``` -pub struct CourseStudentGetCall<'a, C, A> +pub struct CourseAliaseListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Classroom, _course_id: String, - _user_id: String, + _page_token: Option, + _page_size: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for CourseStudentGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for CourseAliaseListCall<'a, C, A> {} -impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> CourseAliaseListCall<'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, Student)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListCourseAliasesResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4784,12 +8200,17 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "classroom.courses.students.get", + dlg.begin(MethodInfo { id: "classroom.courses.aliases.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("courseId", self._course_id.to_string())); - params.push(("userId", self._user_id.to_string())); - for &field in ["alt", "courseId", "userId"].iter() { + 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", "courseId", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4801,12 +8222,12 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/students/{userId}".to_string(); + let mut url = "https://classroom.googleapis.com/v1/courses/{courseId}/aliases".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::RosterReadonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::CourseReadonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].iter() { + for &(find_this, param_name) in [("{courseId}", "courseId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -4817,8 +8238,8 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, 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 ["userId", "courseId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["courseId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -4904,24 +8325,28 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, } - /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. /// /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C, A> { + pub fn course_id(mut self, new_value: &str) -> CourseAliaseListCall<'a, C, A> { self._course_id = new_value.to_string(); self } - /// Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. /// - /// Sets the *user id* path property to the given value. + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CourseAliaseListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C, A> { - self._user_id = new_value.to_string(); + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> CourseAliaseListCall<'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 @@ -4930,7 +8355,7 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseStudentGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CourseAliaseListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4957,7 +8382,7 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, /// * *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) -> CourseStudentGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> CourseAliaseListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4966,7 +8391,7 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, /// 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::RosterReadonly`. + /// `Scope::CourseReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -4974,7 +8399,7 @@ impl<'a, C, A> CourseStudentGetCall<'a, C, A> where C: BorrowMut, /// 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) -> CourseStudentGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> CourseAliaseListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -5507,6 +8932,1005 @@ impl<'a, C, A> CourseTeacherCreateCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Classroom::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.courses().course_work_student_submissions_get("courseId", "courseWorkId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CourseCourseWorkStudentSubmissionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _course_id: String, + _course_work_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseCourseWorkStudentSubmissionGetCall<'a, C, A> {} + +impl<'a, C, A> CourseCourseWorkStudentSubmissionGetCall<'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, StudentSubmission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.courseWork.studentSubmissions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("courseWorkId", self._course_work_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "courseId", "courseWorkId", "id"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CourseworkMeReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{courseWorkId}", "courseWorkId"), ("{id}", "id")].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 ["id", "courseWorkId", "courseId"].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) + } + } + } + } + + + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the course work. + /// + /// Sets the *course work 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 course_work_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> { + self._course_work_id = new_value.to_string(); + self + } + /// Identifier of the student submission. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> { + self._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) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseCourseWorkStudentSubmissionGetCall<'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::CourseworkMeReadonly`. + /// + /// 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) -> CourseCourseWorkStudentSubmissionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist. +/// +/// A builder for the *students.get* method supported by a *course* resource. +/// It is not used directly, but through a `CourseMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.courses().students_get("courseId", "userId") +/// .doit(); +/// # } +/// ``` +pub struct CourseStudentGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _course_id: String, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CourseStudentGetCall<'a, C, A> {} + +impl<'a, C, A> CourseStudentGetCall<'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, Student)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.courses.students.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("courseId", self._course_id.to_string())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "courseId", "userId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/courses/{courseId}/students/{userId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::RosterReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].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 ["userId", "courseId"].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) + } + } + } + } + + + /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias. + /// + /// Sets the *course 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 course_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C, A> { + self._course_id = new_value.to_string(); + self + } + /// Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C, A> { + self._user_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) -> CourseStudentGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CourseStudentGetCall<'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::RosterReadonly`. + /// + /// 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) -> CourseStudentGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a specific guardian. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian information for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `guardian_id`, or if the guardian has been disabled. +/// +/// A builder for the *guardians.get* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.user_profiles().guardians_get("studentId", "guardianId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _student_id: String, + _guardian_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianGetCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianGetCall<'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, Guardian)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardians.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + params.push(("guardianId", self._guardian_id.to_string())); + for &field in ["alt", "studentId", "guardianId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardians/{guardianId}".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId"), ("{guardianId}", "guardianId")].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 ["guardianId", "studentId"].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 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 student whose guardian is being requested. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianGetCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// The `id` field from a `Guardian`. + /// + /// Sets the *guardian 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 guardian_id(mut self, new_value: &str) -> UserProfileGuardianGetCall<'a, C, A> { + self._guardian_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) -> UserProfileGuardianGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianGetCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user. +/// +/// A builder for the *guardianInvitations.create* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::GuardianInvitation; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = GuardianInvitation::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.user_profiles().guardian_invitations_create(req, "studentId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianInvitationCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: GuardianInvitation, + _student_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianInvitationCreateCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianInvitationCreateCall<'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, GuardianInvitation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardianInvitations.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + for &field in ["alt", "studentId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardianInvitations".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId")].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 ["studentId"].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 { + 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(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: GuardianInvitation) -> UserProfileGuardianInvitationCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// ID of the student (in standard format) + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationCreateCall<'a, C, A> { + self._student_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) -> UserProfileGuardianInvitationCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianInvitationCreateCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + /// Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile or if no profile exists with the requested ID or for access errors. /// /// A builder for the *get* method supported by a *userProfile* resource. @@ -5748,6 +10172,1267 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut, A } +/// Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom. +/// +/// A builder for the *guardianInvitations.patch* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// use classroom1::GuardianInvitation; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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 = GuardianInvitation::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.user_profiles().guardian_invitations_patch(req, "studentId", "invitationId") +/// .update_mask("clita") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianInvitationPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _request: GuardianInvitation, + _student_id: String, + _invitation_id: String, + _update_mask: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianInvitationPatchCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianInvitationPatchCall<'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, GuardianInvitation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardianInvitations.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + params.push(("invitationId", self._invitation_id.to_string())); + if let Some(value) = self._update_mask { + params.push(("updateMask", value.to_string())); + } + for &field in ["alt", "studentId", "invitationId", "updateMask"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardianInvitations/{invitationId}".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId"), ("{invitationId}", "invitationId")].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 ["invitationId", "studentId"].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 { + 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(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: GuardianInvitation) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the student whose guardian invitation is to be modified. + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// The `id` field of the `GuardianInvitation` to be modified. + /// + /// Sets the *invitation 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 invitation_id(mut self, new_value: &str) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + self._invitation_id = new_value.to_string(); + self + } + /// Mask that identifies which fields on the course to update. This field is required to do an update. The update will fail if invalid fields are specified. The following fields are valid: * `state` When set in a query parameter, this field should be specified as `updateMask=,,...` + /// + /// Sets the *update mask* query property to the given value. + pub fn update_mask(mut self, new_value: &str) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + self._update_mask = 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) -> UserProfileGuardianInvitationPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianInvitationPatchCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Returns a specific guardian invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian invitations for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `invitation_id`. May also be returned if the student exists, but the requesting user does not have access to see that student. +/// +/// A builder for the *guardianInvitations.get* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.user_profiles().guardian_invitations_get("studentId", "invitationId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianInvitationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _student_id: String, + _invitation_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianInvitationGetCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianInvitationGetCall<'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, GuardianInvitation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardianInvitations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + params.push(("invitationId", self._invitation_id.to_string())); + for &field in ["alt", "studentId", "invitationId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardianInvitations/{invitationId}".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId"), ("{invitationId}", "invitationId")].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 ["invitationId", "studentId"].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 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 ID of the student whose guardian invitation is being requested. + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationGetCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// The `id` field of the `GuardianInvitation` being requested. + /// + /// Sets the *invitation 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 invitation_id(mut self, new_value: &str) -> UserProfileGuardianInvitationGetCall<'a, C, A> { + self._invitation_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) -> UserProfileGuardianInvitationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianInvitationGetCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Returns a list of guardians that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian information for that student, if guardians are not enabled for the domain in question, if the `invited_email_address` filter is set by a user who is not a domain administrator, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student. +/// +/// A builder for the *guardians.list* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.user_profiles().guardians_list("studentId") +/// .page_token("kasd") +/// .page_size(-7) +/// .invited_email_address("takimata") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _student_id: String, + _page_token: Option, + _page_size: Option, + _invited_email_address: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianListCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianListCall<'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, ListGuardiansResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardians.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("studentId", self._student_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._invited_email_address { + params.push(("invitedEmailAddress", value.to_string())); + } + for &field in ["alt", "studentId", "pageToken", "pageSize", "invitedEmailAddress"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardians".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId")].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 ["studentId"].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 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) + } + } + } + } + + + /// Filter results by the student who the guardian is linked to. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> UserProfileGuardianListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// Filter results by the email address that the original invitation was sent to, resulting in this guardian link. This filter can only be used by domain administrators. + /// + /// Sets the *invited email address* query property to the given value. + pub fn invited_email_address(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C, A> { + self._invited_email_address = 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) -> UserProfileGuardianListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianListCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Returns a list of guardian invitations that the requesting user is permitted to view, filtered by the parameters provided. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian invitations for that student, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` or `state` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student. +/// +/// A builder for the *guardianInvitations.list* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.user_profiles().guardian_invitations_list("studentId") +/// .add_states("labore") +/// .page_token("invidunt") +/// .page_size(-66) +/// .invited_email_address("sadipscing") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianInvitationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _student_id: String, + _states: Vec, + _page_token: Option, + _page_size: Option, + _invited_email_address: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianInvitationListCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianInvitationListCall<'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, ListGuardianInvitationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardianInvitations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + if self._states.len() > 0 { + for f in self._states.iter() { + params.push(("states", f.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._invited_email_address { + params.push(("invitedEmailAddress", value.to_string())); + } + for &field in ["alt", "studentId", "states", "pageToken", "pageSize", "invitedEmailAddress"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardianInvitations".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId")].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 ["studentId"].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 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 ID of the student whose guardian invitations are to be returned. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// If specified, only results with the specified `state` values will be returned. Otherwise, results with a `state` of `PENDING` will be returned. + /// + /// Append the given value to the *states* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_states(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._states.push(new_value.to_string()); + self + } + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// If specified, only results with the specified `invited_email_address` will be returned. + /// + /// Sets the *invited email address* query property to the given value. + pub fn invited_email_address(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._invited_email_address = 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) -> UserProfileGuardianInvitationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianInvitationListCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Deletes a guardian. The guardian will no longer receive guardian notifications and the guardian will no longer be accessible via the API. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to manage guardians for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API). * `NOT_FOUND` if Classroom cannot find any record of the given `student_id` or `guardian_id`, or if the guardian has already been disabled. +/// +/// A builder for the *guardians.delete* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.user_profiles().guardians_delete("studentId", "guardianId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGuardianDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _student_id: String, + _guardian_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for UserProfileGuardianDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGuardianDeleteCall<'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, Empty)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.userProfiles.guardians.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("studentId", self._student_id.to_string())); + params.push(("guardianId", self._guardian_id.to_string())); + for &field in ["alt", "studentId", "guardianId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/userProfiles/{studentId}/guardians/{guardianId}".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) + } + } + + for &(find_this, param_name) in [("{studentId}", "studentId"), ("{guardianId}", "guardianId")].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 ["guardianId", "studentId"].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 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())); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, + json::from_str(&json_err).ok(), + json::from_str(&json_err).ok()) { + sleep(d); + continue; + } + 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 student whose guardian is to be deleted. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *student 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 student_id(mut self, new_value: &str) -> UserProfileGuardianDeleteCall<'a, C, A> { + self._student_id = new_value.to_string(); + self + } + /// The `id` field from a `Guardian`. + /// + /// Sets the *guardian 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 guardian_id(mut self, new_value: &str) -> UserProfileGuardianDeleteCall<'a, C, A> { + self._guardian_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) -> UserProfileGuardianDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGuardianDeleteCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + /// Deletes an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID. /// /// A builder for the *delete* method supported by a *invitation* resource. @@ -5989,6 +11674,262 @@ impl<'a, C, A> InvitationDeleteCall<'a, C, A> where C: BorrowMut, } +/// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. +/// +/// A builder for the *list* method supported by a *invitation* resource. +/// It is not used directly, but through a `InvitationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_classroom1 as classroom1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use classroom1::Classroom; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Classroom::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.invitations().list() +/// .user_id("sed") +/// .page_token("aliquyam") +/// .page_size(-53) +/// .course_id("eirmod") +/// .doit(); +/// # } +/// ``` +pub struct InvitationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Classroom, + _user_id: Option, + _page_token: Option, + _page_size: Option, + _course_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InvitationListCall<'a, C, A> {} + +impl<'a, C, A> InvitationListCall<'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, ListInvitationsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "classroom.invitations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + if let Some(value) = self._user_id { + params.push(("userId", value.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._course_id { + params.push(("courseId", value.to_string())); + } + for &field in ["alt", "userId", "pageToken", "pageSize", "courseId"].iter() { + if self._additional_params.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://classroom.googleapis.com/v1/invitations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::RosterReadonly.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) + } + } + } + } + + + /// Restricts returned invitations to those for a specific user. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user + /// + /// Sets the *user id* query property to the given value. + pub fn user_id(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { + self._user_id = Some(new_value.to_string()); + self + } + /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> InvitationListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// Restricts returned invitations to those for a course with the specified identifier. + /// + /// Sets the *course id* query property to the given value. + pub fn course_id(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { + self._course_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) -> InvitationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InvitationListCall<'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::RosterReadonly`. + /// + /// 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) -> InvitationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Creates an invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for access errors. * `NOT_FOUND` if the course or the user does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled or if the user already has this role or a role with greater permissions. * `ALREADY_EXISTS` if an invitation for the specified user and course already exists. /// /// A builder for the *create* method supported by a *invitation* resource. @@ -6228,262 +12169,6 @@ impl<'a, C, A> InvitationCreateCall<'a, C, A> where C: BorrowMut, } -/// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. -/// -/// A builder for the *list* method supported by a *invitation* resource. -/// It is not used directly, but through a `InvitationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_classroom1 as classroom1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use classroom1::Classroom; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Classroom::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.invitations().list() -/// .user_id("eirmod") -/// .page_token("dolore") -/// .page_size(-37) -/// .course_id("aliquyam") -/// .doit(); -/// # } -/// ``` -pub struct InvitationListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Classroom, - _user_id: Option, - _page_token: Option, - _page_size: Option, - _course_id: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InvitationListCall<'a, C, A> {} - -impl<'a, C, A> InvitationListCall<'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, ListInvitationsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "classroom.invitations.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - if let Some(value) = self._user_id { - params.push(("userId", value.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._course_id { - params.push(("courseId", value.to_string())); - } - for &field in ["alt", "userId", "pageToken", "pageSize", "courseId"].iter() { - if self._additional_params.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://classroom.googleapis.com/v1/invitations".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::RosterReadonly.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) - } - } - } - } - - - /// Restricts returned invitations to those for a specific user. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user - /// - /// Sets the *user id* query property to the given value. - pub fn user_id(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { - self._user_id = Some(new_value.to_string()); - self - } - /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> InvitationListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// Restricts returned invitations to those for a course with the specified identifier. - /// - /// Sets the *course id* query property to the given value. - pub fn course_id(mut self, new_value: &str) -> InvitationListCall<'a, C, A> { - self._course_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) -> InvitationListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> InvitationListCall<'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::RosterReadonly`. - /// - /// 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) -> InvitationListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Returns an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID. /// /// A builder for the *get* method supported by a *invitation* resource. diff --git a/gen/cloudbilling1-cli/Cargo.toml b/gen/cloudbilling1-cli/Cargo.toml index 22d2393edb..db6ec7cdd9 100644 --- a/gen/cloudbilling1-cli/Cargo.toml +++ b/gen/cloudbilling1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "cloudbilling1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudbilling1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudbilling1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudbilling1] diff --git a/gen/cloudbilling1/Cargo.toml b/gen/cloudbilling1/Cargo.toml index cdd588a674..4a1ed81dac 100644 --- a/gen/cloudbilling1/Cargo.toml +++ b/gen/cloudbilling1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/clouddebugger2-cli/Cargo.toml b/gen/clouddebugger2-cli/Cargo.toml index 87c37c7505..d34ad11729 100644 --- a/gen/clouddebugger2-cli/Cargo.toml +++ b/gen/clouddebugger2-cli/Cargo.toml @@ -4,11 +4,11 @@ [package] name = "google-clouddebugger2-cli" -version = "0.3.6+20160309" +version = "0.3.6+20160810" authors = ["Sebastian Thiel "] -description = "A complete library to interact with clouddebugger (protocol v2)" +description = "A complete library to interact with Cloud Debugger (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/clouddebugger2-cli" -homepage = "https://cloud.google.com/tools/cloud-debugger" +homepage = "http://cloud.google.com/debugger" documentation = "http://byron.github.io/google-apis-rs/google_clouddebugger2_cli" license = "MIT" keywords = ["clouddebugger", "google", "cli"] @@ -19,10 +19,10 @@ name = "clouddebugger2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-clouddebugger2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-clouddebugger2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-clouddebugger2] diff --git a/gen/clouddebugger2-cli/README.md b/gen/clouddebugger2-cli/README.md index d3416143d1..4d0cc3f79a 100644 --- a/gen/clouddebugger2-cli/README.md +++ b/gen/clouddebugger2-cli/README.md @@ -3,15 +3,15 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/cli/README.md.mako' DO NOT EDIT ! --> -The `clouddebugger2` command-line interface *(CLI)* allows to use most features of the *Google clouddebugger* service from the comfort of your terminal. +The `clouddebugger2` command-line interface *(CLI)* allows to use most features of the *Google Cloud Debugger* 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 *clouddebugger* API can be found at the -[official documentation site](https://cloud.google.com/tools/cloud-debugger). +Everything else about the *Cloud Debugger* API can be found at the +[official documentation site](http://cloud.google.com/debugger). # Downloads @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *clouddebugger* API at revision *20160309*. 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 *0.3.6*. ```bash clouddebugger2 [options] diff --git a/gen/clouddebugger2-cli/mkdocs.yml b/gen/clouddebugger2-cli/mkdocs.yml index 86b532e565..e9d0e1f6fd 100644 --- a/gen/clouddebugger2-cli/mkdocs.yml +++ b/gen/clouddebugger2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: clouddebugger v0.3.6+20160309 +site_name: Cloud Debugger v0.3.6+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 a4244d41b2..def8ac7e2f 100644 --- a/gen/clouddebugger2-cli/src/main.rs +++ b/gen/clouddebugger2-cli/src/main.rs @@ -38,7 +38,7 @@ enum DoitError { struct Engine<'n> { opt: ArgMatches<'n>, - hub: api::Clouddebugger>, + hub: api::CloudDebugger>, gp: Vec<&'static str>, gpm: Vec<(&'static str, &'static str)>, } @@ -750,7 +750,7 @@ impl<'n> Engine<'n> { }; let engine = Engine { opt: opt, - hub: api::Clouddebugger::new(client, auth), + hub: api::CloudDebugger::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"), @@ -992,7 +992,7 @@ fn main() { let mut app = App::new("clouddebugger2") .author("Sebastian Thiel ") - .version("0.3.6+20160309") + .version("0.3.6+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/clouddebugger2/Cargo.toml b/gen/clouddebugger2/Cargo.toml index 2bd9fa0370..05140a1bc9 100644 --- a/gen/clouddebugger2/Cargo.toml +++ b/gen/clouddebugger2/Cargo.toml @@ -4,11 +4,11 @@ [package] name = "google-clouddebugger2" -version = "0.1.14+20160309" +version = "0.1.14+20160810" authors = ["Sebastian Thiel "] -description = "A complete library to interact with clouddebugger (protocol v2)" +description = "A complete library to interact with Cloud Debugger (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/clouddebugger2" -homepage = "https://cloud.google.com/tools/cloud-debugger" +homepage = "http://cloud.google.com/debugger" documentation = "http://byron.github.io/google-apis-rs/google_clouddebugger2" license = "MIT" keywords = ["clouddebugger", "google", "protocol", "web", "api"] @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/clouddebugger2/README.md b/gen/clouddebugger2/README.md index 3066424007..c0f3672a09 100644 --- a/gen/clouddebugger2/README.md +++ b/gen/clouddebugger2/README.md @@ -3,15 +3,15 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/api/README.md.mako' DO NOT EDIT ! --> -The `google-clouddebugger2` library allows access to all features of the *Google clouddebugger* service. +The `google-clouddebugger2` library allows access to all features of the *Google Cloud Debugger* service. -This documentation was generated from *clouddebugger* crate version *0.1.14+20160309*, where *20160309* is the exact revision of the *clouddebugger:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Cloud Debugger* crate version *0.1.14+20160810*, where *20160810* is the exact revision of the *clouddebugger:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -Everything else about the *clouddebugger* *v2* API can be found at the -[official documentation site](https://cloud.google.com/tools/cloud-debugger). +Everything else about the *Cloud Debugger* *v2* API can be found at the +[official documentation site](http://cloud.google.com/debugger). # Features -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.Clouddebugger.html) ... +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.CloudDebugger.html) ... * controller * [*debuggees breakpoints list*](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.ControllerDebuggeeBreakpointListCall.html), [*debuggees breakpoints update*](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.ControllerDebuggeeBreakpointUpdateCall.html) and [*debuggees register*](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.ControllerDebuggeeRegisterCall.html) @@ -25,7 +25,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g The API is structured into the following primary items: -* **[Hub](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.Clouddebugger.html)** +* **[Hub](http://byron.github.io/google-apis-rs/google_clouddebugger2/struct.CloudDebugger.html)** * a central object to maintain state and allow accessing all *Activities* * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_clouddebugger2/trait.MethodsBuilder.html) which in turn allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_clouddebugger2/trait.CallBuilder.html) @@ -78,7 +78,7 @@ use clouddebugger2::Breakpoint; use clouddebugger2::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use clouddebugger2::Clouddebugger; +use clouddebugger2::CloudDebugger; // Get an ApplicationSecret instance by some means. It contains the `client_id` and // `client_secret`, among other things. @@ -91,7 +91,7 @@ let secret: ApplicationSecret = Default::default(); let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, hyper::Client::new(), ::default(), None); -let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +let mut hub = CloudDebugger::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 ! diff --git a/gen/clouddebugger2/src/lib.rs b/gen/clouddebugger2/src/lib.rs index 1cc4af569f..0f260ef9a4 100644 --- a/gen/clouddebugger2/src/lib.rs +++ b/gen/clouddebugger2/src/lib.rs @@ -2,14 +2,14 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *clouddebugger* crate version *0.1.14+20160309*, where *20160309* is the exact revision of the *clouddebugger:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Cloud Debugger* crate version *0.1.14+20160810*, where *20160810* is the exact revision of the *clouddebugger:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! -//! Everything else about the *clouddebugger* *v2* API can be found at the -//! [official documentation site](https://cloud.google.com/tools/cloud-debugger). +//! Everything else about the *Cloud Debugger* *v2* API can be found at the +//! [official documentation site](http://cloud.google.com/debugger). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/clouddebugger2). //! # Features //! -//! Handle the following *Resources* with ease from the central [hub](struct.Clouddebugger.html) ... +//! Handle the following *Resources* with ease from the central [hub](struct.CloudDebugger.html) ... //! //! * controller //! * [*debuggees breakpoints list*](struct.ControllerDebuggeeBreakpointListCall.html), [*debuggees breakpoints update*](struct.ControllerDebuggeeBreakpointUpdateCall.html) and [*debuggees register*](struct.ControllerDebuggeeRegisterCall.html) @@ -25,7 +25,7 @@ //! //! The API is structured into the following primary items: //! -//! * **[Hub](struct.Clouddebugger.html)** +//! * **[Hub](struct.CloudDebugger.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) @@ -79,7 +79,7 @@ //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use clouddebugger2::Clouddebugger; +//! use clouddebugger2::CloudDebugger; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. @@ -92,7 +92,7 @@ //! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, //! hyper::Client::new(), //! ::default(), None); -//! let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +//! let mut hub = CloudDebugger::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 ! diff --git a/gen/clouddebugger2/src/lib.rs.in b/gen/clouddebugger2/src/lib.rs.in index b4b2fa0a97..93e3ddfedf 100644 --- a/gen/clouddebugger2/src/lib.rs.in +++ b/gen/clouddebugger2/src/lib.rs.in @@ -41,9 +41,6 @@ pub enum Scope { /// View and manage your data across Google Cloud Platform services CloudPlatform, - - /// Manage active breakpoints in cloud debugger - CloudDebugletcontroller, } impl AsRef for Scope { @@ -51,7 +48,6 @@ impl AsRef for Scope { match *self { Scope::CloudDebugger => "https://www.googleapis.com/auth/cloud_debugger", Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", - Scope::CloudDebugletcontroller => "https://www.googleapis.com/auth/cloud_debugletcontroller", } } } @@ -68,7 +64,7 @@ impl Default for Scope { // HUB ### // ###### -/// Central instance to access all Clouddebugger related resource activities +/// Central instance to access all CloudDebugger related resource activities /// /// # Examples /// @@ -83,7 +79,7 @@ impl Default for Scope { /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use clouddebugger2::Clouddebugger; +/// use clouddebugger2::CloudDebugger; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. @@ -96,7 +92,7 @@ impl Default for Scope { /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// let mut hub = CloudDebugger::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 ! @@ -127,19 +123,19 @@ impl Default for Scope { /// } /// # } /// ``` -pub struct Clouddebugger { +pub struct CloudDebugger { client: RefCell, auth: RefCell, _user_agent: String, } -impl<'a, C, A> Hub for Clouddebugger {} +impl<'a, C, A> Hub for CloudDebugger {} -impl<'a, C, A> Clouddebugger +impl<'a, C, A> CloudDebugger where C: BorrowMut, A: oauth2::GetToken { - pub fn new(client: C, authenticator: A) -> Clouddebugger { - Clouddebugger { + pub fn new(client: C, authenticator: A) -> CloudDebugger { + CloudDebugger { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/0.1.14".to_string(), @@ -728,7 +724,7 @@ impl ResponseResult for GetBreakpointResponse {} // ################# /// A builder providing access to all methods supported on *controller* resources. -/// It is not used directly, but through the `Clouddebugger` hub. +/// It is not used directly, but through the `CloudDebugger` hub. /// /// # Example /// @@ -742,13 +738,13 @@ impl ResponseResult for GetBreakpointResponse {} /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use clouddebugger2::Clouddebugger; +/// use clouddebugger2::CloudDebugger; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// let mut hub = CloudDebugger::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `debuggees_breakpoints_list(...)`, `debuggees_breakpoints_update(...)` and `debuggees_register(...)` /// // to build up your call. @@ -758,7 +754,7 @@ impl ResponseResult for GetBreakpointResponse {} pub struct ControllerMethods<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, } impl<'a, C, A> MethodsBuilder for ControllerMethods<'a, C, A> {} @@ -826,7 +822,7 @@ impl<'a, C, A> ControllerMethods<'a, C, A> { /// A builder providing access to all methods supported on *debugger* resources. -/// It is not used directly, but through the `Clouddebugger` hub. +/// It is not used directly, but through the `CloudDebugger` hub. /// /// # Example /// @@ -840,13 +836,13 @@ impl<'a, C, A> ControllerMethods<'a, C, A> { /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use clouddebugger2::Clouddebugger; +/// use clouddebugger2::CloudDebugger; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// let mut hub = CloudDebugger::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `debuggees_breakpoints_delete(...)`, `debuggees_breakpoints_get(...)`, `debuggees_breakpoints_list(...)`, `debuggees_breakpoints_set(...)` and `debuggees_list(...)` /// // to build up your call. @@ -856,7 +852,7 @@ impl<'a, C, A> ControllerMethods<'a, C, A> { pub struct DebuggerMethods<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, } impl<'a, C, A> MethodsBuilder for DebuggerMethods<'a, C, A> {} @@ -987,13 +983,13 @@ impl<'a, C, A> DebuggerMethods<'a, C, A> { /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use clouddebugger2::Clouddebugger; +/// # use clouddebugger2::CloudDebugger; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -1009,7 +1005,7 @@ impl<'a, C, A> DebuggerMethods<'a, C, A> { pub struct ControllerDebuggeeBreakpointUpdateCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _request: UpdateActiveBreakpointRequest, _debuggee_id: String, _id: String, @@ -1271,13 +1267,13 @@ impl<'a, C, A> ControllerDebuggeeBreakpointUpdateCall<'a, C, A> where C: BorrowM /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use clouddebugger2::Clouddebugger; +/// # use clouddebugger2::CloudDebugger; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -1293,7 +1289,7 @@ impl<'a, C, A> ControllerDebuggeeBreakpointUpdateCall<'a, C, A> where C: BorrowM pub struct ControllerDebuggeeRegisterCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _request: RegisterDebuggeeRequest, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, @@ -1509,13 +1505,13 @@ impl<'a, C, A> ControllerDebuggeeRegisterCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -1528,7 +1524,7 @@ impl<'a, C, A> ControllerDebuggeeRegisterCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _debuggee_id: String, _wait_token: Option, _success_on_timeout: Option, @@ -1774,13 +1770,13 @@ impl<'a, C, A> ControllerDebuggeeBreakpointListCall<'a, C, A> where C: BorrowMut /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use clouddebugger2::Clouddebugger; +/// # use clouddebugger2::CloudDebugger; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -1792,7 +1788,7 @@ impl<'a, C, A> ControllerDebuggeeBreakpointListCall<'a, C, A> where C: BorrowMut pub struct DebuggerDebuggeeBreakpointGetCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _debuggee_id: String, _breakpoint_id: String, _client_version: Option, @@ -2039,13 +2035,13 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointGetCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -2057,7 +2053,7 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointGetCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _debuggee_id: String, _breakpoint_id: String, _client_version: Option, @@ -2304,13 +2300,13 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointDeleteCall<'a, C, A> where C: BorrowMut /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use clouddebugger2::Clouddebugger; +/// # use clouddebugger2::CloudDebugger; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -2324,7 +2320,7 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointDeleteCall<'a, C, A> where C: BorrowMut pub struct DebuggerDebuggeeListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _project: Option, _include_inactive: Option, _client_version: Option, @@ -2549,13 +2545,13 @@ impl<'a, C, A> DebuggerDebuggeeListCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -2572,7 +2568,7 @@ impl<'a, C, A> DebuggerDebuggeeListCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _request: Breakpoint, _debuggee_id: String, _client_version: Option, @@ -2832,13 +2828,13 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointSetCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Clouddebugger::new(hyper::Client::new(), auth); +/// # let mut hub = CloudDebugger::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 ! @@ -2855,7 +2851,7 @@ impl<'a, C, A> DebuggerDebuggeeBreakpointSetCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { - hub: &'a Clouddebugger, + hub: &'a CloudDebugger, _debuggee_id: String, _wait_token: Option, _strip_results: Option, diff --git a/gen/cloudlatencytest2-cli/Cargo.toml b/gen/cloudlatencytest2-cli/Cargo.toml index 21caf0baa8..d5866dd896 100644 --- a/gen/cloudlatencytest2-cli/Cargo.toml +++ b/gen/cloudlatencytest2-cli/Cargo.toml @@ -18,10 +18,10 @@ name = "cloudlatencytest2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -32,7 +32,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudlatencytest2/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudlatencytest2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudlatencytest2] diff --git a/gen/cloudlatencytest2/Cargo.toml b/gen/cloudlatencytest2/Cargo.toml index a6695a410a..c18a2c1ae1 100644 --- a/gen/cloudlatencytest2/Cargo.toml +++ b/gen/cloudlatencytest2/Cargo.toml @@ -17,10 +17,10 @@ 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 } +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] @@ -29,5 +29,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/cloudmonitoring2_beta2-cli/Cargo.toml b/gen/cloudmonitoring2_beta2-cli/Cargo.toml index 260db5f2c7..860df218c4 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+20160403" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "cloudmonitoring2-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudmonitoring2_beta2/ni with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudmonitoring2_beta2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudmonitoring2_beta2] diff --git a/gen/cloudmonitoring2_beta2-cli/README.md b/gen/cloudmonitoring2_beta2-cli/README.md index e86402dc4e..1d0ad8a9ee 100644 --- a/gen/cloudmonitoring2_beta2-cli/README.md +++ b/gen/cloudmonitoring2_beta2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Cloud Monitoring* API at revision *20160403*. 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 *0.3.6*. ```bash cloudmonitoring2-beta2 [options] diff --git a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml index 32b2e1a998..eccd51cac6 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+20160403 +site_name: Cloud Monitoring v0.3.6+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 b7d5bde30c..5f96f3dd55 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+20160403") + .version("0.3.6+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/cloudmonitoring2_beta2/Cargo.toml b/gen/cloudmonitoring2_beta2/Cargo.toml index fc8dbeb5f0..08443324ab 100644 --- a/gen/cloudmonitoring2_beta2/Cargo.toml +++ b/gen/cloudmonitoring2_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudmonitoring2_beta2" -version = "0.1.14+20160403" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/cloudmonitoring2_beta2/README.md b/gen/cloudmonitoring2_beta2/README.md index acf6276c67..c0ad2c71e3 100644 --- a/gen/cloudmonitoring2_beta2/README.md +++ b/gen/cloudmonitoring2_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudmonitoring2_beta2` library allows access to all features of the *Google Cloud Monitoring* service. -This documentation was generated from *Cloud Monitoring* crate version *0.1.14+20160403*, where *20160403* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Cloud Monitoring* crate version *0.1.14+20160718*, where *20160718* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the [official documentation site](https://cloud.google.com/monitoring/v2beta2/). diff --git a/gen/cloudmonitoring2_beta2/src/lib.rs b/gen/cloudmonitoring2_beta2/src/lib.rs index 3005b44ffa..34bc30c964 100644 --- a/gen/cloudmonitoring2_beta2/src/lib.rs +++ b/gen/cloudmonitoring2_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Cloud Monitoring* crate version *0.1.14+20160403*, where *20160403* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Cloud Monitoring* crate version *0.1.14+20160718*, where *20160718* is the exact revision of the *cloudmonitoring:v2beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the //! [official documentation site](https://cloud.google.com/monitoring/v2beta2/). diff --git a/gen/cloudresourcemanager1-cli/Cargo.toml b/gen/cloudresourcemanager1-cli/Cargo.toml index dfc815fc37..3c24bdd3f4 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+20160316" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "cloudresourcemanager1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudresourcemanager1/nig with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudresourcemanager1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudresourcemanager1] diff --git a/gen/cloudresourcemanager1-cli/README.md b/gen/cloudresourcemanager1-cli/README.md index 9d9fe643d4..1d713eba6a 100644 --- a/gen/cloudresourcemanager1-cli/README.md +++ b/gen/cloudresourcemanager1-cli/README.md @@ -24,10 +24,12 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Cloud Resource Manager* API at revision *20160316*. 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 *0.3.6*. ```bash cloudresourcemanager1 [options] + operations + get [-p ]... [-o ] projects delete [-p ]... [-o ] get [-p ]... [-o ] diff --git a/gen/cloudresourcemanager1-cli/mkdocs.yml b/gen/cloudresourcemanager1-cli/mkdocs.yml index 5363d6161d..fafd7631ce 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+20160316 +site_name: Cloud Resource Manager v0.3.6+20160617 site_url: http://byron.github.io/google-apis-rs/google-cloudresourcemanager1-cli site_description: Write integrating applications with bcore @@ -9,6 +9,7 @@ site_dir: build_html pages: - ['index.md', 'Home'] +- ['operations_get.md', 'Operations', 'Get'] - ['projects_delete.md', 'Projects', 'Delete'] - ['projects_get.md', 'Projects', 'Get'] - ['projects_get-iam-policy.md', 'Projects', 'Get Iam Policy'] diff --git a/gen/cloudresourcemanager1-cli/src/main.rs b/gen/cloudresourcemanager1-cli/src/main.rs index bf41cf2cef..785e59e848 100644 --- a/gen/cloudresourcemanager1-cli/src/main.rs +++ b/gen/cloudresourcemanager1-cli/src/main.rs @@ -45,6 +45,58 @@ struct Engine<'n> { impl<'n> Engine<'n> { + fn _operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operations().get(opt.value_of("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 _projects_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.projects().delete(opt.value_of("project-id").unwrap_or("")); @@ -647,6 +699,17 @@ impl<'n> Engine<'n> { let mut call_result: Result<(), DoitError> = Ok(()); let mut err_opt: Option = None; match self.opt.subcommand() { + ("operations", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._operations_get(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("operations".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, ("projects", Some(opt)) => { match opt.subcommand() { ("delete", Some(opt)) => { @@ -765,9 +828,34 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ + ("operations", "methods: 'get'", vec![ + ("get", + Some(r##"Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service."##), + "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_cli/operations_get", + vec![ + (Some(r##"name"##), + None, + Some(r##"The name of the operation resource."##), + 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: 'delete', 'get', 'get-iam-policy', 'list', 'set-iam-policy', 'test-iam-permissions', 'undelete' and 'update'", vec![ ("delete", - Some(r##"Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the lifecycle state changes to DELETE_IN_PROGRESS. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project."##), + Some(r##"Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_cli/projects_delete", vec![ (Some(r##"project-id"##), @@ -855,7 +943,7 @@ fn main() { Some(false)), ]), ("set-iam-policy", - Some(r##"Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles."##), + Some(r##"Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_cli/projects_set-iam-policy", vec![ (Some(r##"resource"##), @@ -911,7 +999,7 @@ fn main() { Some(false)), ]), ("undelete", - Some(r##"Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, as indicated by a lifecycle state of DELETE_IN_PROGRESS, the Project cannot be restored. The caller must have modify permissions for this Project."##), + Some(r##"Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have modify permissions for this Project."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_cli/projects_undelete", vec![ (Some(r##"project-id"##), @@ -972,7 +1060,7 @@ fn main() { let mut app = App::new("cloudresourcemanager1") .author("Sebastian Thiel ") - .version("0.3.6+20160316") + .version("0.3.6+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/Cargo.toml b/gen/cloudresourcemanager1/Cargo.toml index 7033c8ece7..3bb5918fff 100644 --- a/gen/cloudresourcemanager1/Cargo.toml +++ b/gen/cloudresourcemanager1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudresourcemanager1" -version = "0.1.14+20160316" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/cloudresourcemanager1/README.md b/gen/cloudresourcemanager1/README.md index c26f6a2a89..f698e8c5f7 100644 --- a/gen/cloudresourcemanager1/README.md +++ b/gen/cloudresourcemanager1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudresourcemanager1` library allows access to all features of the *Google Cloud Resource Manager* service. -This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *cloudresourcemanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160617*, where *20160617* is the exact revision of the *cloudresourcemanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Cloud Resource Manager* *v1* API can be found at the [official documentation site](https://cloud.google.com/resource-manager). @@ -13,6 +13,8 @@ Everything else about the *Cloud Resource Manager* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.CloudResourceManager.html) ... +* [operations](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.Operation.html) + * [*get*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.OperationGetCall.html) * [projects](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.Project.html) * [*delete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectGetCall.html), [*get iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectGetIamPolicyCall.html), [*list*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectListCall.html), [*set iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectTestIamPermissionCall.html), [*undelete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectUndeleteCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1/struct.ProjectUpdateCall.html) diff --git a/gen/cloudresourcemanager1/src/lib.rs b/gen/cloudresourcemanager1/src/lib.rs index 397928bc5e..3fd28325b9 100644 --- a/gen/cloudresourcemanager1/src/lib.rs +++ b/gen/cloudresourcemanager1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *cloudresourcemanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160617*, where *20160617* is the exact revision of the *cloudresourcemanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Cloud Resource Manager* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/resource-manager). @@ -11,6 +11,8 @@ //! //! Handle the following *Resources* with ease from the central [hub](struct.CloudResourceManager.html) ... //! +//! * [operations](struct.Operation.html) +//! * [*get*](struct.OperationGetCall.html) //! * [projects](struct.Project.html) //! * [*delete*](struct.ProjectDeleteCall.html), [*get*](struct.ProjectGetCall.html), [*get iam policy*](struct.ProjectGetIamPolicyCall.html), [*list*](struct.ProjectListCall.html), [*set iam policy*](struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](struct.ProjectTestIamPermissionCall.html), [*undelete*](struct.ProjectUndeleteCall.html) and [*update*](struct.ProjectUpdateCall.html) //! @@ -101,9 +103,9 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.projects().list() -//! .page_token("gubergren") -//! .page_size(-95) -//! .filter("aliquyam") +//! .page_token("sadipscing") +//! .page_size(-31) +//! .filter("ea") //! .doit(); //! //! match result { diff --git a/gen/cloudresourcemanager1/src/lib.rs.in b/gen/cloudresourcemanager1/src/lib.rs.in index 38fd9e9869..86d02c9409 100644 --- a/gen/cloudresourcemanager1/src/lib.rs.in +++ b/gen/cloudresourcemanager1/src/lib.rs.in @@ -138,6 +138,9 @@ impl<'a, C, A> CloudResourceManager } } + pub fn operations(&'a self) -> OperationMethods<'a, C, A> { + OperationMethods { hub: &self } + } pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { ProjectMethods { hub: &self } } @@ -172,6 +175,23 @@ pub struct UndeleteProjectRequest; impl RequestValue for UndeleteProjectRequest {} +/// 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 `TestIamPermissions` method. /// /// # Activities @@ -290,7 +310,7 @@ impl Part for Binding {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Project { - /// The user-assigned name of the Project. It must be 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: My Project Read-write. + /// The user-assigned display name of the Project. It must be 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: My Project Read-write. pub name: Option, /// An optional reference to a parent Resource. The only supported parent type is "organization". Once set, the parent cannot be modified. Read-write. pub parent: Option, @@ -338,6 +358,33 @@ pub struct Policy { impl ResponseResult for Policy {} +/// This resource represents a long-running operation that is the result of a network API call. +/// +/// # 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 operations](struct.OperationGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Operation { + /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. + pub metadata: Option>, + /// If the value is `false`, it means the operation is still in progress. If true, the operation is completed, and either `error` or `response` is available. + pub done: Option, + /// The normal response of the operation in case of success. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. + pub response: Option>, + /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should have the format of `operations/some/unique/name`. + pub name: Option, + /// The error result of the operation in case of failure. + pub error: Option, +} + +impl Resource for Operation {} +impl ResponseResult for Operation {} + + /// A page of the response received from the ListProjects method. A paginated response where more pages are available has `next_page_token` set. This token can be used in a subsequent request to retrieve the next request page. /// /// # Activities @@ -380,6 +427,64 @@ impl ResponseResult for Empty {} // MethodBuilders ### // ################# +/// A builder providing access to all methods supported on *operation* resources. +/// It is not used directly, but through the `CloudResourceManager` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use cloudresourcemanager1::CloudResourceManager; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = CloudResourceManager::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.operations(); +/// # } +/// ``` +pub struct OperationMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a CloudResourceManager, +} + +impl<'a, C, A> MethodsBuilder for OperationMethods<'a, C, A> {} + +impl<'a, C, A> OperationMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. + /// + /// # Arguments + /// + /// * `name` - The name of the operation resource. + pub fn get(&self, name: &str) -> OperationGetCall<'a, C, A> { + OperationGetCall { + hub: self.hub, + _name: name.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 `CloudResourceManager` hub. /// @@ -420,15 +525,17 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. + /// Returns permissions that a caller has on the specified Project. /// /// # Arguments /// - /// * `projectId` - The Project ID (for example, `my-project-123`). Required. - pub fn get(&self, project_id: &str) -> ProjectGetCall<'a, C, A> { - ProjectGetCall { + /// * `request` - No description provided. + /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `testIamPermissions` documentation. + pub fn test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectTestIamPermissionCall<'a, C, A> { + ProjectTestIamPermissionCall { hub: self.hub, - _project_id: project_id.to_string(), + _request: request, + _resource: resource.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -437,7 +544,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, as indicated by a lifecycle state of DELETE_IN_PROGRESS, the Project cannot be restored. The caller must have modify permissions for this Project. + /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have modify permissions for this Project. /// /// # Arguments /// @@ -456,7 +563,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. + /// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. /// /// # Arguments /// @@ -475,14 +582,31 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns permissions that a caller has on the specified Project. + /// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. + /// + /// # Arguments + /// + /// * `projectId` - The Project ID (for example, `my-project-123`). Required. + pub fn get(&self, project_id: &str) -> ProjectGetCall<'a, C, A> { + ProjectGetCall { + 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: + /// + /// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. /// /// # Arguments /// /// * `request` - No description provided. - /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `testIamPermissions` documentation. - pub fn test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectTestIamPermissionCall<'a, C, A> { - ProjectTestIamPermissionCall { + /// * `resource` - REQUIRED: The resource for which the policy is being requested. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `getIamPolicy` documentation. + pub fn get_iam_policy(&self, request: GetIamPolicyRequest, resource: &str) -> ProjectGetIamPolicyCall<'a, C, A> { + ProjectGetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), @@ -513,26 +637,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `resource` - REQUIRED: The resource for which the policy is being requested. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `getIamPolicy` documentation. - pub fn get_iam_policy(&self, request: GetIamPolicyRequest, resource: &str) -> ProjectGetIamPolicyCall<'a, C, A> { - ProjectGetIamPolicyCall { - hub: self.hub, - _request: request, - _resource: resource.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the lifecycle state changes to DELETE_IN_PROGRESS. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project. + /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project. /// /// # Arguments /// @@ -571,10 +676,10 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { // CallBuilders ### // ################# -/// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. +/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. /// -/// A builder for the *get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. +/// A builder for the *get* method supported by a *operation* resource. +/// It is not used directly, but through a `OperationMethods` instance. /// /// # Example /// @@ -597,27 +702,28 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// // You can configure optional parameters by calling 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("projectId") +/// let result = hub.operations().get("name") /// .doit(); /// # } /// ``` -pub struct ProjectGetCall<'a, C, A> +pub struct OperationGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudResourceManager, - _project_id: String, + _name: 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> CallBuilder for OperationGetCall<'a, C, A> {} -impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> OperationGetCall<'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)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -625,11 +731,11 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.get", + dlg.begin(MethodInfo { id: "cloudresourcemanager.operations.get", 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() { + params.push(("name", self._name.to_string())); + for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -641,24 +747,27 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://cloudresourcemanager.googleapis.com/v1/projects/{projectId}".to_string(); + let mut url = "https://cloudresourcemanager.googleapis.com/v1/{+name}".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 &(find_this, param_name) in [("{+name}", "name")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { + for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -744,14 +853,14 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa } - /// The Project ID (for example, `my-project-123`). Required. + /// The name of the operation resource. /// - /// Sets the *project id* path property to the given value. + /// Sets the *name* path property to 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) -> ProjectGetCall<'a, C, A> { - self._project_id = new_value.to_string(); + pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C, A> { + self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -760,7 +869,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperationGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -787,7 +896,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa /// * *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) -> ProjectGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> OperationGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -804,551 +913,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa /// 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 - } -} - - -/// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, as indicated by a lifecycle state of DELETE_IN_PROGRESS, the Project cannot be restored. The caller must have modify permissions for this Project. -/// -/// A builder for the *undelete* 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_cloudresourcemanager1 as cloudresourcemanager1; -/// use cloudresourcemanager1::UndeleteProjectRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudresourcemanager1::CloudResourceManager; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = CloudResourceManager::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 = UndeleteProjectRequest::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().undelete(req, "projectId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectUndeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a CloudResourceManager, - _request: UndeleteProjectRequest, - _project_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectUndeleteCall<'a, C, A> {} - -impl<'a, C, A> ProjectUndeleteCall<'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, Empty)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.undelete", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + 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://cloudresourcemanager.googleapis.com/v1/projects/{projectId}:undelete".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: UndeleteProjectRequest) -> ProjectUndeleteCall<'a, C, A> { - self._request = new_value; - self - } - /// The project ID (for example, `foo-bar-123`). 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) -> ProjectUndeleteCall<'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) -> ProjectUndeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProjectUndeleteCall<'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) -> ProjectUndeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. -/// -/// A builder for the *setIamPolicy* 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_cloudresourcemanager1 as cloudresourcemanager1; -/// use cloudresourcemanager1::SetIamPolicyRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudresourcemanager1::CloudResourceManager; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = CloudResourceManager::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 = SetIamPolicyRequest::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_iam_policy(req, "resource") -/// .doit(); -/// # } -/// ``` -pub struct ProjectSetIamPolicyCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a CloudResourceManager, - _request: SetIamPolicyRequest, - _resource: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectSetIamPolicyCall<'a, C, A> {} - -impl<'a, C, A> ProjectSetIamPolicyCall<'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, Policy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.setIamPolicy", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("resource", self._resource.to_string())); - for &field in ["alt", "resource"].iter() { - if self._additional_params.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://cloudresourcemanager.googleapis.com/v1/projects/{resource}:setIamPolicy".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{resource}", "resource")].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 ["resource"].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: SetIamPolicyRequest) -> ProjectSetIamPolicyCall<'a, C, A> { - self._request = new_value; - self - } - /// REQUIRED: The resource for which the policy is being specified. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `setIamPolicy` documentation. - /// - /// Sets the *resource* path property to 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(mut self, new_value: &str) -> ProjectSetIamPolicyCall<'a, C, A> { - self._resource = 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) -> ProjectSetIamPolicyCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProjectSetIamPolicyCall<'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) -> ProjectSetIamPolicyCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> OperationGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -1628,9 +1193,9 @@ impl<'a, C, A> ProjectTestIamPermissionCall<'a, C, A> where C: BorrowMut ProjectTestIamPermissionCall<'a, C, A> where C: BorrowMut ProjectTestIamPermissionCall<'a, C, A> where C: BorrowMut +pub struct ProjectUndeleteCall<'a, C, A> where C: 'a, A: 'a { hub: &'a CloudResourceManager, - _request: Project, + _request: UndeleteProjectRequest, _project_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectUndeleteCall<'a, C, A> {} -impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectUndeleteCall<'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)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1689,8 +1254,8 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.update", - http_method: hyper::method::Method::Put }); + dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.undelete", + http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("projectId", self._project_id.to_string())); for &field in ["alt", "projectId"].iter() { @@ -1705,7 +1270,7 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://cloudresourcemanager.googleapis.com/v1/projects/{projectId}".to_string(); + let mut url = "https://cloudresourcemanager.googleapis.com/v1/projects/{projectId}:undelete".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } @@ -1767,7 +1332,7 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: 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) + 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())) @@ -1828,17 +1393,17 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: /// /// 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: Project) -> ProjectUpdateCall<'a, C, A> { + pub fn request(mut self, new_value: UndeleteProjectRequest) -> ProjectUndeleteCall<'a, C, A> { self._request = new_value; self } - /// The project ID (for example, `my-project-123`). Required. + /// The project ID (for example, `foo-bar-123`). 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) -> ProjectUpdateCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectUndeleteCall<'a, C, A> { self._project_id = new_value.to_string(); self } @@ -1848,7 +1413,7 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectUpdateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectUndeleteCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1875,7 +1440,7 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: /// * *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) -> ProjectUpdateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectUndeleteCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1892,7 +1457,520 @@ impl<'a, C, A> ProjectUpdateCall<'a, C, A> where C: BorrowMut, A: /// 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) -> ProjectUpdateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectUndeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. +/// +/// A builder for the *setIamPolicy* 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_cloudresourcemanager1 as cloudresourcemanager1; +/// use cloudresourcemanager1::SetIamPolicyRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use cloudresourcemanager1::CloudResourceManager; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = CloudResourceManager::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 = SetIamPolicyRequest::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_iam_policy(req, "resource") +/// .doit(); +/// # } +/// ``` +pub struct ProjectSetIamPolicyCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a CloudResourceManager, + _request: SetIamPolicyRequest, + _resource: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectSetIamPolicyCall<'a, C, A> {} + +impl<'a, C, A> ProjectSetIamPolicyCall<'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, Policy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.setIamPolicy", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("resource", self._resource.to_string())); + for &field in ["alt", "resource"].iter() { + if self._additional_params.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://cloudresourcemanager.googleapis.com/v1/projects/{resource}:setIamPolicy".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{resource}", "resource")].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 ["resource"].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: SetIamPolicyRequest) -> ProjectSetIamPolicyCall<'a, C, A> { + self._request = new_value; + self + } + /// REQUIRED: The resource for which the policy is being specified. `resource` is usually specified as a path, such as `projects/*project*/zones/*zone*/disks/*disk*`. The format for the path specified in this value is resource specific and is specified in the `setIamPolicy` documentation. + /// + /// Sets the *resource* path property to 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(mut self, new_value: &str) -> ProjectSetIamPolicyCall<'a, C, A> { + self._resource = 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) -> ProjectSetIamPolicyCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectSetIamPolicyCall<'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) -> ProjectSetIamPolicyCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. +/// +/// 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_cloudresourcemanager1 as cloudresourcemanager1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use cloudresourcemanager1::CloudResourceManager; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = CloudResourceManager::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("projectId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a CloudResourceManager, + _project_id: 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: "cloudresourcemanager.projects.get", + 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://cloudresourcemanager.googleapis.com/v1/projects/{projectId}".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) + } + } + } + } + + + /// The Project ID (for example, `my-project-123`). 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) -> ProjectGetCall<'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) -> 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 + /// + /// * *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) -> 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::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) -> ProjectGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -2172,7 +2250,279 @@ impl<'a, C, A> ProjectGetIamPolicyCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = CloudResourceManager::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 = Project::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().update(req, "projectId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a CloudResourceManager, + _request: Project, + _project_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectUpdateCall<'a, C, A> {} + +impl<'a, C, A> ProjectUpdateCall<'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: "cloudresourcemanager.projects.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + 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://cloudresourcemanager.googleapis.com/v1/projects/{projectId}".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::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: Project) -> ProjectUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The project ID (for example, `my-project-123`). 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) -> ProjectUpdateCall<'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) -> ProjectUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectUpdateCall<'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) -> ProjectUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project. /// /// A builder for the *delete* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -2440,9 +2790,9 @@ impl<'a, C, A> ProjectDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().list() -/// .page_token("sea") -/// .page_size(-90) -/// .filter("dolores") +/// .page_token("nonumy") +/// .page_size(-19) +/// .filter("gubergren") /// .doit(); /// # } /// ``` diff --git a/gen/cloudresourcemanager1_beta1-cli/Cargo.toml b/gen/cloudresourcemanager1_beta1-cli/Cargo.toml index 105ba9fc70..acba41536d 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+20160316" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "cloudresourcemanager1-beta1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudresourcemanager1_bet with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudresourcemanager1_beta1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudresourcemanager1_beta1] diff --git a/gen/cloudresourcemanager1_beta1-cli/README.md b/gen/cloudresourcemanager1_beta1-cli/README.md index 3f06dd01eb..a1f48ed24d 100644 --- a/gen/cloudresourcemanager1_beta1-cli/README.md +++ b/gen/cloudresourcemanager1_beta1-cli/README.md @@ -24,21 +24,22 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Cloud Resource Manager* API at revision *20160316*. 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 *0.3.6*. ```bash cloudresourcemanager1-beta1 [options] organizations - get [-p ]... [-o ] + get [-p ]... [-o ] get-iam-policy (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-iam-policy (-r )... [-p ]... [-o ] test-iam-permissions (-r )... [-p ]... [-o ] - update (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] projects create (-r )... [-p ]... [-o ] delete [-p ]... [-o ] get [-p ]... [-o ] + get-ancestry (-r )... [-p ]... [-o ] get-iam-policy (-r )... [-p ]... [-o ] list [-p ]... [-o ] set-iam-policy (-r )... [-p ]... [-o ] diff --git a/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml b/gen/cloudresourcemanager1_beta1-cli/mkdocs.yml index e043c718ad..11fd85df64 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+20160316 +site_name: Cloud Resource Manager v0.3.6+20160617 site_url: http://byron.github.io/google-apis-rs/google-cloudresourcemanager1_beta1-cli site_description: Write integrating applications with bcore @@ -18,6 +18,7 @@ pages: - ['projects_create.md', 'Projects', 'Create'] - ['projects_delete.md', 'Projects', 'Delete'] - ['projects_get.md', 'Projects', 'Get'] +- ['projects_get-ancestry.md', 'Projects', 'Get Ancestry'] - ['projects_get-iam-policy.md', 'Projects', 'Get Iam Policy'] - ['projects_list.md', 'Projects', 'List'] - ['projects_set-iam-policy.md', 'Projects', 'Set Iam Policy'] diff --git a/gen/cloudresourcemanager1_beta1-cli/src/main.rs b/gen/cloudresourcemanager1_beta1-cli/src/main.rs index e9521785d1..0c3e34f8b6 100644 --- a/gen/cloudresourcemanager1_beta1-cli/src/main.rs +++ b/gen/cloudresourcemanager1_beta1-cli/src/main.rs @@ -47,10 +47,13 @@ struct Engine<'n> { impl<'n> Engine<'n> { fn _organizations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { - let mut call = self.hub.organizations().get(opt.value_of("organization-id").unwrap_or("")); + let mut call = self.hub.organizations().get(opt.value_of("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 { + "organization-id" => { + call = call.organization_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -64,6 +67,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["organization-id"].iter().map(|v|*v)); v } )); } } @@ -437,12 +441,14 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { - "organization-id" => Some(("organizationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "owner.directory-customer-id" => Some(("owner.directoryCustomerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "organization-id" => Some(("organizationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "creation-time" => Some(("creationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lifecycle-state" => Some(("lifecycleState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner.directory-customer-id" => Some(("owner.directoryCustomerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "directory-customer-id", "display-name", "organization-id", "owner"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-time", "directory-customer-id", "display-name", "lifecycle-state", "name", "organization-id", "owner"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -452,7 +458,7 @@ impl<'n> Engine<'n> { } } let mut request: api::Organization = json::value::from_value(object).unwrap(); - let mut call = self.hub.organizations().update(request, opt.value_of("organization-id").unwrap_or("")); + let mut call = self.hub.organizations().update(request, opt.value_of("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 { @@ -698,6 +704,90 @@ impl<'n> Engine<'n> { } } + fn _projects_get_ancestry(&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::GetAncestryRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.projects().get_ancestry(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 { + _ => { + 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_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { @@ -1233,6 +1323,9 @@ impl<'n> Engine<'n> { ("get", Some(opt)) => { call_result = self._projects_get(opt, dry_run, &mut err); }, + ("get-ancestry", Some(opt)) => { + call_result = self._projects_get_ancestry(opt, dry_run, &mut err); + }, ("get-iam-policy", Some(opt)) => { call_result = self._projects_get_iam_policy(opt, dry_run, &mut err); }, @@ -1345,12 +1438,12 @@ fn main() { let arg_data = [ ("organizations", "methods: 'get', 'get-iam-policy', 'list', 'set-iam-policy', 'test-iam-permissions' and 'update'", vec![ ("get", - Some(r##"Fetches an Organization resource identified by the specified `organization_id`."##), + Some(r##"Fetches an Organization resource identified by the specified resource name."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/organizations_get", vec![ - (Some(r##"organization-id"##), + (Some(r##"name"##), None, - Some(r##"The id of the Organization resource to fetch."##), + Some(r##"The resource name of the Organization to fetch. Its format is "organizations/[organization_id]". For example, "organizations/1234"."##), Some(true), Some(false)), @@ -1367,7 +1460,7 @@ fn main() { Some(false)), ]), ("get-iam-policy", - Some(r##"Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists."##), + Some(r##"Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/organizations_get-iam-policy", vec![ (Some(r##"resource"##), @@ -1411,7 +1504,7 @@ fn main() { Some(false)), ]), ("set-iam-policy", - Some(r##"Sets the access control policy on an Organization resource. Replaces any existing policy."##), + Some(r##"Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/organizations_set-iam-policy", vec![ (Some(r##"resource"##), @@ -1439,7 +1532,7 @@ fn main() { Some(false)), ]), ("test-iam-permissions", - Some(r##"Returns permissions that a caller has on the specified Organization."##), + Some(r##"Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/organizations_test-iam-permissions", vec![ (Some(r##"resource"##), @@ -1467,12 +1560,12 @@ fn main() { Some(false)), ]), ("update", - Some(r##"Updates an Organization resource identified by the specified `organization_id`."##), + Some(r##"Updates an Organization resource identified by the specified resource name."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/organizations_update", vec![ - (Some(r##"organization-id"##), + (Some(r##"name"##), None, - Some(r##"An immutable id for the Organization that is assigned on creation. This should be omitted when creating a new Organization. This field is read-only."##), + Some(r##"Output Only. The resource name of the organization. This is the organization's relative path in the API. Its format is "organizations/[organization_id]". For example, "organizations/1234"."##), Some(true), Some(false)), @@ -1496,7 +1589,7 @@ fn main() { ]), ]), - ("projects", "methods: 'create', 'delete', 'get', 'get-iam-policy', 'list', 'set-iam-policy', 'test-iam-permissions', 'undelete' and 'update'", vec![ + ("projects", "methods: 'create', 'delete', 'get', 'get-ancestry', 'get-iam-policy', 'list', 'set-iam-policy', 'test-iam-permissions', 'undelete' and 'update'", vec![ ("create", Some(r##"Creates a Project resource. Initially, the Project resource is owned by its creator exclusively. The creator can later grant permission to others to read or update the Project. Several APIs are activated automatically for the Project, including Google Cloud Storage."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/projects_create", @@ -1520,7 +1613,7 @@ fn main() { Some(false)), ]), ("delete", - Some(r##"Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the lifecycle state changes to DELETE_IN_PROGRESS. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project."##), + Some(r##"Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/projects_delete", vec![ (Some(r##"project-id"##), @@ -1557,6 +1650,34 @@ fn main() { 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-ancestry", + Some(r##"Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project."##), + "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/projects_get-ancestry", + vec![ + (Some(r##"project-id"##), + None, + Some(r##"The Project ID (for example, `my-project-123`). 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"##), @@ -1608,7 +1729,7 @@ fn main() { Some(false)), ]), ("set-iam-policy", - Some(r##"Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles."##), + Some(r##"Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/projects_set-iam-policy", vec![ (Some(r##"resource"##), @@ -1664,7 +1785,7 @@ fn main() { Some(false)), ]), ("undelete", - Some(r##"Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, as indicated by a lifecycle state of DELETE_IN_PROGRESS, the Project cannot be restored. The caller must have modify permissions for this Project."##), + Some(r##"Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have modify permissions for this Project."##), "Details at http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1_cli/projects_undelete", vec![ (Some(r##"project-id"##), @@ -1725,7 +1846,7 @@ fn main() { let mut app = App::new("cloudresourcemanager1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20160316") + .version("0.3.6+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/cloudresourcemanager1_beta1/Cargo.toml b/gen/cloudresourcemanager1_beta1/Cargo.toml index a964d7bf1b..d2e79f6865 100644 --- a/gen/cloudresourcemanager1_beta1/Cargo.toml +++ b/gen/cloudresourcemanager1_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-cloudresourcemanager1_beta1" -version = "0.1.14+20160316" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/cloudresourcemanager1_beta1/README.md b/gen/cloudresourcemanager1_beta1/README.md index df39fad8cc..7c3a52539b 100644 --- a/gen/cloudresourcemanager1_beta1/README.md +++ b/gen/cloudresourcemanager1_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-cloudresourcemanager1_beta1` library allows access to all features of the *Google Cloud Resource Manager* service. -This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *cloudresourcemanager:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160617*, where *20160617* is the exact revision of the *cloudresourcemanager:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Cloud Resource Manager* *v1_beta1* API can be found at the [official documentation site](https://cloud.google.com/resource-manager). @@ -16,7 +16,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [organizations](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.Organization.html) * [*get*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationGetCall.html), [*get iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationGetIamPolicyCall.html), [*list*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationListCall.html), [*set iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationSetIamPolicyCall.html), [*test iam permissions*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationTestIamPermissionCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.OrganizationUpdateCall.html) * [projects](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.Project.html) - * [*create*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectGetCall.html), [*get iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectGetIamPolicyCall.html), [*list*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectListCall.html), [*set iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectTestIamPermissionCall.html), [*undelete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectUndeleteCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectUpdateCall.html) + * [*create*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectGetCall.html), [*get ancestry*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectGetAncestryCall.html), [*get iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectGetIamPolicyCall.html), [*list*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectListCall.html), [*set iam policy*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectTestIamPermissionCall.html), [*undelete*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectUndeleteCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_cloudresourcemanager1_beta1/struct.ProjectUpdateCall.html) @@ -53,6 +53,7 @@ let r = hub.projects().test_iam_permissions(...).doit() let r = hub.projects().undelete(...).doit() let r = hub.projects().set_iam_policy(...).doit() let r = hub.projects().get(...).doit() +let r = hub.projects().get_ancestry(...).doit() let r = hub.projects().update(...).doit() let r = hub.projects().get_iam_policy(...).doit() let r = hub.projects().delete(...).doit() diff --git a/gen/cloudresourcemanager1_beta1/src/lib.rs b/gen/cloudresourcemanager1_beta1/src/lib.rs index b2fc1c35be..726ba66daa 100644 --- a/gen/cloudresourcemanager1_beta1/src/lib.rs +++ b/gen/cloudresourcemanager1_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *cloudresourcemanager:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Cloud Resource Manager* crate version *0.1.14+20160617*, where *20160617* is the exact revision of the *cloudresourcemanager:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Cloud Resource Manager* *v1_beta1* API can be found at the //! [official documentation site](https://cloud.google.com/resource-manager). @@ -14,7 +14,7 @@ //! * [organizations](struct.Organization.html) //! * [*get*](struct.OrganizationGetCall.html), [*get iam policy*](struct.OrganizationGetIamPolicyCall.html), [*list*](struct.OrganizationListCall.html), [*set iam policy*](struct.OrganizationSetIamPolicyCall.html), [*test iam permissions*](struct.OrganizationTestIamPermissionCall.html) and [*update*](struct.OrganizationUpdateCall.html) //! * [projects](struct.Project.html) -//! * [*create*](struct.ProjectCreateCall.html), [*delete*](struct.ProjectDeleteCall.html), [*get*](struct.ProjectGetCall.html), [*get iam policy*](struct.ProjectGetIamPolicyCall.html), [*list*](struct.ProjectListCall.html), [*set iam policy*](struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](struct.ProjectTestIamPermissionCall.html), [*undelete*](struct.ProjectUndeleteCall.html) and [*update*](struct.ProjectUpdateCall.html) +//! * [*create*](struct.ProjectCreateCall.html), [*delete*](struct.ProjectDeleteCall.html), [*get*](struct.ProjectGetCall.html), [*get ancestry*](struct.ProjectGetAncestryCall.html), [*get iam policy*](struct.ProjectGetIamPolicyCall.html), [*list*](struct.ProjectListCall.html), [*set iam policy*](struct.ProjectSetIamPolicyCall.html), [*test iam permissions*](struct.ProjectTestIamPermissionCall.html), [*undelete*](struct.ProjectUndeleteCall.html) and [*update*](struct.ProjectUpdateCall.html) //! //! //! @@ -53,6 +53,7 @@ //! let r = hub.projects().undelete(...).doit() //! let r = hub.projects().set_iam_policy(...).doit() //! let r = hub.projects().get(...).doit() +//! let r = hub.projects().get_ancestry(...).doit() //! let r = hub.projects().update(...).doit() //! let r = hub.projects().get_iam_policy(...).doit() //! let r = hub.projects().delete(...).doit() @@ -104,9 +105,9 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.projects().list() -//! .page_token("et") -//! .page_size(-41) -//! .filter("ipsum") +//! .page_token("ipsum") +//! .page_size(-5) +//! .filter("et") //! .doit(); //! //! match result { diff --git a/gen/cloudresourcemanager1_beta1/src/lib.rs.in b/gen/cloudresourcemanager1_beta1/src/lib.rs.in index 09126a31d7..40beca7a6a 100644 --- a/gen/cloudresourcemanager1_beta1/src/lib.rs.in +++ b/gen/cloudresourcemanager1_beta1/src/lib.rs.in @@ -160,84 +160,6 @@ impl<'a, C, A> CloudResourceManager // ############ // SCHEMAS ### // ########## -/// The request sent to the UndeleteProject method. -/// -/// # 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*). -/// -/// * [undelete projects](struct.ProjectUndeleteCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UndeleteProjectRequest; - -impl RequestValue for UndeleteProjectRequest {} - - -/// A Project is a high-level Google Cloud Platform entity. It is a container for ACLs, APIs, AppEngine Apps, VMs, and other Google Cloud Platform 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*). -/// -/// * [test iam permissions projects](struct.ProjectTestIamPermissionCall.html) (none) -/// * [undelete projects](struct.ProjectUndeleteCall.html) (none) -/// * [set iam policy projects](struct.ProjectSetIamPolicyCall.html) (none) -/// * [get projects](struct.ProjectGetCall.html) (response) -/// * [update projects](struct.ProjectUpdateCall.html) (request|response) -/// * [get iam policy projects](struct.ProjectGetIamPolicyCall.html) (none) -/// * [delete projects](struct.ProjectDeleteCall.html) (none) -/// * [create projects](struct.ProjectCreateCall.html) (request|response) -/// * [list projects](struct.ProjectListCall.html) (none) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Project { - /// The user-assigned name of the Project. It must be 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: My Project Read-write. - pub name: Option, - /// An optional reference to a parent Resource. The only supported parent type is "organization". Once set, the parent cannot be modified. Read-write. - pub parent: Option, - /// The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited. Example: tokyo-rain-123 Read-only after creation. - #[serde(rename="projectId")] - pub project_id: Option, - /// The labels associated with this Project. Label keys must be between 1 and 63 characters long and must conform to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. Label values must be between 0 and 63 characters long and must conform to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. No more than 256 labels can be associated with a given resource. Clients should store labels in a representation such as JSON that does not depend on specific characters being disallowed. Example: "environment" : "dev" Read-write. - pub labels: Option>, - /// The number uniquely identifying the project. Example: 415104041262 Read-only. - #[serde(rename="projectNumber")] - pub project_number: Option, - /// Creation time. Read-only. - #[serde(rename="createTime")] - pub create_time: Option, - /// The Project lifecycle state. Read-only. - #[serde(rename="lifecycleState")] - pub lifecycle_state: Option, -} - -impl RequestValue for Project {} -impl Resource for Project {} -impl ResponseResult for Project {} - - -/// Response message for `TestIamPermissions` method. -/// -/// # 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*). -/// -/// * [test iam permissions organizations](struct.OrganizationTestIamPermissionCall.html) (response) -/// * [test iam permissions projects](struct.ProjectTestIamPermissionCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TestIamPermissionsResponse { - /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed. - pub permissions: Option>, -} - -impl ResponseResult for TestIamPermissionsResponse {} - - /// Request message for `GetIamPolicy` method. /// /// # Activities @@ -292,56 +214,82 @@ pub struct SetIamPolicyRequest { impl RequestValue for SetIamPolicyRequest {} -/// A container to reference an id for any resource type. A `resource` in Google Cloud Platform is a generic term for something you (a developer) may want to interact with through one of our API's. Some examples are an AppEngine app, a Compute Engine instance, a Cloud SQL database, and so on. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ResourceId { - /// Required field representing the resource type this id is for. At present, the only valid type is "organization". - #[serde(rename="type")] - pub type_: Option, - /// Required field for the type-specific id. This should correspond to the id used in the type-specific API's. - pub id: Option, -} - -impl Part for ResourceId {} - - -/// Associates `members` with a `role`. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Binding { - /// Role that is assigned to `members`. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. Required - pub role: Option, - /// Specifies the identities requesting access for a Cloud Platform resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@gmail.com` or `joe@example.com`. * `serviceAccount:{emailid}`: An email address that represents a service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: A Google Apps domain name that represents all the users of that domain. For example, `google.com` or `example.com`. - pub members: Option>, -} - -impl Part for Binding {} - - -/// The response returned from the `ListOrganizations` method. +/// Response from the GetAncestry method. /// /// # 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 organizations](struct.OrganizationListCall.html) (response) +/// * [get ancestry projects](struct.ProjectGetAncestryCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListOrganizationsResponse { - /// A pagination token to be used to retrieve the next page of results. If the result is too large to fit within the page size specified in the request, this field will be set with a token that can be used to fetch the next page of results. If this field is empty, it indicates that this response contains the last page of results. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// The list of Organizations that matched the list query, possibly paginated. - pub organizations: Option>, +pub struct GetAncestryResponse { + /// Ancestors are ordered from bottom to top of the resource hierarchy. The first ancestor is the project itself, followed by the project's parent, etc. + pub ancestor: Option>, } -impl ResponseResult for ListOrganizationsResponse {} +impl ResponseResult for GetAncestryResponse {} + + +/// A Project is a high-level Google Cloud Platform entity. It is a container for ACLs, APIs, AppEngine Apps, VMs, and other Google Cloud Platform 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*). +/// +/// * [test iam permissions projects](struct.ProjectTestIamPermissionCall.html) (none) +/// * [undelete projects](struct.ProjectUndeleteCall.html) (none) +/// * [set iam policy projects](struct.ProjectSetIamPolicyCall.html) (none) +/// * [get projects](struct.ProjectGetCall.html) (response) +/// * [get ancestry projects](struct.ProjectGetAncestryCall.html) (none) +/// * [update projects](struct.ProjectUpdateCall.html) (request|response) +/// * [get iam policy projects](struct.ProjectGetIamPolicyCall.html) (none) +/// * [delete projects](struct.ProjectDeleteCall.html) (none) +/// * [create projects](struct.ProjectCreateCall.html) (request|response) +/// * [list projects](struct.ProjectListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Project { + /// The user-assigned display name of the Project. It must be 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: My Project Read-write. + pub name: Option, + /// An optional reference to a parent Resource. The only supported parent type is "organization". Once set, the parent cannot be modified. Read-write. + pub parent: Option, + /// The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited. Example: tokyo-rain-123 Read-only after creation. + #[serde(rename="projectId")] + pub project_id: Option, + /// The labels associated with this Project. Label keys must be between 1 and 63 characters long and must conform to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. Label values must be between 0 and 63 characters long and must conform to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. No more than 256 labels can be associated with a given resource. Clients should store labels in a representation such as JSON that does not depend on specific characters being disallowed. Example: "environment" : "dev" Read-write. + pub labels: Option>, + /// The number uniquely identifying the project. Example: 415104041262 Read-only. + #[serde(rename="projectNumber")] + pub project_number: Option, + /// Creation time. Read-only. + #[serde(rename="createTime")] + pub create_time: Option, + /// The Project lifecycle state. Read-only. + #[serde(rename="lifecycleState")] + pub lifecycle_state: Option, +} + +impl RequestValue for Project {} +impl Resource for Project {} +impl ResponseResult for Project {} + + +/// The request sent to the GetAncestry method. +/// +/// # 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 ancestry projects](struct.ProjectGetAncestryCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GetAncestryRequest; + +impl RequestValue for GetAncestryRequest {} /// Defines an Identity and Access Management (IAM) policy. It is used to specify access control policies for Cloud Platform resources. A `Policy` consists of a list of `bindings`. A `Binding` binds a list of `members` to a `role`, where the members can be user accounts, Google groups, Google domains, and service accounts. A `role` is a named list of permissions defined by IAM. **Example** { "bindings": [ { "role": "roles/owner", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-other-app@appspot.gserviceaccount.com", ] }, { "role": "roles/viewer", "members": ["user:sean@example.com"] } ] } For a description of IAM and its features, see the [IAM developer's guide](https://cloud.google.com/iam). @@ -385,17 +333,22 @@ impl ResponseResult for Policy {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Organization { - /// An immutable id for the Organization that is assigned on creation. This should be omitted when creating a new Organization. This field is read-only. - #[serde(rename="organizationId")] - pub organization_id: Option, /// The owner of this Organization. The owner should be specified on creation. Once set, it cannot be changed. This field is required. pub owner: Option, /// A friendly string to be used to refer to the Organization in the UI. This field is required. #[serde(rename="displayName")] pub display_name: Option, + /// Output Only. The resource name of the organization. This is the organization's relative path in the API. Its format is "organizations/[organization_id]". For example, "organizations/1234". + pub name: Option, + /// An immutable id for the Organization that is assigned on creation. This should be omitted when creating a new Organization. This field is read-only. This field is deprecated and will be removed in v1. Use name instead. + #[serde(rename="organizationId")] + pub organization_id: Option, /// Timestamp when the Organization was created. Assigned by the server. @OutputOnly #[serde(rename="creationTime")] pub creation_time: Option, + /// The organization's current lifecycle state. Assigned by the server. @OutputOnly + #[serde(rename="lifecycleState")] + pub lifecycle_state: Option, } impl RequestValue for Organization {} @@ -440,6 +393,106 @@ pub struct Empty; impl ResponseResult for Empty {} +/// The request sent to the UndeleteProject method. +/// +/// # 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*). +/// +/// * [undelete projects](struct.ProjectUndeleteCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UndeleteProjectRequest; + +impl RequestValue for UndeleteProjectRequest {} + + +/// The response returned from the `ListOrganizations` method. +/// +/// # 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 organizations](struct.OrganizationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListOrganizationsResponse { + /// A pagination token to be used to retrieve the next page of results. If the result is too large to fit within the page size specified in the request, this field will be set with a token that can be used to fetch the next page of results. If this field is empty, it indicates that this response contains the last page of results. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The list of Organizations that matched the list query, possibly paginated. + pub organizations: Option>, +} + +impl ResponseResult for ListOrganizationsResponse {} + + +/// Response message for `TestIamPermissions` method. +/// +/// # 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*). +/// +/// * [test iam permissions organizations](struct.OrganizationTestIamPermissionCall.html) (response) +/// * [test iam permissions projects](struct.ProjectTestIamPermissionCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TestIamPermissionsResponse { + /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed. + pub permissions: Option>, +} + +impl ResponseResult for TestIamPermissionsResponse {} + + +/// Identifying information for a single ancestor of a project. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Ancestor { + /// Resource id of the ancestor. + #[serde(rename="resourceId")] + pub resource_id: Option, +} + +impl Part for Ancestor {} + + +/// A container to reference an id for any resource type. A `resource` in Google Cloud Platform is a generic term for something you (a developer) may want to interact with through one of our API's. Some examples are an AppEngine app, a Compute Engine instance, a Cloud SQL database, and so on. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ResourceId { + /// Required field representing the resource type this id is for. At present, the valid types are "project" and "organization". + #[serde(rename="type")] + pub type_: Option, + /// Required field for the type-specific id. This should correspond to the id used in the type-specific API's. + pub id: Option, +} + +impl Part for ResourceId {} + + +/// Associates `members` with a `role`. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Binding { + /// Role that is assigned to `members`. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. Required + pub role: Option, + /// Specifies the identities requesting access for a Cloud Platform resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@gmail.com` or `joe@example.com`. * `serviceAccount:{emailid}`: An email address that represents a service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: A Google Apps domain name that represents all the users of that domain. For example, `google.com` or `example.com`. + pub members: Option>, +} + +impl Part for Binding {} + + /// The entity that owns an Organization. The lifetime of the Organization and all of its descendants are bound to the `OrganizationOwner`. If the `OrganizationOwner` is deleted, the Organization and all its descendants will be deleted. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -499,7 +552,7 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sets the access control policy on an Organization resource. Replaces any existing policy. + /// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1. /// /// # Arguments /// @@ -518,7 +571,7 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. + /// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1. /// /// # Arguments /// @@ -537,7 +590,7 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns permissions that a caller has on the specified Organization. + /// Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1. /// /// # Arguments /// @@ -556,15 +609,16 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Fetches an Organization resource identified by the specified `organization_id`. + /// Fetches an Organization resource identified by the specified resource name. /// /// # Arguments /// - /// * `organizationId` - The id of the Organization resource to fetch. - pub fn get(&self, organization_id: &str) -> OrganizationGetCall<'a, C, A> { + /// * `name` - The resource name of the Organization to fetch. Its format is "organizations/[organization_id]". For example, "organizations/1234". + pub fn get(&self, name: &str) -> OrganizationGetCall<'a, C, A> { OrganizationGetCall { hub: self.hub, - _organization_id: organization_id.to_string(), + _name: name.to_string(), + _organization_id: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -573,17 +627,17 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an Organization resource identified by the specified `organization_id`. + /// Updates an Organization resource identified by the specified resource name. /// /// # Arguments /// /// * `request` - No description provided. - /// * `organizationId` - An immutable id for the Organization that is assigned on creation. This should be omitted when creating a new Organization. This field is read-only. - pub fn update(&self, request: Organization, organization_id: &str) -> OrganizationUpdateCall<'a, C, A> { + /// * `name` - Output Only. The resource name of the organization. This is the organization's relative path in the API. Its format is "organizations/[organization_id]". For example, "organizations/1234". + pub fn update(&self, request: Organization, name: &str) -> OrganizationUpdateCall<'a, C, A> { OrganizationUpdateCall { hub: self.hub, _request: request, - _organization_id: organization_id.to_string(), + _name: name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -631,7 +685,7 @@ impl<'a, C, A> OrganizationMethods<'a, C, A> { /// ::default(), None); /// let mut hub = CloudResourceManager::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)`, `undelete(...)` and `update(...)` +/// // like `create(...)`, `delete(...)`, `get(...)`, `get_ancestry(...)`, `get_iam_policy(...)`, `list(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)`, `undelete(...)` and `update(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } @@ -667,7 +721,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, as indicated by a lifecycle state of DELETE_IN_PROGRESS, the Project cannot be restored. The caller must have modify permissions for this Project. + /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have modify permissions for this Project. /// /// # Arguments /// @@ -703,7 +757,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. + /// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. /// /// # Arguments /// @@ -737,6 +791,25 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `projectId` - The Project ID (for example, `my-project-123`). Required. + pub fn get_ancestry(&self, request: GetAncestryRequest, project_id: &str) -> ProjectGetAncestryCall<'a, C, A> { + ProjectGetAncestryCall { + hub: self.hub, + _request: request, + _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: /// /// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project. @@ -777,7 +850,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the lifecycle state changes to DELETE_IN_PROGRESS. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project. + /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if the following criteria are met: + The Project does not have a billing account associated with it. + The Project has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have modify permissions for this Project. /// /// # Arguments /// @@ -816,7 +889,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { // CallBuilders ### // ################# -/// Sets the access control policy on an Organization resource. Replaces any existing policy. +/// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". For backward compatibility, the resource provided may also be the organization_id. This will not be supported in v1. /// /// A builder for the *setIamPolicy* method supported by a *organization* resource. /// It is not used directly, but through a `OrganizationMethods` instance. @@ -870,6 +943,7 @@ impl<'a, C, A> OrganizationSetIamPolicyCall<'a, C, A> where C: BorrowMut Result<(hyper::client::Response, Policy)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -893,20 +967,23 @@ impl<'a, C, A> OrganizationSetIamPolicyCall<'a, C, A> where C: BorrowMut = None; + for &(find_this, param_name) in [("{+resource}", "resource")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); @@ -1088,7 +1165,7 @@ impl<'a, C, A> OrganizationSetIamPolicyCall<'a, C, A> where C: BorrowMut OrganizationGetIamPolicyCall<'a, C, A> where C: BorrowMut Result<(hyper::client::Response, Policy)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1165,20 +1243,23 @@ impl<'a, C, A> OrganizationGetIamPolicyCall<'a, C, A> where C: BorrowMut = None; + for &(find_this, param_name) in [("{+resource}", "resource")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); @@ -1360,7 +1441,7 @@ impl<'a, C, A> OrganizationGetIamPolicyCall<'a, C, A> where C: BorrowMut OrganizationTestIamPermissionCall<'a, C, A> where C: BorrowMut Result<(hyper::client::Response, TestIamPermissionsResponse)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1437,20 +1519,23 @@ impl<'a, C, A> OrganizationTestIamPermissionCall<'a, C, A> where C: BorrowMut = None; + for &(find_this, param_name) in [("{+resource}", "resource")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); @@ -1632,7 +1717,7 @@ impl<'a, C, A> OrganizationTestIamPermissionCall<'a, C, A> where C: BorrowMut OrganizationTestIamPermissionCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { hub: &'a CloudResourceManager, - _organization_id: String, + _name: String, + _organization_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -1679,6 +1766,7 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Organization)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1688,9 +1776,12 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "cloudresourcemanager.organizations.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("organizationId", self._organization_id.to_string())); - for &field in ["alt", "organizationId"].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("name", self._name.to_string())); + if let Some(value) = self._organization_id { + params.push(("organizationId", value.to_string())); + } + for &field in ["alt", "name", "organizationId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1702,24 +1793,27 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://cloudresourcemanager.googleapis.com/v1beta1/organizations/{organizationId}".to_string(); + let mut url = "https://cloudresourcemanager.googleapis.com/v1beta1/{+name}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{organizationId}", "organizationId")].iter() { - let mut replace_with: Option<&str> = None; + for &(find_this, param_name) in [("{+name}", "name")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["organizationId"].iter() { + for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -1805,14 +1899,21 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, } - /// The id of the Organization resource to fetch. + /// The resource name of the Organization to fetch. Its format is "organizations/[organization_id]". For example, "organizations/1234". /// - /// Sets the *organization id* path property to the given value. + /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. + pub fn name(mut self, new_value: &str) -> OrganizationGetCall<'a, C, A> { + self._name = new_value.to_string(); + self + } + /// The id of the Organization resource to fetch. This field is deprecated and will be removed in v1. Use name instead. + /// + /// Sets the *organization id* query property to the given value. pub fn organization_id(mut self, new_value: &str) -> OrganizationGetCall<'a, C, A> { - self._organization_id = new_value.to_string(); + self._organization_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -1873,7 +1974,7 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, } -/// Updates an Organization resource identified by the specified `organization_id`. +/// Updates an Organization resource identified by the specified resource name. /// /// A builder for the *update* method supported by a *organization* resource. /// It is not used directly, but through a `OrganizationMethods` instance. @@ -1905,7 +2006,7 @@ impl<'a, C, A> OrganizationGetCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.organizations().update(req, "organizationId") +/// let result = hub.organizations().update(req, "name") /// .doit(); /// # } /// ``` @@ -1914,7 +2015,7 @@ pub struct OrganizationUpdateCall<'a, C, A> hub: &'a CloudResourceManager, _request: Organization, - _organization_id: String, + _name: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -1927,6 +2028,7 @@ impl<'a, C, A> OrganizationUpdateCall<'a, C, A> where C: BorrowMut Result<(hyper::client::Response, Organization)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1937,8 +2039,8 @@ impl<'a, C, A> OrganizationUpdateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("organizationId", self._organization_id.to_string())); - for &field in ["alt", "organizationId"].iter() { + params.push(("name", self._name.to_string())); + for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1950,24 +2052,27 @@ impl<'a, C, A> OrganizationUpdateCall<'a, C, A> where C: BorrowMut = None; + for &(find_this, param_name) in [("{+name}", "name")].iter() { + let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { - replace_with = Some(value); + replace_with = value.to_string(); break; } } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["organizationId"].iter() { + for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -2077,14 +2182,14 @@ impl<'a, C, A> OrganizationUpdateCall<'a, C, A> where C: BorrowMut OrganizationUpdateCall<'a, C, A> { - self._organization_id = new_value.to_string(); + pub fn name(mut self, new_value: &str) -> OrganizationUpdateCall<'a, C, A> { + self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -2172,9 +2277,9 @@ impl<'a, C, A> OrganizationUpdateCall<'a, C, A> where C: BorrowMut ProjectTestIamPermissionCall<'a, C, A> where C: BorrowMut ProjectCreateCall<'a, C, A> where C: BorrowMut, A: } -/// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project currently supports only `user:{emailid}` and `serviceAccount:{emailid}` members in a `Binding` of a `Policy`. + To be added as an `owner`, a user must be invited via Cloud Platform console and must accept the invitation. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. +/// Sets the IAM access control policy for the specified Project. Replaces any existing policy. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted only to `user` and `serviceAccount`. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + Members cannot be added to more than one role in the same policy. + There must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. /// /// A builder for the *setIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -3685,6 +3790,278 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa } +/// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project. +/// +/// A builder for the *getAncestry* 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_cloudresourcemanager1_beta1 as cloudresourcemanager1_beta1; +/// use cloudresourcemanager1_beta1::GetAncestryRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use cloudresourcemanager1_beta1::CloudResourceManager; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = CloudResourceManager::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 = GetAncestryRequest::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().get_ancestry(req, "projectId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectGetAncestryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a CloudResourceManager, + _request: GetAncestryRequest, + _project_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectGetAncestryCall<'a, C, A> {} + +impl<'a, C, A> ProjectGetAncestryCall<'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, GetAncestryResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "cloudresourcemanager.projects.getAncestry", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + 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://cloudresourcemanager.googleapis.com/v1beta1/projects/{projectId}:getAncestry".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: GetAncestryRequest) -> ProjectGetAncestryCall<'a, C, A> { + self._request = new_value; + self + } + /// The Project ID (for example, `my-project-123`). 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) -> ProjectGetAncestryCall<'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) -> ProjectGetAncestryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectGetAncestryCall<'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) -> ProjectGetAncestryCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project. /// /// A builder for the *update* method supported by a *project* resource. @@ -4229,7 +4606,7 @@ impl<'a, C, A> ProjectGetIamPolicyCall<'a, C, A> where C: BorrowMut ProjectDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().list() -/// .page_token("justo") -/// .page_size(-21) -/// .filter("et") +/// .page_token("et") +/// .page_size(-17) +/// .filter("diam") /// .doit(); /// # } /// ``` diff --git a/gen/cloudtrace1-cli/Cargo.toml b/gen/cloudtrace1-cli/Cargo.toml index 280af0b412..01b6cbfe49 100644 --- a/gen/cloudtrace1-cli/Cargo.toml +++ b/gen/cloudtrace1-cli/Cargo.toml @@ -4,9 +4,9 @@ [package] name = "google-cloudtrace1-cli" -version = "0.3.6+20151207" +version = "0.3.6+20160518" authors = ["Sebastian Thiel "] -description = "A complete library to interact with cloudtrace (protocol v1)" +description = "A complete library to interact with Cloud Trace (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudtrace1-cli" homepage = "https://cloud.google.com/tools/cloud-trace" documentation = "http://byron.github.io/google-apis-rs/google_cloudtrace1_cli" @@ -19,10 +19,10 @@ name = "cloudtrace1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-cloudtrace1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-cloudtrace1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-cloudtrace1] diff --git a/gen/cloudtrace1-cli/README.md b/gen/cloudtrace1-cli/README.md index 9fb55fc8d0..db5341173e 100644 --- a/gen/cloudtrace1-cli/README.md +++ b/gen/cloudtrace1-cli/README.md @@ -3,14 +3,14 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/cli/README.md.mako' DO NOT EDIT ! --> -The `cloudtrace1` command-line interface *(CLI)* allows to use most features of the *Google cloudtrace* service from the comfort of your terminal. +The `cloudtrace1` command-line interface *(CLI)* allows to use most features of the *Google Cloud Trace* 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 *cloudtrace* API can be found at the +Everything else about the *Cloud Trace* API can be found at the [official documentation site](https://cloud.google.com/tools/cloud-trace). # Downloads @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *cloudtrace* API at revision *20151207*. 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 *0.3.6*. ```bash cloudtrace1 [options] diff --git a/gen/cloudtrace1-cli/mkdocs.yml b/gen/cloudtrace1-cli/mkdocs.yml index d72edda502..b0de8b0438 100644 --- a/gen/cloudtrace1-cli/mkdocs.yml +++ b/gen/cloudtrace1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudtrace v0.3.6+20151207 +site_name: Cloud Trace v0.3.6+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 8acf2958b5..8c14254b4d 100644 --- a/gen/cloudtrace1-cli/src/main.rs +++ b/gen/cloudtrace1-cli/src/main.rs @@ -38,7 +38,7 @@ enum DoitError { struct Engine<'n> { opt: ArgMatches<'n>, - hub: api::Cloudtrace>, + hub: api::CloudTrace>, gp: Vec<&'static str>, gpm: Vec<(&'static str, &'static str)>, } @@ -331,7 +331,7 @@ impl<'n> Engine<'n> { }; let engine = Engine { opt: opt, - hub: api::Cloudtrace::new(client, auth), + hub: api::CloudTrace::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"), @@ -365,7 +365,7 @@ fn main() { let arg_data = [ ("projects", "methods: 'patch-traces', 'traces-get' and 'traces-list'", vec![ ("patch-traces", - Some(r##"Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created."##), + Some(r##"Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created."##), "Details at http://byron.github.io/google-apis-rs/google_cloudtrace1_cli/projects_patch-traces", vec![ (Some(r##"project-id"##), @@ -448,8 +448,8 @@ fn main() { let mut app = App::new("cloudtrace1") .author("Sebastian Thiel ") - .version("0.3.6+20151207") - .about("The Cloud Trace API allows you to send traces to and retrieve traces from Google Cloud Trace.") + .version("0.3.6+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") .long("scope") diff --git a/gen/cloudtrace1/Cargo.toml b/gen/cloudtrace1/Cargo.toml index a56492ab0b..f699bc2593 100644 --- a/gen/cloudtrace1/Cargo.toml +++ b/gen/cloudtrace1/Cargo.toml @@ -4,9 +4,9 @@ [package] name = "google-cloudtrace1" -version = "0.1.14+20151207" +version = "0.1.14+20160518" authors = ["Sebastian Thiel "] -description = "A complete library to interact with cloudtrace (protocol v1)" +description = "A complete library to interact with Cloud Trace (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/cloudtrace1" homepage = "https://cloud.google.com/tools/cloud-trace" documentation = "http://byron.github.io/google-apis-rs/google_cloudtrace1" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/cloudtrace1/README.md b/gen/cloudtrace1/README.md index 38c987282c..51a59ad432 100644 --- a/gen/cloudtrace1/README.md +++ b/gen/cloudtrace1/README.md @@ -3,15 +3,15 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/api/README.md.mako' DO NOT EDIT ! --> -The `google-cloudtrace1` library allows access to all features of the *Google cloudtrace* service. +The `google-cloudtrace1` library allows access to all features of the *Google Cloud Trace* service. -This documentation was generated from *cloudtrace* crate version *0.1.14+20151207*, where *20151207* is the exact revision of the *cloudtrace:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Cloud Trace* crate version *0.1.14+20160518*, where *20160518* is the exact revision of the *cloudtrace:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -Everything else about the *cloudtrace* *v1* API can be found at the +Everything else about the *Cloud Trace* *v1* API can be found at the [official documentation site](https://cloud.google.com/tools/cloud-trace). # Features -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.Cloudtrace.html) ... +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.CloudTrace.html) ... * projects * [*patch traces*](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.ProjectPatchTraceCall.html), [*traces get*](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.ProjectTraceGetCall.html) and [*traces list*](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.ProjectTraceListCall.html) @@ -23,7 +23,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g The API is structured into the following primary items: -* **[Hub](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.Cloudtrace.html)** +* **[Hub](http://byron.github.io/google-apis-rs/google_cloudtrace1/struct.CloudTrace.html)** * a central object to maintain state and allow accessing all *Activities* * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_cloudtrace1/trait.MethodsBuilder.html) which in turn allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_cloudtrace1/trait.CallBuilder.html) @@ -75,7 +75,7 @@ extern crate google_cloudtrace1 as cloudtrace1; use cloudtrace1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use cloudtrace1::Cloudtrace; +use cloudtrace1::CloudTrace; // Get an ApplicationSecret instance by some means. It contains the `client_id` and // `client_secret`, among other things. @@ -88,7 +88,7 @@ let secret: ApplicationSecret = Default::default(); let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, hyper::Client::new(), ::default(), None); -let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +let mut hub = CloudTrace::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 ! diff --git a/gen/cloudtrace1/src/lib.rs b/gen/cloudtrace1/src/lib.rs index e08355747e..a172f0839c 100644 --- a/gen/cloudtrace1/src/lib.rs +++ b/gen/cloudtrace1/src/lib.rs @@ -2,14 +2,14 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *cloudtrace* crate version *0.1.14+20151207*, where *20151207* is the exact revision of the *cloudtrace:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Cloud Trace* crate version *0.1.14+20160518*, where *20160518* is the exact revision of the *cloudtrace:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! -//! Everything else about the *cloudtrace* *v1* API can be found at the +//! Everything else about the *Cloud Trace* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/tools/cloud-trace). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudtrace1). //! # Features //! -//! Handle the following *Resources* with ease from the central [hub](struct.Cloudtrace.html) ... +//! Handle the following *Resources* with ease from the central [hub](struct.CloudTrace.html) ... //! //! * projects //! * [*patch traces*](struct.ProjectPatchTraceCall.html), [*traces get*](struct.ProjectTraceGetCall.html) and [*traces list*](struct.ProjectTraceListCall.html) @@ -23,7 +23,7 @@ //! //! The API is structured into the following primary items: //! -//! * **[Hub](struct.Cloudtrace.html)** +//! * **[Hub](struct.CloudTrace.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) @@ -76,7 +76,7 @@ //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use cloudtrace1::Cloudtrace; +//! use cloudtrace1::CloudTrace; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. @@ -89,7 +89,7 @@ //! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, //! hyper::Client::new(), //! ::default(), None); -//! let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +//! let mut hub = CloudTrace::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 ! diff --git a/gen/cloudtrace1/src/lib.rs.in b/gen/cloudtrace1/src/lib.rs.in index 657fd398a1..ed5679bf33 100644 --- a/gen/cloudtrace1/src/lib.rs.in +++ b/gen/cloudtrace1/src/lib.rs.in @@ -38,19 +38,27 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, pub enum Scope { /// View and manage your data across Google Cloud Platform services CloudPlatform, + + /// Write Trace data for a project or application + TraceAppend, + + /// Read Trace data for a project or application + TraceReadonly, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", + Scope::TraceAppend => "https://www.googleapis.com/auth/trace.append", + Scope::TraceReadonly => "https://www.googleapis.com/auth/trace.readonly", } } } impl Default for Scope { fn default() -> Scope { - Scope::CloudPlatform + Scope::TraceReadonly } } @@ -60,7 +68,7 @@ impl Default for Scope { // HUB ### // ###### -/// Central instance to access all Cloudtrace related resource activities +/// Central instance to access all CloudTrace related resource activities /// /// # Examples /// @@ -74,7 +82,7 @@ impl Default for Scope { /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use cloudtrace1::Cloudtrace; +/// use cloudtrace1::CloudTrace; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. @@ -87,7 +95,7 @@ impl Default for Scope { /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +/// let mut hub = CloudTrace::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 ! @@ -112,19 +120,19 @@ impl Default for Scope { /// } /// # } /// ``` -pub struct Cloudtrace { +pub struct CloudTrace { client: RefCell, auth: RefCell, _user_agent: String, } -impl<'a, C, A> Hub for Cloudtrace {} +impl<'a, C, A> Hub for CloudTrace {} -impl<'a, C, A> Cloudtrace +impl<'a, C, A> CloudTrace where C: BorrowMut, A: oauth2::GetToken { - pub fn new(client: C, authenticator: A) -> Cloudtrace { - Cloudtrace { + pub fn new(client: C, authenticator: A) -> CloudTrace { + CloudTrace { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/0.1.14".to_string(), @@ -200,7 +208,7 @@ pub struct TraceSpan { /// ID of the parent span, if any. Optional. #[serde(rename="parentSpanId")] pub parent_span_id: Option, - /// Name of the trace. The trace name is sanitized and displayed in the Cloud Trace tool in the Google Developers Console. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans. + /// Name of the trace. The trace name is sanitized and displayed in the Stackdriver Trace tool in the {% dynamic print site_values.console_name %}. The name may be a method name or some other per-call site name. For the same executable and the same call point, a best practice is to use a consistent name, which makes it easier to correlate cross-trace spans. pub name: Option, /// Start time of the span in nanoseconds from the UNIX epoch. #[serde(rename="startTime")] @@ -263,7 +271,7 @@ impl ResponseResult for Trace {} // ################# /// A builder providing access to all methods supported on *project* resources. -/// It is not used directly, but through the `Cloudtrace` hub. +/// It is not used directly, but through the `CloudTrace` hub. /// /// # Example /// @@ -277,13 +285,13 @@ impl ResponseResult for Trace {} /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use cloudtrace1::Cloudtrace; +/// use cloudtrace1::CloudTrace; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +/// let mut hub = CloudTrace::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `patch_traces(...)`, `traces_get(...)` and `traces_list(...)` /// // to build up your call. @@ -293,7 +301,7 @@ impl ResponseResult for Trace {} pub struct ProjectMethods<'a, C, A> where C: 'a, A: 'a { - hub: &'a Cloudtrace, + hub: &'a CloudTrace, } impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} @@ -321,7 +329,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created. + /// Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created. /// /// # Arguments /// @@ -387,13 +395,13 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudtrace1::Cloudtrace; +/// # use cloudtrace1::CloudTrace; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +/// # let mut hub = CloudTrace::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 ! @@ -404,7 +412,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { pub struct ProjectTraceGetCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Cloudtrace, + hub: &'a CloudTrace, _project_id: String, _trace_id: String, _delegate: Option<&'a mut Delegate>, @@ -445,7 +453,7 @@ impl<'a, C, A> ProjectTraceGetCall<'a, C, A> where C: BorrowMut, let mut url = "https://cloudtrace.googleapis.com/v1/projects/{projectId}/traces/{traceId}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + self._scopes.insert(Scope::TraceReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{projectId}", "projectId"), ("{traceId}", "traceId")].iter() { @@ -608,7 +616,7 @@ impl<'a, C, A> ProjectTraceGetCall<'a, C, A> where C: BorrowMut, /// 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`. + /// `Scope::TraceReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -624,7 +632,7 @@ impl<'a, C, A> ProjectTraceGetCall<'a, C, A> where C: BorrowMut, } -/// Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created. +/// Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created. /// /// A builder for the *patchTraces* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -641,13 +649,13 @@ impl<'a, C, A> ProjectTraceGetCall<'a, C, A> where C: BorrowMut, /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudtrace1::Cloudtrace; +/// # use cloudtrace1::CloudTrace; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +/// # let mut hub = CloudTrace::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 ! @@ -663,7 +671,7 @@ impl<'a, C, A> ProjectTraceGetCall<'a, C, A> where C: BorrowMut, pub struct ProjectPatchTraceCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Cloudtrace, + hub: &'a CloudTrace, _request: Traces, _project_id: String, _delegate: Option<&'a mut Delegate>, @@ -912,13 +920,13 @@ impl<'a, C, A> ProjectPatchTraceCall<'a, C, A> where C: BorrowMut /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudtrace1::Cloudtrace; +/// # use cloudtrace1::CloudTrace; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Cloudtrace::new(hyper::Client::new(), auth); +/// # let mut hub = CloudTrace::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 ! @@ -936,7 +944,7 @@ impl<'a, C, A> ProjectPatchTraceCall<'a, C, A> where C: BorrowMut pub struct ProjectTraceListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Cloudtrace, + hub: &'a CloudTrace, _project_id: String, _view: Option, _start_time: Option, @@ -1003,7 +1011,7 @@ impl<'a, C, A> ProjectTraceListCall<'a, C, A> where C: BorrowMut, let mut url = "https://cloudtrace.googleapis.com/v1/projects/{projectId}/traces".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + self._scopes.insert(Scope::TraceReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { @@ -1205,7 +1213,7 @@ impl<'a, C, A> ProjectTraceListCall<'a, C, A> where C: BorrowMut, /// 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`. + /// `Scope::TraceReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. diff --git a/gen/clouduseraccountsvm_beta-cli/Cargo.toml b/gen/clouduseraccountsvm_beta-cli/Cargo.toml index 7f2ff00125..ac187b0c17 100644 --- a/gen/clouduseraccountsvm_beta-cli/Cargo.toml +++ b/gen/clouduseraccountsvm_beta-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "clouduseraccountsvm-beta" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-clouduseraccountsvm_beta/ with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-clouduseraccountsvm_beta/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-clouduseraccountsvm_beta] diff --git a/gen/clouduseraccountsvm_beta/Cargo.toml b/gen/clouduseraccountsvm_beta/Cargo.toml index cb00ffdea8..5a49fc6282 100644 --- a/gen/clouduseraccountsvm_beta/Cargo.toml +++ b/gen/clouduseraccountsvm_beta/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/compute1-cli/Cargo.toml b/gen/compute1-cli/Cargo.toml index b2c61396bc..6fa6de54f3 100644 --- a/gen/compute1-cli/Cargo.toml +++ b/gen/compute1-cli/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-compute1-cli" -version = "0.3.6+20160328" +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" @@ -19,10 +19,10 @@ name = "compute1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ 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.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-compute1] diff --git a/gen/compute1-cli/README.md b/gen/compute1-cli/README.md index 90cca78838..ae54dc7a6e 100644 --- a/gen/compute1-cli/README.md +++ b/gen/compute1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *compute* API at revision *20160328*. The CLI is at version *0.3.6*. +This documentation was generated from the *compute* API at revision *20160908*. The CLI is at version *0.3.6*. ```bash compute1 [options] @@ -92,6 +92,13 @@ compute1 [options] 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 ] @@ -110,6 +117,7 @@ compute1 [options] 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 @@ -158,6 +166,7 @@ compute1 [options] 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 ] @@ -183,6 +192,16 @@ compute1 [options] 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 ] @@ -234,6 +253,14 @@ compute1 [options] 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 ] @@ -244,6 +271,7 @@ compute1 [options] 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 ] diff --git a/gen/compute1-cli/mkdocs.yml b/gen/compute1-cli/mkdocs.yml index d89c2eb325..cd00abf6dc 100644 --- a/gen/compute1-cli/mkdocs.yml +++ b/gen/compute1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: compute v0.3.6+20160328 +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 @@ -63,6 +63,12 @@ pages: - ['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'] @@ -78,6 +84,7 @@ pages: - ['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'] @@ -122,6 +129,7 @@ pages: - ['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'] @@ -141,6 +149,15 @@ pages: - ['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'] @@ -184,6 +201,13 @@ pages: - ['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'] @@ -192,6 +216,7 @@ pages: - ['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'] diff --git a/gen/compute1-cli/src/main.rs b/gen/compute1-cli/src/main.rs index e8c4111e3c..10071e9a6d 100644 --- a/gen/compute1-cli/src/main.rs +++ b/gen/compute1-cli/src/main.rs @@ -1102,11 +1102,15 @@ impl<'n> Engine<'n> { 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 })), @@ -1116,7 +1120,7 @@ impl<'n> Engine<'n> { "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", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "timeout-sec"]); + 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 } @@ -1261,11 +1265,15 @@ impl<'n> Engine<'n> { 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 })), @@ -1275,7 +1283,7 @@ impl<'n> Engine<'n> { "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", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "timeout-sec"]); + 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 } @@ -1358,11 +1366,15 @@ impl<'n> Engine<'n> { 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 })), @@ -1372,7 +1384,7 @@ impl<'n> Engine<'n> { "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", "fingerprint", "health-checks", "id", "kind", "name", "port", "port-name", "protocol", "region", "self-link", "timeout-sec"]); + 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 } @@ -1695,9 +1707,13 @@ impl<'n> Engine<'n> { 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 })), @@ -1707,7 +1723,7 @@ impl<'n> Engine<'n> { "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", "self-link", "source-disk", "source-disk-id", "status", "storage-bytes", "storage-bytes-status"]); + 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 } @@ -1894,27 +1910,33 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { - "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "kind" => Some(("kind", 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 })), - "size-gb" => Some(("sizeGb", 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 })), - "source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "last-attach-timestamp" => Some(("lastAttachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "options" => Some(("options", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "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 })), - "zone" => Some(("zone", 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 })), "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", "id", "kind", "last-attach-timestamp", "last-detach-timestamp", "licenses", "name", "options", "self-link", "size-gb", "source-image", "source-image-id", "source-snapshot", "source-snapshot-id", "status", "type", "users", "zone"]); + 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 } @@ -3807,6 +3829,532 @@ impl<'n> Engine<'n> { } } + 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("")); @@ -4914,6 +5462,58 @@ impl<'n> Engine<'n> { } } + 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> { @@ -4939,27 +5539,32 @@ impl<'n> Engine<'n> { 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 })), - "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 })), "licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), - "source-type" => Some(("sourceType", 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 })), + "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", "id", "kind", "licenses", "name", "obsolete", "raw-disk", "replacement", "self-link", "sha1-checksum", "source", "source-disk", "source-disk-id", "source-type", "state", "status"]); + 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 } @@ -5446,6 +6051,7 @@ impl<'n> Engine<'n> { "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 })), @@ -5461,7 +6067,7 @@ impl<'n> Engine<'n> { "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", "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"]); + 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 } @@ -7054,11 +7660,15 @@ impl<'n> Engine<'n> { 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.disk-name" => Some(("initializeParams.diskName", 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 })), @@ -7069,7 +7679,7 @@ impl<'n> Engine<'n> { "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-name", "disk-size-gb", "disk-type", "index", "initialize-params", "interface", "kind", "licenses", "mode", "source", "source-image", "type"]); + 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 } @@ -8059,6 +8669,90 @@ impl<'n> Engine<'n> { } } + 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("")); @@ -9267,6 +9961,658 @@ impl<'n> Engine<'n> { } } + 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("")); @@ -12203,6 +13549,520 @@ impl<'n> Engine<'n> { } } + 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("")); @@ -12722,6 +14582,91 @@ impl<'n> Engine<'n> { } } + 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("")); @@ -13252,20 +15197,22 @@ impl<'n> Engine<'n> { "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 })), - "target-vpn-gateway" => Some(("targetVpnGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "shared-secret" => Some(("sharedSecret", 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 })), - "name" => Some(("name", 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", "self-link", "shared-secret", "shared-secret-hash", "status", "target-vpn-gateway"]); + 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 } @@ -13906,6 +15853,32 @@ impl<'n> Engine<'n> { } } }, + ("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)) => { @@ -13969,6 +15942,9 @@ impl<'n> Engine<'n> { ("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); }, @@ -14133,6 +16109,9 @@ impl<'n> Engine<'n> { ("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); }, @@ -14244,6 +16223,41 @@ impl<'n> Engine<'n> { } } }, + ("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)) => { @@ -14437,6 +16451,35 @@ impl<'n> Engine<'n> { } } }, + ("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)) => { @@ -14471,6 +16514,9 @@ impl<'n> Engine<'n> { ("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); }, @@ -16263,6 +18309,183 @@ fn main() { ]), ]), + ("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."##), @@ -16617,7 +18840,7 @@ fn main() { ]), ]), - ("images", "methods: 'delete', 'deprecate', 'get', 'insert' and 'list'", vec![ + ("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", @@ -16704,6 +18927,34 @@ fn main() { 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"##), @@ -16739,9 +18990,7 @@ fn main() { 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 7. 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. - - See Accessing images for more information."##), + 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"##), @@ -17617,7 +19866,7 @@ fn main() { ]), ]), - ("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' and 'stop'", vec![ + ("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", @@ -18244,6 +20493,46 @@ fn main() { 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"##), @@ -18796,6 +21085,315 @@ fn main() { ]), ]), + ("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."##), @@ -19155,7 +21753,7 @@ fn main() { Some(false)), ]), ("get", - Some(r##"Returns the specified subnetwork. Get a list of available subnetworks by making a list() request."##), + 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"##), @@ -20122,6 +22720,217 @@ fn main() { ]), ]), + ("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."##), @@ -20277,7 +23086,7 @@ fn main() { ]), ]), - ("url-maps", "methods: 'delete', 'get', 'insert', 'list', 'patch', 'update' and 'validate'", vec![ + ("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", @@ -20356,6 +23165,40 @@ fn main() { 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"##), @@ -20793,8 +23636,8 @@ fn main() { let mut app = App::new("compute1") .author("Sebastian Thiel ") - .version("0.3.6+20160328") - .about("API for the Google Compute Engine service.") + .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") diff --git a/gen/compute1/Cargo.toml b/gen/compute1/Cargo.toml index 96f16d4ece..baeb1ce150 100644 --- a/gen/compute1/Cargo.toml +++ b/gen/compute1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-compute1" -version = "0.1.14+20160328" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/compute1/README.md b/gen/compute1/README.md index db5f6e37d7..8ab7ce8479 100644 --- a/gen/compute1/README.md +++ b/gen/compute1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-compute1` library allows access to all features of the *Google compute* service. -This documentation was generated from *compute* crate version *0.1.14+20160328*, where *20160328* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *compute* crate version *0.1.14+20160908*, where *20160908* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *compute* *v1* API can be found at the [official documentation site](https://developers.google.com/compute/docs/reference/latest/). @@ -33,12 +33,14 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*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), [*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) + * [*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) @@ -46,7 +48,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [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) and [*stop*](http://byron.github.io/google-apis-rs/google_compute1/struct.InstanceStopCall.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) @@ -59,6 +61,8 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*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) @@ -75,10 +79,12 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*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), [*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) + * [*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 @@ -123,7 +129,7 @@ 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.backend_services().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() @@ -136,29 +142,35 @@ 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.instances().set_tags(...).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.instances().set_machine_type(...).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.global_operations().get(...).doit() -let r = hub.addresses().delete(...).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() @@ -175,13 +187,13 @@ 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.subnetworks().insert(...).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.images().delete(...).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() @@ -189,6 +201,7 @@ 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() @@ -207,17 +220,25 @@ 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.instances().attach_disk(...).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() diff --git a/gen/compute1/src/lib.rs b/gen/compute1/src/lib.rs index 68375214dc..abfbd9a4f4 100644 --- a/gen/compute1/src/lib.rs +++ b/gen/compute1/src/lib.rs @@ -2,7 +2,7 @@ // 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.14+20160328*, where *20160328* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *compute* crate version *0.1.14+20160908*, where *20160908* is the exact revision of the *compute:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *compute* *v1* API can be found at the //! [official documentation site](https://developers.google.com/compute/docs/reference/latest/). @@ -31,12 +31,14 @@ //! * [*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), [*insert*](struct.ImageInsertCall.html) and [*list*](struct.ImageListCall.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) @@ -44,7 +46,7 @@ //! * [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) and [*stop*](struct.InstanceStopCall.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) @@ -57,6 +59,8 @@ //! * [*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) @@ -73,10 +77,12 @@ //! * [*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), [*list*](struct.UrlMapListCall.html), [*patch*](struct.UrlMapPatchCall.html), [*update*](struct.UrlMapUpdateCall.html) and [*validate*](struct.UrlMapValidateCall.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 @@ -123,7 +129,7 @@ //! let r = hub.target_https_proxies().delete(...).doit() //! let r = hub.firewalls().patch(...).doit() //! let r = hub.vpn_tunnels().delete(...).doit() -//! let r = hub.backend_services().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() @@ -136,29 +142,35 @@ //! 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.instances().set_tags(...).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.instances().set_machine_type(...).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.global_operations().get(...).doit() -//! let r = hub.addresses().delete(...).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() @@ -175,13 +187,13 @@ //! 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.subnetworks().insert(...).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.images().delete(...).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() @@ -189,6 +201,7 @@ //! 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() @@ -207,17 +220,25 @@ //! 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.instances().attach_disk(...).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() diff --git a/gen/compute1/src/lib.rs.in b/gen/compute1/src/lib.rs.in index ffb18a4754..e8ccf96c96 100644 --- a/gen/compute1/src/lib.rs.in +++ b/gen/compute1/src/lib.rs.in @@ -181,6 +181,9 @@ impl<'a, C, A> Compute 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 } } @@ -220,6 +223,9 @@ impl<'a, C, A> Compute 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 } } @@ -244,6 +250,9 @@ impl<'a, C, A> Compute 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 } } @@ -438,6 +447,46 @@ 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. @@ -482,6 +531,21 @@ pub struct VpnTunnelAggregatedList { 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 @@ -624,6 +688,39 @@ 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. @@ -638,6 +735,22 @@ 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 @@ -765,16 +878,21 @@ pub struct InstanceGroupManagerActionsSummary { 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 one of these instances, it tries again until it creates the instance successfully. + /// [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 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, + /// [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 in the managed instance group that are scheduled to be restarted or are currently being restarted. - pub restarting: 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 {} @@ -872,6 +990,30 @@ pub struct PathRule { 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 @@ -889,6 +1031,9 @@ impl Part for PathRule {} 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. @@ -946,7 +1091,7 @@ pub struct SubnetworkAggregatedList { impl ResponseResult for SubnetworkAggregatedList {} -/// There is no detailed description. +/// An Instance Group Manager resource. /// /// # Activities /// @@ -973,11 +1118,11 @@ pub struct InstanceGroupManager { pub current_actions: Option, /// An optional description of this resource. Provide this property when you create the resource. pub description: Option, - /// The name of the zone where the managed instance group is located. + /// [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 target pools information. You can use this optional field for optimistic locking when you update the target pool entries. + /// [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")] @@ -1256,6 +1401,96 @@ pub struct AutoscalerAggregatedList { 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. @@ -1275,6 +1510,43 @@ 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 @@ -1291,11 +1563,11 @@ pub struct InstanceGroupsListInstances { 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 lists of instance groups. + /// [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 instance groups. The server generates this identifier. + /// [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 instance groups. The server generates this URL. + /// [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, } @@ -1377,32 +1649,198 @@ pub struct ForwardingRulesScopedList { impl Part for ForwardingRulesScopedList {} -/// Contains a list of Route resources. +/// 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*). /// -/// * [list routes](struct.RouteListCall.html) (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 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 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] Server-defined URL for this resource. + /// [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 RouteList {} +impl ResponseResult for Operation {} /// A Disk resource. @@ -1430,6 +1868,9 @@ pub struct Disk { /// - 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, @@ -1438,8 +1879,9 @@ pub struct Disk { /// [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] Any applicable publicly visible licenses. - pub licenses: 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: @@ -1459,30 +1901,41 @@ pub struct Disk { /// global/images/family/my-private-family #[serde(rename="sourceImage")] pub source_image: 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, - /// [Output Only] Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - pub users: 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, - /// 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#disk for disks. - pub kind: 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, @@ -1515,60 +1968,89 @@ impl NestedType for VpnTunnelsScopedListWarningData {} impl Part for VpnTunnelsScopedListWarningData {} -/// A TargetHttpsProxy resource. This resource defines an HTTPS proxy. +/// 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*). /// -/// * [get target https proxies](struct.TargetHttpsProxyGetCall.html) (response) -/// * [insert target https proxies](struct.TargetHttpsProxyInsertCall.html) (request) +/// * [list target http proxies](struct.TargetHttpProxyListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct TargetHttpsProxy { - /// [Output Only] Type of resource. Always compute#targetHttpsProxy for target HTTPS proxies. +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, - /// 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. + /// [Output Only] Server-defined URL for this 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 {} +impl ResponseResult for TargetHttpProxyList {} -/// The named port. For example: . +/// There is no detailed description. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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 NamedPort { - /// The name for this named port. The name must be 1-63 characters long, and comply with RFC1035. +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, - /// The port number, which can be a value between 1 and 65535. - pub port: 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 Part for NamedPort {} +impl RequestValue for InstanceGroup {} +impl Resource for InstanceGroup {} +impl ResponseResult for InstanceGroup {} /// Represents a Network resource. Read Networks and Firewalls for more information. @@ -1657,7 +2139,7 @@ impl Resource for Zone {} impl ResponseResult for Zone {} -/// An access configuration attached to an instance's network interface. +/// An access configuration attached to an instance's network interface. Only one access config per instance is supported. /// /// # Activities /// @@ -1683,77 +2165,71 @@ pub struct AccessConfig { impl RequestValue for AccessConfig {} -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } +/// 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 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, +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 NestedType for SubnetworksScopedListWarningData {} -impl Part for SubnetworksScopedListWarningData {} +impl Part for CustomerEncryptionKey {} -/// An HttpHealthCheck resource. This resource defines a template for how individual instances should be checked for health, via HTTP. +/// 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*). /// -/// * [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) +/// * [list routers](struct.RouterListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HttpHealthCheck { - /// [Output Only] Type of the resource. Always compute#httpHealthCheck for HTTP health checks. +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, - /// 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 {} +impl ResponseResult for RouterList {} /// The location in Cloud Storage and naming method of the daily usage report. Contains bucket_name and report_name prefix. @@ -1840,7 +2316,7 @@ impl ResponseResult for SubnetworkList {} /// #[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.8. + /// 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. /// @@ -1917,6 +2393,34 @@ 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 @@ -1964,21 +2468,18 @@ impl NestedType for OperationsScopedListWarning {} impl Part for OperationsScopedListWarning {} -/// [Output Only] Metadata about this warning in key: value format. For example: -/// "data": [ { "key": "scope", "value": "zones/us-east1-d" } +/// 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 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, +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 NestedType for AutoscalersScopedListWarningData {} -impl Part for AutoscalersScopedListWarningData {} +impl Part for ConnectionDraining {} /// There is no detailed description. @@ -2086,6 +2587,34 @@ pub struct InstanceGroupManagerAggregatedList { 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 @@ -2250,16 +2779,16 @@ impl NestedType for AutoscalersScopedListWarning {} impl Part for AutoscalersScopedListWarning {} -/// The list of rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection. +/// 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 that is allowed for this rule. 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. + /// 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 which are allowed. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, connections through any port are allowed + /// 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>, @@ -2476,6 +3005,17 @@ impl ResponseResult for HttpHealthCheckList {} /// #[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. @@ -2504,13 +3044,80 @@ pub struct AttachedDisk { /// 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. + /// 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. @@ -2520,7 +3127,7 @@ 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 target_size value is decreased. + /// - 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. @@ -2620,6 +3227,25 @@ pub struct TargetPoolAggregatedList { 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 @@ -2642,7 +3268,7 @@ pub struct Subnetwork { /// [Output Only] The gateway address for default routes to reach destination addresses outside this subnetwork. #[serde(rename="gatewayAddress")] pub gateway_address: Option, - /// [Output Only] URL of the region where the Subnetwork resides. + /// 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, @@ -2666,183 +3292,50 @@ impl Resource for Subnetwork {} impl ResponseResult for Subnetwork {} -/// An Operation resource, used to manage asynchronous API requests. +/// 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*). /// -/// * [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) -/// * [delete backend services](struct.BackendServiceDeleteCall.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) -/// * [delete https health checks](struct.HttpsHealthCheckDeleteCall.html) (response) -/// * [insert autoscalers](struct.AutoscalerInsertCall.html) (response) -/// * [insert instance groups](struct.InstanceGroupInsertCall.html) (response) -/// * [set tags instances](struct.InstanceSetTagCall.html) (response) -/// * [delete instances instance group managers](struct.InstanceGroupManagerDeleteInstanceCall.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) -/// * [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) -/// * [set machine type instances](struct.InstanceSetMachineTypeCall.html) (response) -/// * [insert url maps](struct.UrlMapInsertCall.html) (response) -/// * [add access config instances](struct.InstanceAddAccessConfigCall.html) (response) -/// * [insert addresses](struct.AddresseInsertCall.html) (response) -/// * [insert global forwarding rules](struct.GlobalForwardingRuleInsertCall.html) (response) -/// * [get global operations](struct.GlobalOperationGetCall.html) (response) -/// * [delete addresses](struct.AddresseDeleteCall.html) (response) -/// * [insert target vpn gateways](struct.TargetVpnGatewayInsertCall.html) (response) -/// * [create snapshot disks](struct.DiskCreateSnapshotCall.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) -/// * [insert subnetworks](struct.SubnetworkInsertCall.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) -/// * [delete images](struct.ImageDeleteCall.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) -/// * [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 target vpn gateways](struct.TargetVpnGatewayDeleteCall.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) -/// * [reset instances](struct.InstanceResetCall.html) (response) -/// * [insert backend services](struct.BackendServiceInsertCall.html) (response) -/// * [delete http health checks](struct.HttpHealthCheckDeleteCall.html) (response) -/// * [insert http health checks](struct.HttpHealthCheckInsertCall.html) (response) -/// * [attach disk instances](struct.InstanceAttachDiskCall.html) (response) -/// * [update autoscalers](struct.AutoscalerUpdateCall.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) +/// * [list routes](struct.RouteListCall.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 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] 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. + /// [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, - /// [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 {} +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. @@ -2863,6 +3356,24 @@ pub struct InstanceGroupManagersDeleteInstancesRequest { 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 @@ -2870,55 +3381,70 @@ impl RequestValue for InstanceGroupManagersDeleteInstancesRequest {} /// 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 images](struct.ImageGetCall.html) (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) -/// * [insert images](struct.ImageInsertCall.html) (request) /// #[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, - /// [Output Only] Type of the resource. Always compute#image for images. - 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, /// An optional description of this resource. Provide this property when you create the resource. pub description: Option, - /// The parameters of the raw disk image. - #[serde(rename="rawDisk")] - pub raw_disk: Option, - /// The deprecation status associated with this image. - pub deprecated: 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 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, - /// Size of the image when restored onto a persistent disk (in GB). - #[serde(rename="diskSizeGb")] - pub disk_size_gb: 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, - /// 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, + /// 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, - /// The type of the image used to create this disk. The default and only value is RAW - #[serde(rename="sourceType")] - pub source_type: Option, } impl RequestValue for Image {} @@ -2974,6 +3500,23 @@ 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. @@ -3033,14 +3576,14 @@ impl Part for OperationsScopedListWarningData {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BackendServiceList { - /// [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. + /// [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] The unique identifier for the resource. This identifier is defined by the server. + /// [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")] @@ -3050,32 +3593,45 @@ pub struct BackendServiceList { impl ResponseResult for BackendServiceList {} -/// A list of TargetHttpProxy resources. +/// 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*). /// -/// * [list target http proxies](struct.TargetHttpProxyListCall.html) (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 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 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 this resource. + /// [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 ResponseResult for TargetHttpProxyList {} +impl RequestValue for TargetHttpsProxy {} +impl ResponseResult for TargetHttpsProxy {} /// Configuration parameters of autoscaling based on load balancing. @@ -3126,25 +3682,47 @@ impl ResponseResult for RegionList {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Backend { - /// A multiplier applied to the group's maximum servicing capacity (either UTILIZATION or RATE). Default value is 1, which means the group will serve up to 100% of its configured CPU or RPS (depending on balancingMode). A setting of 0 means the group is completely drained, offering 0% of its available CPU or RPS. Valid range is [0.0,1.0]. - #[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. - #[serde(rename="maxRate")] - pub max_rate: Option, /// 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, - /// Specifies the balancing mode for this backend. For global HTTP(S) load balancing, the default is UTILIZATION. Valid values are UTILIZATION and RATE. + /// 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, } @@ -3190,23 +3768,26 @@ pub struct OperationsScopedList { impl Part for OperationsScopedList {} -/// An informational warning that appears when the list of addresses is empty. +/// There is no detailed description. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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 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>, +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 NestedType for SubnetworksScopedListWarning {} -impl Part for SubnetworksScopedListWarning {} +impl RequestValue for InstancesStartWithEncryptionKeyRequest {} /// [Output Only] Informational warning which replaces the list of instances when the list is empty. @@ -3228,93 +3809,36 @@ impl NestedType for InstancesScopedListWarning {} impl Part for InstancesScopedListWarning {} -/// An Instance resource. +/// 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 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 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) -/// * [set scheduling instances](struct.InstanceSetSchedulingCall.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) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[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, 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 Authenticating from Google Compute Engine 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. - #[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, +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 RequestValue for Instance {} -impl Resource for Instance {} -impl ResponseResult for Instance {} +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. @@ -3443,26 +3967,23 @@ pub struct InstanceGroupAggregatedList { impl ResponseResult for InstanceGroupAggregatedList {} -/// A set of instance tags. +/// 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 tags instances](struct.InstanceSetTagCall.html) (request) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[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, +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 RequestValue for Tags {} +impl Part for RouterInterface {} /// There is no detailed description. @@ -3483,6 +4004,42 @@ pub struct UrlMapsValidateRequest { 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. @@ -3565,20 +4122,32 @@ pub struct OperationAggregatedList { impl ResponseResult for OperationAggregatedList {} -/// Array of key/value pairs. The total size of all keys and values must be less than 512 KB. +/// Contains a list of routers. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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 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, +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 NestedType for MetadataItems {} -impl Part for MetadataItems {} +impl ResponseResult for RouterAggregatedList {} /// [Output Only] Metadata about this warning in key: value format. For example: @@ -3598,6 +4167,34 @@ 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 @@ -3645,6 +4242,28 @@ pub struct InstanceGroupsListInstancesRequest { 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. @@ -3707,6 +4326,23 @@ pub struct ServiceAccount { 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 @@ -3742,58 +4378,28 @@ impl NestedType for MachineTypesScopedListWarningData {} impl Part for MachineTypesScopedListWarningData {} -/// A persistent disk snapshot resource. +/// 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 snapshots](struct.SnapshotListCall.html) (none) -/// * [create snapshot disks](struct.DiskCreateSnapshotCall.html) (request) -/// * [delete snapshots](struct.SnapshotDeleteCall.html) (none) -/// * [get snapshots](struct.SnapshotGetCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[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, - /// [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] 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, - /// [Output Only] Size of the snapshot, specified in GB. - #[serde(rename="diskSizeGb")] - pub disk_size_gb: 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, +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 RequestValue for Snapshot {} -impl Resource for Snapshot {} -impl ResponseResult for Snapshot {} +impl Part for HTTP2HealthCheck {} /// There is no detailed description. @@ -3829,41 +4435,71 @@ impl Part for DiskTypesScopedList {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BackendService { - /// [Output Only] Type of resource. Always compute#backendService for backend services. - pub kind: Option, + /// 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. + /// 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, - /// [Output Only] URL of the region where the regional backend service resides. This field is not applicable to global backend services. - pub region: Option, - /// [Output Only] The unique identifier for the resource. This identifier is defined by the server. - pub id: Option, - /// The list of backends that serve this BackendService. - pub backends: 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. + /// 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, - /// 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 BackendService {} @@ -3871,59 +4507,55 @@ impl Resource for BackendService {} impl ResponseResult for BackendService {} -/// A Machine Type resource. +/// 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*). /// -/// * [list machine types](struct.MachineTypeListCall.html) (none) -/// * [aggregated list machine types](struct.MachineTypeAggregatedListCall.html) (none) -/// * [get machine types](struct.MachineTypeGetCall.html) (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 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 struct Router { + /// [Output Only] Type of resource. Always compute#router for routers. pub kind: Option, - /// [Output Only] An optional textual description of the resource. + /// An optional description of this resource. Provide this property when you create 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] List of extended scratch disks assigned to the instance. - #[serde(rename="scratchDisks")] - pub scratch_disks: 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] The unique identifier for the resource. This identifier is defined by the server. - pub id: 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, - /// [Output Only] Name of the resource. - pub name: Option, + /// URI of the network to which this router belongs. + pub network: Option, } -impl Resource for MachineType {} -impl ResponseResult for MachineType {} +impl RequestValue for Router {} +impl Resource for Router {} +impl ResponseResult for Router {} /// Contains a list of images. @@ -3954,6 +4586,25 @@ pub struct ImageList { 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" } /// @@ -4045,14 +4696,10 @@ pub struct Firewall { pub kind: Option, /// An optional description of this resource. Provide this property when you create the resource. pub description: Option, - /// A list of instance tags which this rule applies to. One or both of sourceRanges and sourceTags may be set. - /// - /// If both properties are set, an inbound connection is allowed if the range matches the sourceRanges OR the tag of the source matches the sourceTags property. The connection does not need to match both properties. + /// 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>, - /// The IP address blocks that this rule applies to, expressed in CIDR format. One or both of sourceRanges and sourceTags may be set. - /// - /// If both properties are set, an inbound connection is allowed if the range matches the sourceRanges OR the tag of the source matches the sourceTags property. The connection does not need to match both properties. + /// 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. @@ -4060,7 +4707,7 @@ pub struct Firewall { /// 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 rules specified by this firewall. Each rule specifies a protocol and port-range tuple that describes a permitted connection. + /// 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")] @@ -4114,61 +4761,19 @@ pub struct OperationList { impl ResponseResult for OperationList {} -/// There is no detailed description. +/// The named port. For example: . /// -/// # 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) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[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. - 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 struct NamedPort { + /// The name for this named port. 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 resource type. 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, + /// The port number, which can be a value between 1 and 65535. + pub port: Option, } -impl RequestValue for InstanceGroup {} -impl Resource for InstanceGroup {} -impl ResponseResult for InstanceGroup {} +impl Part for NamedPort {} /// A TargetInstance resource. This resource defines an endpoint instance that terminates traffic of certain protocols. @@ -4245,32 +4850,28 @@ pub struct TargetInstanceAggregatedList { impl ResponseResult for TargetInstanceAggregatedList {} -/// [Output Only] A list of managed instance groups. +/// 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 instance group managers](struct.InstanceGroupManagerListCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[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, +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 ResponseResult for InstanceGroupManagerList {} +impl Part for HTTPSHealthCheck {} /// [Output Only] Metadata about this warning in key: value format. For example: @@ -4290,6 +4891,25 @@ 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 @@ -4377,20 +4997,18 @@ impl ResponseResult for MachineTypeAggregatedList {} /// 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) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UrlMapsValidateResponse { - /// no description provided - pub result: Option, +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 ResponseResult for UrlMapsValidateResponse {} +impl Part for CustomerEncryptionKeyProtectedDisk {} /// Informational warning which replaces the list of addresses when the list is empty. @@ -4496,39 +5114,44 @@ pub struct VpnTunnel { /// 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, - /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: Option, /// An optional description of this resource. Provide this property when you create the resource. pub description: Option, - /// IP address of the peer VPN gateway. - #[serde(rename="peerIp")] - pub peer_ip: Option, - /// [Output Only] URL of the region where the VPN tunnel resides. - pub region: 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>, - /// 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 status of the VPN tunnel. - pub status: Option, /// Hash of the shared secret. #[serde(rename="sharedSecretHash")] pub shared_secret_hash: 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, + /// 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, - /// [Output Only] Server-defined URL for the resource. - #[serde(rename="selfLink")] - pub self_link: 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 {} @@ -4562,6 +5185,34 @@ pub struct DeprecationStatus { 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. @@ -4620,6 +5271,29 @@ pub struct UrlMapReference { 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. @@ -4727,13 +5401,13 @@ pub struct Autoscaler { 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. + /// [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.8 or 80%. + /// 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. @@ -4801,22 +5475,33 @@ pub struct AttachedDiskInitializeParams { /// Specifies the size of the disk in base-2 GB. #[serde(rename="diskSizeGb")] pub disk_size_gb: 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, - /// The source image used to create this disk. + /// The customer-supplied encryption key of the source image. Required if the source image is protected by a customer-supplied encryption key. /// - /// To create a disk with a private image, specify the image name in the following format: + /// 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. /// - /// global/images/my-private-image + /// 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: /// - /// To create a disk with a public image, specify the image name and the project that owns the image. For example, you can use a Debian image from the debian-cloud project: + /// 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 /// - /// The vYYYYMMDD value is the image version. The fully-qualified URL also works in both examples. + /// 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 @@ -4824,7 +5509,7 @@ pub struct AttachedDiskInitializeParams { /// 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 + /// - 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, } @@ -4952,6 +5637,26 @@ 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 @@ -5036,6 +5741,8 @@ pub struct ForwardingRule { /// 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. @@ -5045,10 +5752,16 @@ pub struct ForwardingRule { /// [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 or SCTP. + /// 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, - /// Value of the reserved 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. If left empty (default value), an ephemeral IP from the same scope (global or regional) will be assigned. + /// 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. @@ -5057,6 +5770,8 @@ pub struct ForwardingRule { #[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, } @@ -5109,32 +5824,60 @@ impl Resource for License {} impl ResponseResult for License {} -/// Contains a list of disk types. +/// 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*). /// -/// * [list disk types](struct.DiskTypeListCall.html) (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 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 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] Server-defined URL for this resource. + /// [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 ResponseResult for DiskTypeList {} +impl RequestValue for HttpHealthCheck {} +impl Resource for HttpHealthCheck {} +impl ResponseResult for HttpHealthCheck {} /// There is no detailed description. @@ -5260,17 +6003,17 @@ impl RequestValue for TargetReference {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkInterface { - /// An array of configurations for this interface. Currently, ONE_TO_ONE_NAT is the only access config supported. If there are no accessConfigs specified, then this instance will have no external internet access. + /// 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>, - /// [Output Only] An optional IPV4 internal network address assigned to the instance for this network interface. + /// 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/zones/zone/subnetworks/subnetwork - /// - zones/zone/subnetworks/subnetwork + /// - 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: /// @@ -5350,6 +6093,34 @@ pub struct TargetPoolInstanceHealth { 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. @@ -5376,9 +6147,10 @@ impl Part for TargetInstancesScopedList {} /// * [update url maps](struct.UrlMapUpdateCall.html) (request) /// * [insert url maps](struct.UrlMapInsertCall.html) (request) /// * [list url maps](struct.UrlMapListCall.html) (none) -/// * [validate url maps](struct.UrlMapValidateCall.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)] @@ -5390,7 +6162,7 @@ pub struct UrlMap { /// 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 all of the test cases pass. + /// 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")] @@ -5450,6 +6222,24 @@ pub struct InstanceGroupsScopedList { 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 @@ -5478,37 +6268,62 @@ pub struct TargetPoolList { impl ResponseResult for TargetPoolList {} +/// A Machine Type resource. /// +/// # Activities /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// 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 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 canIpForward 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 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, - /// 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, + /// [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 Part for InstanceProperties {} +impl Resource for MachineType {} +impl ResponseResult for MachineType {} /// There is no detailed description. @@ -5533,23 +6348,89 @@ pub struct TargetPoolsRemoveHealthCheckRequest { impl RequestValue for TargetPoolsRemoveHealthCheckRequest {} -/// Informational warning which replaces the list of addresses when the list is empty. +/// A persistent disk snapshot resource. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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 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>, +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 NestedType for VpnTunnelsScopedListWarning {} -impl Part for VpnTunnelsScopedListWarning {} +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. @@ -5570,6 +6451,24 @@ 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 @@ -5731,6 +6630,28 @@ impl<'a, C, A> DiskMethods<'a, C, A> { } } + /// 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. @@ -5754,28 +6675,6 @@ impl<'a, C, A> DiskMethods<'a, C, A> { } } - /// 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: /// /// 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. @@ -5824,7 +6723,7 @@ impl<'a, C, A> DiskMethods<'a, C, A> { -/// A builder providing access to all methods supported on *addresse* resources. +/// A builder providing access to all methods supported on *targetSslProxy* resources. /// It is not used directly, but through the `Compute` hub. /// /// # Example @@ -5847,52 +6746,30 @@ impl<'a, C, A> DiskMethods<'a, C, A> { /// ::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(...)` +/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `set_backend_service(...)`, `set_proxy_header(...)` and `set_ssl_certificates(...)` /// // to build up your call. -/// let rb = hub.addresses(); +/// let rb = hub.target_ssl_proxies(); /// # } /// ``` -pub struct AddresseMethods<'a, C, A> +pub struct TargetSslProxyMethods<'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> MethodsBuilder for TargetSslProxyMethods<'a, C, A> {} -impl<'a, C, A> AddresseMethods<'a, C, A> { +impl<'a, C, A> TargetSslProxyMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves a list of addresses contained within the specified region. + /// Retrieves the list of TargetSslProxy 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) -> 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 { + pub fn list(&self, project: &str) -> TargetSslProxyListCall<'a, C, A> { + TargetSslProxyListCall { hub: self.hub, _project: project.to_string(), _page_token: Default::default(), @@ -5906,40 +6783,19 @@ impl<'a, C, A> AddresseMethods<'a, C, A> { /// 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. + /// Changes SslCertificates for TargetSslProxy. /// /// # 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 { + /// * `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(), - _region: region.to_string(), + _target_ssl_proxy: target_ssl_proxy.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -5948,19 +6804,97 @@ impl<'a, C, A> AddresseMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes the specified address resource. + /// 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. - /// * `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 { + /// * `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(), - _region: region.to_string(), - _address: address.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(), @@ -5993,7 +6927,7 @@ impl<'a, C, A> AddresseMethods<'a, C, A> { /// ::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(...)`, `update(...)` and `validate(...)` +/// // like `delete(...)`, `get(...)`, `insert(...)`, `invalidate_cache(...)`, `list(...)`, `patch(...)`, `update(...)` and `validate(...)` /// // to build up your call. /// let rb = hub.url_maps(); /// # } @@ -6087,6 +7021,27 @@ impl<'a, C, A> UrlMapMethods<'a, C, A> { } } + /// 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. @@ -6577,7 +7532,7 @@ impl<'a, C, A> ZoneMethods<'a, C, A> { /// ::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(...)` and `stop(...)` +/// // 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(); /// # } @@ -6706,29 +7661,6 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { } } - /// 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: /// /// Adds an access config to an instance's network interface. @@ -6821,16 +7753,18 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// 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. + /// 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 resource to stop. - pub fn stop(&self, project: &str, zone: &str, instance: &str) -> InstanceStopCall<'a, C, A> { - InstanceStopCall { + /// * `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(), @@ -6865,20 +7799,60 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Attaches a Disk resource to an instance. + /// 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. - /// * `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 { + 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(), @@ -6913,19 +7887,21 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// 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. + /// 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. - pub fn insert(&self, request: Instance, project: &str, zone: &str) -> InstanceInsertCall<'a, C, A> { - InstanceInsertCall { + /// * `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(), @@ -6956,16 +7932,18 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Performs a hard reset on the instance. + /// 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 scoping this request. - pub fn reset(&self, project: &str, zone: &str, instance: &str) -> InstanceResetCall<'a, C, A> { - InstanceResetCall { + /// * `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(), @@ -7202,7 +8180,7 @@ impl<'a, C, A> BackendServiceMethods<'a, C, A> { /// ::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(...)`, `insert(...)` and `list(...)` +/// // like `delete(...)`, `deprecate(...)`, `get(...)`, `get_from_family(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.images(); /// # } @@ -7219,9 +8197,7 @@ 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 7. 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. - /// - /// See Accessing images for more information. + /// 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 /// @@ -7239,6 +8215,44 @@ impl<'a, C, A> ImageMethods<'a, C, A> { } } + /// 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. @@ -7299,20 +8313,161 @@ impl<'a, C, A> ImageMethods<'a, C, A> { _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: /// - /// Deletes the specified image. + /// Returns the specified HealthCheck resource. Get a list of available health checks by making a list() request. /// /// # 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 { + /// * `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(), - _image: image.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(), @@ -7660,6 +8815,152 @@ impl<'a, C, A> NetworkMethods<'a, C, A> { +/// 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. /// @@ -7718,26 +9019,6 @@ impl<'a, C, A> GlobalOperationMethods<'a, C, A> { } } - /// 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(), - } - } - /// 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. @@ -7775,6 +9056,26 @@ impl<'a, C, A> GlobalOperationMethods<'a, C, A> { _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(), + } + } } @@ -8008,26 +9309,6 @@ 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: - /// - /// 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: /// /// Creates a subnetwork in the specified project using the data included in the request. @@ -8049,6 +9330,47 @@ impl<'a, C, A> SubnetworkMethods<'a, C, A> { } } + /// 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. @@ -8091,27 +9413,6 @@ impl<'a, C, A> SubnetworkMethods<'a, C, A> { _additional_params: Default::default(), } } - - /// Create a builder to help you perform the following task: - /// - /// Returns the specified subnetwork. Get a list of available subnetworks by making a 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(), - } - } } @@ -8201,6 +9502,29 @@ impl<'a, C, A> InstanceGroupMethods<'a, C, A> { } } + /// 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. @@ -8266,29 +9590,6 @@ impl<'a, C, A> InstanceGroupMethods<'a, C, A> { } } - /// 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: /// /// Sets the named ports for the specified instance group. @@ -8475,6 +9776,26 @@ 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. @@ -8541,26 +9862,6 @@ 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: /// /// Returns the specified ForwardingRule resource. @@ -9336,6 +10637,242 @@ impl<'a, C, A> HttpsHealthCheckMethods<'a, C, A> { +/// 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. /// @@ -9647,28 +11184,6 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { } } - /// 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: /// /// 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. @@ -9756,21 +11271,20 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { /// 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. + /// Retrieves a list of managed instance groups that are contained within the specified project and zone. /// /// # 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 { + pub fn list(&self, project: &str, zone: &str) -> InstanceGroupManagerListCall<'a, C, A> { + InstanceGroupManagerListCall { hub: self.hub, - _request: request, _project: project.to_string(), _zone: zone.to_string(), - _instance_group_manager: instance_group_manager.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _filter: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -9800,6 +11314,29 @@ impl<'a, C, A> InstanceGroupManagerMethods<'a, C, A> { } } + /// 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. @@ -9967,23 +11504,6 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { } } - /// 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(), - } - } - /// Create a builder to help you perform the following task: /// /// Moves an instance and its attached persistent disks from one zone to another. @@ -10021,6 +11541,23 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { _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(), + } + } } @@ -10082,6 +11619,25 @@ impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { } } + /// 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. @@ -10123,25 +11679,6 @@ impl<'a, C, A> HttpHealthCheckMethods<'a, C, A> { } } - /// 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: /// /// Creates a HttpHealthCheck resource in the specified project using the data included in the request. @@ -11046,17 +12583,15 @@ impl<'a, C, A> VpnTunnelMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves a list of VpnTunnel resources contained in the specified project and region. + /// Retrieves an aggregated list of VPN tunnels. /// /// # 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 { + pub fn aggregated_list(&self, project: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { + VpnTunnelAggregatedListCall { hub: self.hub, _project: project.to_string(), - _region: region.to_string(), _page_token: Default::default(), _max_results: Default::default(), _filter: Default::default(), @@ -11068,15 +12603,17 @@ impl<'a, C, A> VpnTunnelMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves an aggregated list of VPN tunnels. + /// Retrieves a list of VpnTunnel resources contained in the specified project and region. /// /// # Arguments /// /// * `project` - Project ID for this request. - pub fn aggregated_list(&self, project: &str) -> VpnTunnelAggregatedListCall<'a, C, A> { - VpnTunnelAggregatedListCall { + /// * `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(), @@ -11677,9 +13214,9 @@ impl<'a, C, A> DiskAggregatedListCall<'a, C, A> where C: BorrowMut DiskAggregatedListCall<'a, C, A> { @@ -11997,6 +13534,297 @@ impl<'a, C, A> DiskGetCall<'a, C, A> where C: BorrowMut, A: oauth } +/// 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. @@ -12287,297 +14115,6 @@ impl<'a, C, A> DiskResizeCall<'a, C, A> where C: BorrowMut, A: oa } -/// 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("diam") -/// .max_results(46) -/// .filter("Lorem") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 - } -} - - /// 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. @@ -13158,10 +14695,10 @@ impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut - 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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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("no") -/// .max_results(65) +/// let result = hub.target_ssl_proxies().list("project") +/// .page_token("sadipscing") +/// .max_results(53) /// .filter("eirmod") /// .doit(); /// # } /// ``` -pub struct AddresseAggregatedListCall<'a, C, A> +pub struct TargetSslProxyListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, @@ -13495,13 +14741,13 @@ pub struct AddresseAggregatedListCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for AddresseAggregatedListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for TargetSslProxyListCall<'a, C, A> {} -impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +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, AddressAggregatedList)> { + 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; @@ -13509,7 +14755,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.addresses.aggregatedList", + 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())); @@ -13534,7 +14780,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut AddresseAggregatedListCall<'a, C, A> where C: BorrowMut AddresseAggregatedListCall<'a, C, A> { + 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) -> AddresseAggregatedListCall<'a, C, A> { + 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) -> AddresseAggregatedListCall<'a, C, A> { + pub fn max_results(mut self, new_value: u32) -> TargetSslProxyListCall<'a, C, A> { self._max_results = Some(new_value); self } @@ -13667,12 +14913,12 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut AddresseAggregatedListCall<'a, C, A> { + pub fn filter(mut self, new_value: &str) -> TargetSslProxyListCall<'a, C, A> { self._filter = Some(new_value.to_string()); self } @@ -13682,7 +14928,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut AddresseAggregatedListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -13703,7 +14949,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> AddresseAggregatedListCall<'a, C, A> + 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 @@ -13720,7 +14966,7 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> AddresseAggregatedListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> TargetSslProxyListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -13728,10 +14974,10 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut AddresseAggregatedListCall<'a, C, A> where C: BorrowMut::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; +/// use compute1::TargetSslProxiesSetSslCertificatesRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -14014,30 +15001,30 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o /// // 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(); +/// 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.addresses().insert(req, "project", "region") +/// let result = hub.target_ssl_proxies().set_ssl_certificates(req, "project", "targetSslProxy") /// .doit(); /// # } /// ``` -pub struct AddresseInsertCall<'a, C, A> +pub struct TargetSslProxySetSslCertificateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, - _request: Address, + _request: TargetSslProxiesSetSslCertificatesRequest, _project: String, - _region: String, + _target_ssl_proxy: 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> CallBuilder for TargetSslProxySetSslCertificateCall<'a, C, A> {} -impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> TargetSslProxySetSslCertificateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -14049,12 +15036,12 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.addresses.insert", + 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(("region", self._region.to_string())); - for &field in ["alt", "project", "region"].iter() { + 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)); @@ -14066,12 +15053,12 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".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"), ("{region}", "region")].iter() { + 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 { @@ -14083,7 +15070,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["region", "project"].iter() { + for param_name in ["targetSslProxy", "project"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -14189,7 +15176,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// /// 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> { + pub fn request(mut self, new_value: TargetSslProxiesSetSslCertificatesRequest) -> TargetSslProxySetSslCertificateCall<'a, C, A> { self._request = new_value; self } @@ -14199,18 +15186,18 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// /// 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> { + pub fn project(mut self, new_value: &str) -> TargetSslProxySetSslCertificateCall<'a, C, A> { self._project = new_value.to_string(); self } - /// Name of the region for this request. + /// Name of the TargetSslProxy resource whose SslCertificate resource is to be set. /// - /// Sets the *region* path property to the given value. + /// 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 region(mut self, new_value: &str) -> AddresseInsertCall<'a, C, A> { - self._region = new_value.to_string(); + 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 @@ -14219,7 +15206,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxySetSslCertificateCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14240,7 +15227,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// * *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> + 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 @@ -14257,7 +15244,7 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// 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> + pub fn add_scope(mut self, scope: T) -> TargetSslProxySetSslCertificateCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -14265,10 +15252,288 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A } -/// Deletes the specified address resource. +/// Changes the BackendService for TargetSslProxy. /// -/// A builder for the *delete* method supported by a *addresse* resource. -/// It is not used directly, but through a `AddresseMethods` instance. +/// 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 /// @@ -14291,25 +15556,24 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling 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") +/// let result = hub.target_ssl_proxies().delete("project", "targetSslProxy") /// .doit(); /// # } /// ``` -pub struct AddresseDeleteCall<'a, C, A> +pub struct TargetSslProxyDeleteCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, _project: String, - _region: String, - _address: String, + _target_ssl_proxy: 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> CallBuilder for TargetSslProxyDeleteCall<'a, C, A> {} -impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> TargetSslProxyDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -14321,13 +15585,12 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.addresses.delete", + dlg.begin(MethodInfo { id: "compute.targetSslProxies.delete", http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + 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(("address", self._address.to_string())); - for &field in ["alt", "project", "region", "address"].iter() { + 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)); @@ -14339,12 +15602,12 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses/{address}".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"), ("{region}", "region"), ("{address}", "address")].iter() { + 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 { @@ -14355,8 +15618,8 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A 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() { + 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); } @@ -14448,28 +15711,18 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// /// 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> { + pub fn project(mut self, new_value: &str) -> TargetSslProxyDeleteCall<'a, C, A> { self._project = new_value.to_string(); self } - /// Name of the region for this request. + /// Name of the TargetSslProxy resource to delete. /// - /// Sets the *region* path property to the given value. + /// 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 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(); + 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 @@ -14478,7 +15731,7 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetSslProxyDeleteCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -14499,7 +15752,7 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// * *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> + 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 @@ -14516,7 +15769,798 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// 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> + 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 @@ -15342,9 +17386,9 @@ impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.url_maps().list("project") -/// .page_token("consetetur") -/// .max_results(65) -/// .filter("ea") +/// .page_token("amet") +/// .max_results(78) +/// .filter("consetetur") /// .doit(); /// # } /// ``` @@ -15533,9 +17577,9 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -15594,6 +17638,284 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa } +/// 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. @@ -16881,9 +19203,9 @@ impl<'a, C, A> GlobalAddresseListCall<'a, C, A> where C: BorrowMut GlobalAddresseListCall<'a, C, A> { @@ -17901,9 +20223,9 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -18688,9 +21010,9 @@ impl<'a, C, A> DiskTypeAggregatedListCall<'a, C, A> where C: BorrowMut DiskTypeAggregatedListCall<'a, C, A> { @@ -18979,9 +21301,9 @@ impl<'a, C, A> DiskTypeListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -19505,9 +21827,9 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -20959,296 +23281,6 @@ impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut::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 - } -} - - /// Adds an access config to an instance's network interface. /// /// A builder for the *addAccessConfig* method supported by a *instance* resource. @@ -22359,9 +24391,9 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o } -/// 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. +/// Sets tags for the specified instance to the data included in the request. /// -/// A builder for the *stop* method supported by a *instance* resource. +/// A builder for the *setTags* method supported by a *instance* resource. /// It is not used directly, but through a `InstanceMethods` instance. /// /// # Example @@ -22372,6 +24404,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o /// # 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}; @@ -22382,17 +24415,23 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o /// # 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().stop("project", "zone", "instance") +/// let result = hub.instances().set_tags(req, "project", "zone", "instance") /// .doit(); /// # } /// ``` -pub struct InstanceStopCall<'a, C, A> +pub struct InstanceSetTagCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, + _request: Tags, _project: String, _zone: String, _instance: String, @@ -22401,9 +24440,9 @@ pub struct InstanceStopCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for InstanceStopCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for InstanceSetTagCall<'a, C, A> {} -impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -22415,9 +24454,9 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.instances.stop", + dlg.begin(MethodInfo { id: "compute.instances.setTags", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + 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())); @@ -22433,7 +24472,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/stop".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(), ()); } @@ -22465,6 +24504,17 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: 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 { @@ -22481,11 +24531,15 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: } }; 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(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() @@ -22536,13 +24590,22 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: } + /// + /// 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) -> InstanceStopCall<'a, C, A> { + pub fn project(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { self._project = new_value.to_string(); self } @@ -22552,17 +24615,17 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// /// 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> { + pub fn zone(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { self._zone = new_value.to_string(); self } - /// Name of the instance resource to stop. + /// 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) -> InstanceStopCall<'a, C, A> { + pub fn instance(mut self, new_value: &str) -> InstanceSetTagCall<'a, C, A> { self._instance = new_value.to_string(); self } @@ -22572,7 +24635,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceSetTagCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -22593,7 +24656,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// * *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> + 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 @@ -22610,7 +24673,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// 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> + pub fn add_scope(mut self, scope: T) -> InstanceSetTagCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -22889,6 +24952,1085 @@ impl<'a, C, A> InstanceDetachDiskCall<'a, C, A> where C: BorrowMut::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. @@ -23179,567 +26321,6 @@ impl<'a, C, A> InstanceAttachDiskCall<'a, C, A> where C: BorrowMut::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 - } -} - - -/// 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 - } -} - - /// Retrieves the list of instances contained within the specified zone. /// /// A builder for the *list* method supported by a *instance* resource. @@ -23767,9 +26348,9 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.instances().list("project", "zone") -/// .page_token("sit") -/// .max_results(93) -/// .filter("elitr") +/// .page_token("nonumy") +/// .max_results(86) +/// .filter("Lorem") /// .doit(); /// # } /// ``` @@ -23970,9 +26551,9 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -24031,9 +26612,9 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: } -/// Performs a hard reset on the instance. +/// Starts an instance that was stopped using the using the instances().stop method. For more information, see Restart an instance. /// -/// A builder for the *reset* method supported by a *instance* resource. +/// A builder for the *startWithEncryptionKey* method supported by a *instance* resource. /// It is not used directly, but through a `InstanceMethods` instance. /// /// # Example @@ -24044,6 +26625,7 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: /// # 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}; @@ -24054,17 +26636,23 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: /// # 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().reset("project", "zone", "instance") +/// let result = hub.instances().start_with_encryption_key(req, "project", "zone", "instance") /// .doit(); /// # } /// ``` -pub struct InstanceResetCall<'a, C, A> +pub struct InstanceStartWithEncryptionKeyCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, + _request: InstancesStartWithEncryptionKeyRequest, _project: String, _zone: String, _instance: String, @@ -24073,9 +26661,9 @@ pub struct InstanceResetCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for InstanceResetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for InstanceStartWithEncryptionKeyCall<'a, C, A> {} -impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> InstanceStartWithEncryptionKeyCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -24087,9 +26675,9 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.instances.reset", + dlg.begin(MethodInfo { id: "compute.instances.startWithEncryptionKey", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + 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())); @@ -24105,7 +26693,7 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/reset".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(), ()); } @@ -24137,6 +26725,17 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: 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 { @@ -24153,11 +26752,15 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: } }; 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(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() @@ -24208,13 +26811,22 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: } + /// + /// 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) -> InstanceResetCall<'a, C, A> { + pub fn project(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { self._project = new_value.to_string(); self } @@ -24224,17 +26836,17 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: /// /// 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> { + pub fn zone(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { self._zone = new_value.to_string(); self } - /// Name of the instance scoping this request. + /// 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) -> InstanceResetCall<'a, C, A> { + pub fn instance(mut self, new_value: &str) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { self._instance = new_value.to_string(); self } @@ -24244,7 +26856,7 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceStartWithEncryptionKeyCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -24265,7 +26877,7 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: /// * *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> + 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 @@ -24282,7 +26894,7 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: /// 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> + pub fn add_scope(mut self, scope: T) -> InstanceStartWithEncryptionKeyCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -24317,8 +26929,8 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.instances().aggregated_list("project") -/// .page_token("diam") -/// .max_results(65) +/// .page_token("amet.") +/// .max_results(1) /// .filter("ut") /// .doit(); /// # } @@ -24508,9 +27120,9 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut InstanceAggregatedListCall<'a, C, A> { @@ -25645,9 +28257,9 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut BackendServiceListCall<'a, C, A> where C: BorrowMut BackendServiceListCall<'a, C, A> { @@ -26441,9 +29053,7 @@ impl<'a, C, A> BackendServiceInsertCall<'a, C, A> where C: BorrowMut BackendServiceInsertCall<'a, C, A> where C: BorrowMut ImageListCall<'a, C, A> where C: BorrowMut, A: oau /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -26722,6 +29332,500 @@ impl<'a, C, A> ImageListCall<'a, C, A> where C: BorrowMut, A: oau } +/// 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. @@ -27515,10 +30619,10 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut } -/// Deletes the specified image. +/// Returns the specified HealthCheck resource. Get a list of available health checks by making a list() request. /// -/// A builder for the *delete* method supported by a *image* resource. -/// It is not used directly, but through a `ImageMethods` instance. +/// A builder for the *get* method supported by a *healthCheck* resource. +/// It is not used directly, but through a `HealthCheckMethods` instance. /// /// # Example /// @@ -27541,28 +30645,28 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // You can configure optional parameters by calling 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") +/// let result = hub.health_checks().get("project", "healthCheck") /// .doit(); /// # } /// ``` -pub struct ImageDeleteCall<'a, C, A> +pub struct HealthCheckGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, _project: String, - _image: String, + _health_check: 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> CallBuilder for HealthCheckGetCall<'a, C, A> {} -impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +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, Operation)> { + 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; @@ -27570,12 +30674,12 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "compute.images.delete", - http_method: hyper::method::Method::Delete }); + 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(("image", self._image.to_string())); - for &field in ["alt", "project", "image"].iter() { + 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)); @@ -27587,12 +30691,12 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/global/images/{image}".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(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{project}", "project"), ("{image}", "image")].iter() { + 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 { @@ -27604,7 +30708,1355 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["image", "project"].iter() { + 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); } @@ -27696,18 +32148,18 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// /// 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> { + pub fn project(mut self, new_value: &str) -> HealthCheckDeleteCall<'a, C, A> { self._project = new_value.to_string(); self } - /// Name of the image resource to delete. + /// Name of the HealthCheck resource to delete. /// - /// Sets the *image* path property to the given value. + /// 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 image(mut self, new_value: &str) -> ImageDeleteCall<'a, C, A> { - self._image = new_value.to_string(); + 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 @@ -27716,7 +32168,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> HealthCheckDeleteCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -27737,7 +32189,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// * *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> + 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 @@ -27754,7 +32206,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// 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> + pub fn add_scope(mut self, scope: T) -> HealthCheckDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -29352,9 +33804,9 @@ impl<'a, C, A> TargetHttpsProxySetSslCertificateCall<'a, C, A> where C: BorrowMu /// // 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("diam") -/// .max_results(79) -/// .filter("dolores") +/// .page_token("labore") +/// .max_results(40) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -29543,9 +33995,9 @@ impl<'a, C, A> TargetHttpsProxyListCall<'a, C, A> where C: BorrowMut TargetHttpsProxyListCall<'a, C, A> { @@ -29897,9 +34349,9 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.networks().list("project") -/// .page_token("aliquyam") -/// .max_results(7) -/// .filter("ea") +/// .page_token("magna") +/// .max_results(0) +/// .filter("rebum.") /// .doit(); /// # } /// ``` @@ -30088,9 +34540,9 @@ impl<'a, C, A> NetworkListCall<'a, C, A> where C: BorrowMut, A: o /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -30643,6 +35095,1372 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa } +/// 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. @@ -30670,9 +36488,9 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.global_operations().list("project") -/// .page_token("dolore") -/// .max_results(96) -/// .filter("consetetur") +/// .page_token("diam") +/// .max_results(60) +/// .filter("sed") /// .doit(); /// # } /// ``` @@ -30861,9 +36679,9 @@ impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut GlobalOperationListCall<'a, C, A> { @@ -30922,285 +36740,6 @@ impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut::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("eirmod") -/// .max_results(65) -/// .filter("gubergren") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 - } -} - - /// 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. @@ -31684,6 +37223,285 @@ impl<'a, C, A> GlobalOperationDeleteCall<'a, C, A> where C: BorrowMut::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. @@ -32229,9 +38047,9 @@ impl<'a, C, A> AutoscalerGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.autoscalers().list("project", "zone") -/// .page_token("vero") -/// .max_results(5) -/// .filter("eos") +/// .page_token("et") +/// .max_results(70) +/// .filter("nonumy") /// .doit(); /// # } /// ``` @@ -32432,9 +38250,9 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -33088,9 +38906,9 @@ impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.autoscalers().aggregated_list("project") -/// .page_token("magna") -/// .max_results(7) -/// .filter("magna") +/// .page_token("gubergren") +/// .max_results(99) +/// .filter("amet") /// .doit(); /// # } /// ``` @@ -33279,9 +39097,9 @@ impl<'a, C, A> AutoscalerAggregatedListCall<'a, C, A> where C: BorrowMut AutoscalerAggregatedListCall<'a, C, A> { @@ -33373,7 +39191,7 @@ impl<'a, C, A> AutoscalerAggregatedListCall<'a, C, A> where C: BorrowMut AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, } -/// 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("diam") -/// .max_results(60) -/// .filter("sed") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 - } -} - - /// 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. @@ -34187,6 +39726,544 @@ impl<'a, C, A> SubnetworkInsertCall<'a, C, A> where C: BorrowMut, } +/// 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. @@ -34473,9 +40550,9 @@ impl<'a, C, A> SubnetworkDeleteCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subnetworks().list("project", "region") -/// .page_token("takimata") -/// .max_results(32) -/// .filter("consetetur") +/// .page_token("et") +/// .max_results(20) +/// .filter("dolores") /// .doit(); /// # } /// ``` @@ -34676,9 +40753,9 @@ impl<'a, C, A> SubnetworkListCall<'a, C, A> where C: BorrowMut, A /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -34737,265 +40814,6 @@ impl<'a, C, A> SubnetworkListCall<'a, C, A> where C: BorrowMut, A } -/// Returns the specified subnetwork. Get a list of available subnetworks by making a 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 - } -} - - /// 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. @@ -35288,9 +41106,9 @@ impl<'a, C, A> InstanceGroupDeleteCall<'a, C, A> where C: BorrowMut InstanceGroupListInstanceCall<'a, C, A> where C: BorrowMut InstanceGroupListInstanceCall<'a, C, A> { @@ -35589,6 +41407,296 @@ impl<'a, C, A> InstanceGroupListInstanceCall<'a, C, A> where C: BorrowMut::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. @@ -36416,296 +42524,6 @@ impl<'a, C, A> InstanceGroupRemoveInstanceCall<'a, C, A> where C: BorrowMut::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 - } -} - - /// Sets the named ports for the specified instance group. /// /// A builder for the *setNamedPorts* method supported by a *instanceGroup* resource. @@ -37023,9 +42841,9 @@ impl<'a, C, A> InstanceGroupSetNamedPortCall<'a, C, A> where C: BorrowMut InstanceGroupAggregatedListCall<'a, C, A> where C: BorrowMut InstanceGroupAggregatedListCall<'a, C, A> { @@ -37302,9 +43120,9 @@ impl<'a, C, A> InstanceGroupAggregatedListCall<'a, C, A> where C: BorrowMut InstanceGroupListCall<'a, C, A> where C: BorrowMut /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -37593,9 +43411,9 @@ impl<'a, C, A> InstanceGroupListCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.regions().list("project") -/// .page_token("erat") -/// .max_results(83) -/// .filter("kasd") +/// .page_token("est") +/// .max_results(53) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -37784,9 +43602,9 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut, A: oa /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -38092,6 +43910,285 @@ impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oau } +/// 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. @@ -38688,8 +44785,8 @@ impl<'a, C, A> ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut ForwardingRuleListCall<'a, C, A> where C: BorrowMut ForwardingRuleListCall<'a, C, A> { @@ -38951,285 +45048,6 @@ impl<'a, C, A> ForwardingRuleListCall<'a, C, A> where C: BorrowMut::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("gubergren") -/// .max_results(71) -/// .filter("et") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 - } -} - - /// Returns the specified ForwardingRule resource. /// /// A builder for the *get* method supported by a *forwardingRule* resource. @@ -40929,7 +46747,7 @@ impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut TargetPoolAggregatedListCall<'a, C, A> where C: BorrowMut TargetPoolAggregatedListCall<'a, C, A> { @@ -42602,8 +48420,8 @@ impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, /// // 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("ut") -/// .max_results(57) +/// .page_token("et") +/// .max_results(55) /// .filter("et") /// .doit(); /// # } @@ -42805,9 +48623,9 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -42893,9 +48711,9 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A /// // 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("dolor") -/// .max_results(7) -/// .filter("magna") +/// .page_token("kasd") +/// .max_results(51) +/// .filter("eos") /// .doit(); /// # } /// ``` @@ -43096,9 +48914,9 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut TargetInstanceListCall<'a, C, A> { @@ -43462,9 +49280,9 @@ impl<'a, C, A> TargetInstanceInsertCall<'a, C, A> where C: BorrowMut TargetInstanceAggregatedListCall<'a, C, A> where C: BorrowMut TargetInstanceAggregatedListCall<'a, C, A> { @@ -45050,9 +50868,9 @@ impl<'a, C, A> GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleListCall<'a, C, A> { @@ -45823,9 +51641,9 @@ impl<'a, C, A> HttpsHealthCheckDeleteCall<'a, C, A> where C: BorrowMut HttpsHealthCheckListCall<'a, C, A> where C: BorrowMut HttpsHealthCheckListCall<'a, C, A> { @@ -47144,6 +52962,2501 @@ impl<'a, C, A> HttpsHealthCheckPatchCall<'a, C, A> where C: BorrowMut::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. @@ -47171,9 +55484,9 @@ impl<'a, C, A> HttpsHealthCheckPatchCall<'a, C, A> where C: BorrowMut MachineTypeAggregatedListCall<'a, C, A> where C: BorrowMut MachineTypeAggregatedListCall<'a, C, A> { @@ -47709,9 +56022,9 @@ impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A /// // 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("amet") -/// .max_results(96) -/// .filter("eirmod") +/// .page_token("kasd") +/// .max_results(53) +/// .filter("justo") /// .doit(); /// # } /// ``` @@ -47912,9 +56225,9 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -48000,9 +56313,9 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, /// // 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("clita") -/// .max_results(78) -/// .filter("eirmod") +/// .page_token("ipsum") +/// .max_results(100) +/// .filter("dolor") /// .doit(); /// # } /// ``` @@ -48191,9 +56504,9 @@ impl<'a, C, A> TargetVpnGatewayAggregatedListCall<'a, C, A> where C: BorrowMut TargetVpnGatewayAggregatedListCall<'a, C, A> { @@ -48538,9 +56851,9 @@ impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut TargetVpnGatewayListCall<'a, C, A> { @@ -49610,297 +57923,6 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut::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("ipsum") -/// .max_results(40) -/// .filter("vero") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 - } -} - - /// 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. @@ -50465,9 +58487,9 @@ impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut InstanceGroupManagerAggregatedListCall<'a, C, A> where C: BorrowM /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -51007,9 +59029,9 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM } -/// 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. +/// Retrieves a list of managed instance groups that are contained within the specified project and zone. /// -/// A builder for the *setInstanceTemplate* method supported by a *instanceGroupManager* resource. +/// A builder for the *list* method supported by a *instanceGroupManager* resource. /// It is not used directly, but through a `InstanceGroupManagerMethods` instance. /// /// # Example @@ -51020,7 +59042,6 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM /// # 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}; @@ -51031,38 +59052,37 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM /// # 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") +/// let result = hub.instance_group_managers().list("project", "zone") +/// .page_token("dolore") +/// .max_results(57) +/// .filter("ipsum") /// .doit(); /// # } /// ``` -pub struct InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> +pub struct InstanceGroupManagerListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Compute, - _request: InstanceGroupManagersSetInstanceTemplateRequest, _project: String, _zone: String, - _instance_group_manager: 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 InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for InstanceGroupManagerListCall<'a, C, A> {} -impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +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, Operation)> { + 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; @@ -51070,13 +59090,21 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo 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())); + 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())); - params.push(("instanceGroupManager", self._instance_group_manager.to_string())); - for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() { + 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)); @@ -51088,12 +59116,12 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/setInstanceTemplate".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(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{instanceGroupManager}", "instanceGroupManager")].iter() { + 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 { @@ -51104,8 +59132,8 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo 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() { + 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); } @@ -51120,17 +59148,6 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo 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 { @@ -51147,15 +59164,11 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo } }; 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) + 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); + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -51206,22 +59219,13 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo } - /// - /// 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> { + pub fn project(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { self._project = new_value.to_string(); self } @@ -51231,18 +59235,37 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// /// 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> { + pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C, A> { self._zone = new_value.to_string(); self } - /// The name of the managed instance group. + /// 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 *instance group manager* path property to the given value. + /// 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. /// - /// 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(); + /// 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 @@ -51251,7 +59274,7 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// It should be used to handle progress information, and to 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> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> InstanceGroupManagerListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -51272,7 +59295,7 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// * *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> + 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 @@ -51281,7 +59304,7 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// 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`. + /// `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. @@ -51289,7 +59312,7 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo /// 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> + pub fn add_scope(mut self, scope: T) -> InstanceGroupManagerListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -51587,6 +59610,296 @@ impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMu } +/// 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. @@ -53217,241 +61530,6 @@ impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut } -/// 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 - } -} - - /// Moves an instance and its attached persistent disks from one zone to another. /// /// A builder for the *moveInstance* method supported by a *project* resource. @@ -53984,6 +62062,241 @@ impl<'a, C, A> ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut::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. @@ -54231,6 +62544,253 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut::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. @@ -54536,9 +63096,9 @@ impl<'a, C, A> HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut HttpHealthCheckListCall<'a, C, A> where C: BorrowMut HttpHealthCheckListCall<'a, C, A> { @@ -54788,253 +63348,6 @@ impl<'a, C, A> HttpHealthCheckListCall<'a, C, A> where C: BorrowMut::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 - } -} - - /// 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. @@ -56100,9 +64413,9 @@ impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut InstanceTemplateListCall<'a, C, A> where C: BorrowMut InstanceTemplateListCall<'a, C, A> { @@ -56892,9 +65205,9 @@ impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut TargetHttpProxyListCall<'a, C, A> where C: BorrowMut TargetHttpProxyListCall<'a, C, A> { @@ -58209,9 +66522,9 @@ impl<'a, C, A> SslCertificateDeleteCall<'a, C, A> where C: BorrowMut SslCertificateListCall<'a, C, A> where C: BorrowMut SslCertificateListCall<'a, C, A> { @@ -59250,8 +67563,8 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut ZoneOperationListCall<'a, C, A> where C: BorrowMut /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -60312,9 +68625,9 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.routes().list("project") -/// .page_token("accusam") -/// .max_results(95) -/// .filter("sit") +/// .page_token("sit") +/// .max_results(1) +/// .filter("clita") /// .doit(); /// # } /// ``` @@ -60503,9 +68816,9 @@ impl<'a, C, A> RouteListCall<'a, C, A> where C: BorrowMut, A: oau /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -61907,9 +70220,9 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.firewalls().list("project") -/// .page_token("diam") -/// .max_results(27) -/// .filter("elitr") +/// .page_token("erat") +/// .max_results(68) +/// .filter("dolore") /// .doit(); /// # } /// ``` @@ -62098,9 +70411,9 @@ impl<'a, C, A> FirewallListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -63202,6 +71515,285 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: } +/// 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. @@ -63229,9 +71821,9 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: /// // 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("clita") -/// .max_results(62) -/// .filter("Stet") +/// .page_token("amet.") +/// .max_results(72) +/// .filter("sea") /// .doit(); /// # } /// ``` @@ -63432,9 +72024,9 @@ impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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> { @@ -63493,285 +72085,6 @@ impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: } -/// 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("Stet") -/// .max_results(18) -/// .filter("Lorem") -/// .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. - /// - /// Compute Engine Beta API Only: If you use filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. In particular, use filtering on nested fields to take advantage of instance labels to organize and filter results based on label values. - /// - /// The Beta API also supports filtering on multiple expressions by providing 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 Operation resources contained within the specified region. /// /// A builder for the *list* method supported by a *regionOperation* resource. @@ -63799,9 +72112,9 @@ impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut RegionOperationListCall<'a, C, A> where C: BorrowMut RegionOperationListCall<'a, C, A> { diff --git a/gen/container1-cli/Cargo.toml b/gen/container1-cli/Cargo.toml index 5fa2738036..e9ccc49f8c 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+20160321" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "container1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-container1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-container1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-container1] diff --git a/gen/container1-cli/README.md b/gen/container1-cli/README.md index f0a7e52701..cea542071e 100644 --- a/gen/container1-cli/README.md +++ b/gen/container1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *container* API at revision *20160321*. The CLI is at version *0.3.6*. +This documentation was generated from the *container* API at revision *20160421*. The CLI is at version *0.3.6*. ```bash container1 [options] @@ -33,6 +33,10 @@ container1 [options] zones-clusters-delete [-p ]... [-o ] zones-clusters-get [-p ]... [-o ] zones-clusters-list [-p ]... [-o ] + zones-clusters-node-pools-create (-r )... [-p ]... [-o ] + zones-clusters-node-pools-delete [-p ]... [-o ] + zones-clusters-node-pools-get [-p ]... [-o ] + zones-clusters-node-pools-list [-p ]... [-o ] zones-clusters-update (-r )... [-p ]... [-o ] zones-get-serverconfig [-p ]... [-o ] zones-operations-get [-p ]... [-o ] diff --git a/gen/container1-cli/mkdocs.yml b/gen/container1-cli/mkdocs.yml index 845e400fbe..bc45a66aa9 100644 --- a/gen/container1-cli/mkdocs.yml +++ b/gen/container1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: container v0.3.6+20160321 +site_name: container v0.3.6+20160421 site_url: http://byron.github.io/google-apis-rs/google-container1-cli site_description: Write integrating applications with bcore @@ -13,6 +13,10 @@ pages: - ['projects_zones-clusters-delete.md', 'Projects', 'Zones Clusters Delete'] - ['projects_zones-clusters-get.md', 'Projects', 'Zones Clusters Get'] - ['projects_zones-clusters-list.md', 'Projects', 'Zones Clusters List'] +- ['projects_zones-clusters-node-pools-create.md', 'Projects', 'Zones Clusters Node Pools Create'] +- ['projects_zones-clusters-node-pools-delete.md', 'Projects', 'Zones Clusters Node Pools Delete'] +- ['projects_zones-clusters-node-pools-get.md', 'Projects', 'Zones Clusters Node Pools Get'] +- ['projects_zones-clusters-node-pools-list.md', 'Projects', 'Zones Clusters Node Pools List'] - ['projects_zones-clusters-update.md', 'Projects', 'Zones Clusters Update'] - ['projects_zones-get-serverconfig.md', 'Projects', 'Zones Get Serverconfig'] - ['projects_zones-operations-get.md', 'Projects', 'Zones Operations Get'] diff --git a/gen/container1-cli/src/main.rs b/gen/container1-cli/src/main.rs index 51ed43642b..eaea1ca377 100644 --- a/gen/container1-cli/src/main.rs +++ b/gen/container1-cli/src/main.rs @@ -71,9 +71,11 @@ impl<'n> Engine<'n> { "cluster.node-ipv4-cidr-size" => Some(("cluster.nodeIpv4CidrSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "cluster.addons-config.http-load-balancing.disabled" => Some(("cluster.addonsConfig.httpLoadBalancing.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "cluster.addons-config.horizontal-pod-autoscaling.disabled" => Some(("cluster.addonsConfig.horizontalPodAutoscaling.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cluster.locations" => Some(("cluster.locations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "cluster.network" => Some(("cluster.network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.logging-service" => Some(("cluster.loggingService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.instance-group-urls" => Some(("cluster.instanceGroupUrls", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cluster.zone" => Some(("cluster.zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.status-message" => Some(("cluster.statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.services-ipv4-cidr" => Some(("cluster.servicesIpv4Cidr", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.status" => Some(("cluster.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -88,10 +90,9 @@ impl<'n> Engine<'n> { "cluster.initial-node-count" => Some(("cluster.initialNodeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "cluster.monitoring-service" => Some(("cluster.monitoringService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.create-time" => Some(("cluster.createTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "cluster.name" => Some(("cluster.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.endpoint" => Some(("cluster.endpoint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.current-node-count" => Some(("cluster.currentNodeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "cluster.zone" => Some(("cluster.zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cluster.name" => Some(("cluster.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.initial-cluster-version" => Some(("cluster.initialClusterVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.node-config.disk-size-gb" => Some(("cluster.nodeConfig.diskSizeGb", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "cluster.node-config.machine-type" => Some(("cluster.nodeConfig.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -101,7 +102,7 @@ impl<'n> Engine<'n> { "cluster.subnetwork" => Some(("cluster.subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cluster.self-link" => Some(("cluster.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["addons-config", "client-certificate", "client-key", "cluster", "cluster-ca-certificate", "cluster-ipv4-cidr", "create-time", "current-master-version", "current-node-count", "current-node-version", "description", "disabled", "disk-size-gb", "endpoint", "horizontal-pod-autoscaling", "http-load-balancing", "initial-cluster-version", "initial-node-count", "instance-group-urls", "logging-service", "machine-type", "master-auth", "metadata", "monitoring-service", "name", "network", "node-config", "node-ipv4-cidr-size", "oauth-scopes", "password", "self-link", "services-ipv4-cidr", "status", "status-message", "subnetwork", "username", "zone"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["addons-config", "client-certificate", "client-key", "cluster", "cluster-ca-certificate", "cluster-ipv4-cidr", "create-time", "current-master-version", "current-node-count", "current-node-version", "description", "disabled", "disk-size-gb", "endpoint", "horizontal-pod-autoscaling", "http-load-balancing", "initial-cluster-version", "initial-node-count", "instance-group-urls", "locations", "logging-service", "machine-type", "master-auth", "metadata", "monitoring-service", "name", "network", "node-config", "node-ipv4-cidr-size", "oauth-scopes", "password", "self-link", "services-ipv4-cidr", "status", "status-message", "subnetwork", "username", "zone"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -317,6 +318,257 @@ impl<'n> Engine<'n> { } } + fn _projects_zones_clusters_node_pools_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()[..] { + "node-pool.status" => Some(("nodePool.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "node-pool.status-message" => Some(("nodePool.statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "node-pool.name" => Some(("nodePool.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "node-pool.instance-group-urls" => Some(("nodePool.instanceGroupUrls", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "node-pool.version" => Some(("nodePool.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "node-pool.initial-node-count" => Some(("nodePool.initialNodeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "node-pool.config.disk-size-gb" => Some(("nodePool.config.diskSizeGb", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "node-pool.config.machine-type" => Some(("nodePool.config.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "node-pool.config.oauth-scopes" => Some(("nodePool.config.oauthScopes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "node-pool.config.metadata" => Some(("nodePool.config.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "node-pool.self-link" => Some(("nodePool.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["config", "disk-size-gb", "initial-node-count", "instance-group-urls", "machine-type", "metadata", "name", "node-pool", "oauth-scopes", "self-link", "status", "status-message", "version"]); + 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::CreateNodePoolRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.projects().zones_clusters_node_pools_create(request, opt.value_of("project-id").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("cluster-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_zones_clusters_node_pools_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().zones_clusters_node_pools_delete(opt.value_of("project-id").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("cluster-id").unwrap_or(""), opt.value_of("node-pool-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_zones_clusters_node_pools_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().zones_clusters_node_pools_get(opt.value_of("project-id").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("cluster-id").unwrap_or(""), opt.value_of("node-pool-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_zones_clusters_node_pools_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().zones_clusters_node_pools_list(opt.value_of("project-id").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("cluster-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_zones_clusters_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { @@ -341,12 +593,13 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { "update.desired-master-version" => Some(("update.desiredMasterVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "update.desired-node-pool-id" => Some(("update.desiredNodePoolId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "update.desired-node-version" => Some(("update.desiredNodeVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "update.desired-monitoring-service" => Some(("update.desiredMonitoringService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "update.desired-addons-config.http-load-balancing.disabled" => Some(("update.desiredAddonsConfig.httpLoadBalancing.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "update.desired-addons-config.horizontal-pod-autoscaling.disabled" => Some(("update.desiredAddonsConfig.horizontalPodAutoscaling.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["desired-addons-config", "desired-master-version", "desired-monitoring-service", "desired-node-version", "disabled", "horizontal-pod-autoscaling", "http-load-balancing", "update"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["desired-addons-config", "desired-master-version", "desired-monitoring-service", "desired-node-pool-id", "desired-node-version", "disabled", "horizontal-pod-autoscaling", "http-load-balancing", "update"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -581,6 +834,18 @@ impl<'n> Engine<'n> { ("zones-clusters-list", Some(opt)) => { call_result = self._projects_zones_clusters_list(opt, dry_run, &mut err); }, + ("zones-clusters-node-pools-create", Some(opt)) => { + call_result = self._projects_zones_clusters_node_pools_create(opt, dry_run, &mut err); + }, + ("zones-clusters-node-pools-delete", Some(opt)) => { + call_result = self._projects_zones_clusters_node_pools_delete(opt, dry_run, &mut err); + }, + ("zones-clusters-node-pools-get", Some(opt)) => { + call_result = self._projects_zones_clusters_node_pools_get(opt, dry_run, &mut err); + }, + ("zones-clusters-node-pools-list", Some(opt)) => { + call_result = self._projects_zones_clusters_node_pools_list(opt, dry_run, &mut err); + }, ("zones-clusters-update", Some(opt)) => { call_result = self._projects_zones_clusters_update(opt, dry_run, &mut err); }, @@ -685,7 +950,7 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("projects", "methods: 'zones-clusters-create', 'zones-clusters-delete', 'zones-clusters-get', 'zones-clusters-list', 'zones-clusters-update', 'zones-get-serverconfig', 'zones-operations-get' and 'zones-operations-list'", vec![ + ("projects", "methods: 'zones-clusters-create', 'zones-clusters-delete', 'zones-clusters-get', 'zones-clusters-list', 'zones-clusters-node-pools-create', 'zones-clusters-node-pools-delete', 'zones-clusters-node-pools-get', 'zones-clusters-node-pools-list', 'zones-clusters-update', 'zones-get-serverconfig', 'zones-operations-get' and 'zones-operations-list'", vec![ ("zones-clusters-create", Some(r##"Creates a cluster, consisting of the specified number and type of Google Compute Engine instances. By default, the cluster is created in the project's [default network](/compute/docs/networks-and-firewalls#networks). One firewall is added for the cluster. After cluster creation, the cluster creates routes for each node to allow the containers on that node to communicate with all other instances in the cluster. Finally, an entry is added to the project's global metadata indicating which CIDR range is being used by the cluster."##), "Details at http://byron.github.io/google-apis-rs/google_container1_cli/projects_zones-clusters-create", @@ -810,6 +1075,160 @@ fn main() { 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-clusters-node-pools-create", + Some(r##"Creates a node pool for a cluster."##), + "Details at http://byron.github.io/google-apis-rs/google_container1_cli/projects_zones-clusters-node-pools-create", + vec![ + (Some(r##"project-id"##), + None, + Some(r##"The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber)."##), + Some(true), + Some(false)), + + (Some(r##"zone"##), + None, + Some(r##"The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides."##), + Some(true), + Some(false)), + + (Some(r##"cluster-id"##), + None, + Some(r##"The name of the cluster."##), + 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)), + ]), + ("zones-clusters-node-pools-delete", + Some(r##"Deletes a node pool from a cluster."##), + "Details at http://byron.github.io/google-apis-rs/google_container1_cli/projects_zones-clusters-node-pools-delete", + vec![ + (Some(r##"project-id"##), + None, + Some(r##"The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber)."##), + Some(true), + Some(false)), + + (Some(r##"zone"##), + None, + Some(r##"The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides."##), + Some(true), + Some(false)), + + (Some(r##"cluster-id"##), + None, + Some(r##"The name of the cluster."##), + Some(true), + Some(false)), + + (Some(r##"node-pool-id"##), + None, + Some(r##"The name of the node pool 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)), + ]), + ("zones-clusters-node-pools-get", + Some(r##"Retrieves the node pool requested."##), + "Details at http://byron.github.io/google-apis-rs/google_container1_cli/projects_zones-clusters-node-pools-get", + vec![ + (Some(r##"project-id"##), + None, + Some(r##"The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber)."##), + Some(true), + Some(false)), + + (Some(r##"zone"##), + None, + Some(r##"The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides."##), + Some(true), + Some(false)), + + (Some(r##"cluster-id"##), + None, + Some(r##"The name of the cluster."##), + Some(true), + Some(false)), + + (Some(r##"node-pool-id"##), + None, + Some(r##"The name of the node pool."##), + 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-clusters-node-pools-list", + Some(r##"Lists the node pools for a cluster."##), + "Details at http://byron.github.io/google-apis-rs/google_container1_cli/projects_zones-clusters-node-pools-list", + vec![ + (Some(r##"project-id"##), + None, + Some(r##"The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber)."##), + Some(true), + Some(false)), + + (Some(r##"zone"##), + None, + Some(r##"The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides."##), + Some(true), + Some(false)), + + (Some(r##"cluster-id"##), + None, + Some(r##"The name of the cluster."##), + 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"##), @@ -952,7 +1371,7 @@ fn main() { let mut app = App::new("container1") .author("Sebastian Thiel ") - .version("0.3.6+20160321") + .version("0.3.6+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/container1/Cargo.toml b/gen/container1/Cargo.toml index 30d6bfe74c..0c45fa4d6d 100644 --- a/gen/container1/Cargo.toml +++ b/gen/container1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-container1" -version = "0.1.14+20160321" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/container1/README.md b/gen/container1/README.md index 8718343d89..8d6c2b2d49 100644 --- a/gen/container1/README.md +++ b/gen/container1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-container1` library allows access to all features of the *Google container* service. -This documentation was generated from *container* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *container:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *container* crate version *0.1.14+20160421*, where *20160421* is the exact revision of the *container:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *container* *v1* API can be found at the [official documentation site](https://cloud.google.com/container-engine/). @@ -14,7 +14,7 @@ Everything else about the *container* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_container1/struct.Container.html) ... * projects - * [*zones clusters create*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterListCall.html), [*zones clusters update*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterUpdateCall.html), [*zones get serverconfig*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneGetServerconfigCall.html), [*zones operations get*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneOperationListCall.html) + * [*zones clusters create*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterListCall.html), [*zones clusters node pools create*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterNodePoolCreateCall.html), [*zones clusters node pools delete*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterNodePoolDeleteCall.html), [*zones clusters node pools get*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterNodePoolGetCall.html), [*zones clusters node pools list*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterNodePoolListCall.html), [*zones clusters update*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneClusterUpdateCall.html), [*zones get serverconfig*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneGetServerconfigCall.html), [*zones operations get*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](http://byron.github.io/google-apis-rs/google_container1/struct.ProjectZoneOperationListCall.html) @@ -47,9 +47,11 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.projects().zones_clusters_update(...).doit() -let r = hub.projects().zones_operations_get(...).doit() +let r = hub.projects().zones_clusters_node_pools_create(...).doit() let r = hub.projects().zones_clusters_delete(...).doit() +let r = hub.projects().zones_operations_get(...).doit() +let r = hub.projects().zones_clusters_node_pools_delete(...).doit() +let r = hub.projects().zones_clusters_update(...).doit() let r = hub.projects().zones_clusters_create(...).doit() ``` @@ -75,7 +77,7 @@ google-container1 = "*" extern crate hyper; extern crate yup_oauth2 as oauth2; extern crate google_container1 as container1; -use container1::UpdateClusterRequest; +use container1::CreateNodePoolRequest; use container1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -96,12 +98,12 @@ let mut hub = Container::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 = UpdateClusterRequest::default(); +let mut req = CreateNodePoolRequest::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().zones_clusters_update(req, "projectId", "zone", "clusterId") +let result = hub.projects().zones_clusters_node_pools_create(req, "projectId", "zone", "clusterId") .doit(); match result { diff --git a/gen/container1/src/lib.rs b/gen/container1/src/lib.rs index 7b704a4995..5326efe175 100644 --- a/gen/container1/src/lib.rs +++ b/gen/container1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *container* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *container:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *container* crate version *0.1.14+20160421*, where *20160421* is the exact revision of the *container:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *container* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/container-engine/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Container.html) ... //! //! * projects -//! * [*zones clusters create*](struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](struct.ProjectZoneClusterListCall.html), [*zones clusters update*](struct.ProjectZoneClusterUpdateCall.html), [*zones get serverconfig*](struct.ProjectZoneGetServerconfigCall.html), [*zones operations get*](struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](struct.ProjectZoneOperationListCall.html) +//! * [*zones clusters create*](struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](struct.ProjectZoneClusterListCall.html), [*zones clusters node pools create*](struct.ProjectZoneClusterNodePoolCreateCall.html), [*zones clusters node pools delete*](struct.ProjectZoneClusterNodePoolDeleteCall.html), [*zones clusters node pools get*](struct.ProjectZoneClusterNodePoolGetCall.html), [*zones clusters node pools list*](struct.ProjectZoneClusterNodePoolListCall.html), [*zones clusters update*](struct.ProjectZoneClusterUpdateCall.html), [*zones get serverconfig*](struct.ProjectZoneGetServerconfigCall.html), [*zones operations get*](struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](struct.ProjectZoneOperationListCall.html) //! //! //! @@ -47,9 +47,11 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.projects().zones_clusters_update(...).doit() -//! let r = hub.projects().zones_operations_get(...).doit() +//! let r = hub.projects().zones_clusters_node_pools_create(...).doit() //! let r = hub.projects().zones_clusters_delete(...).doit() +//! let r = hub.projects().zones_operations_get(...).doit() +//! let r = hub.projects().zones_clusters_node_pools_delete(...).doit() +//! let r = hub.projects().zones_clusters_update(...).doit() //! let r = hub.projects().zones_clusters_create(...).doit() //! ``` //! @@ -75,7 +77,7 @@ //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; //! extern crate google_container1 as container1; -//! use container1::UpdateClusterRequest; +//! use container1::CreateNodePoolRequest; //! use container1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; @@ -97,12 +99,12 @@ //! // 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 = UpdateClusterRequest::default(); +//! let mut req = CreateNodePoolRequest::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().zones_clusters_update(req, "projectId", "zone", "clusterId") +//! let result = hub.projects().zones_clusters_node_pools_create(req, "projectId", "zone", "clusterId") //! .doit(); //! //! match result { diff --git a/gen/container1/src/lib.rs.in b/gen/container1/src/lib.rs.in index bba16566f3..3adcf0924b 100644 --- a/gen/container1/src/lib.rs.in +++ b/gen/container1/src/lib.rs.in @@ -70,7 +70,7 @@ impl Default for Scope { /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_container1 as container1; -/// use container1::UpdateClusterRequest; +/// use container1::CreateNodePoolRequest; /// use container1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; @@ -92,12 +92,12 @@ impl Default for Scope { /// // 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 = UpdateClusterRequest::default(); +/// let mut req = CreateNodePoolRequest::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().zones_clusters_update(req, "projectId", "zone", "clusterId") +/// let result = hub.projects().zones_clusters_node_pools_create(req, "projectId", "zone", "clusterId") /// .doit(); /// /// match result { @@ -165,6 +165,9 @@ pub struct ClusterUpdate { /// The Kubernetes version to change the master to. The only valid value is the latest supported version. Use "-" to have the server automatically select the latest version. #[serde(rename="desiredMasterVersion")] pub desired_master_version: Option, + /// The node pool to be upgraded. This field is mandatory if the "desired_node_version" or "desired_image_family" is specified and there is more than one node pool on the cluster. + #[serde(rename="desiredNodePoolId")] + pub desired_node_pool_id: Option, /// The Kubernetes version to change the nodes to (typically an upgrade). Use `-` to upgrade to the latest version supported by the server. #[serde(rename="desiredNodeVersion")] pub desired_node_version: Option, @@ -179,24 +182,6 @@ pub struct ClusterUpdate { impl Part for ClusterUpdate {} -/// CreateClusterRequest creates a cluster. -/// -/// # 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*). -/// -/// * [zones clusters create projects](struct.ProjectZoneClusterCreateCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CreateClusterRequest { - /// A [cluster resource](/container-engine/reference/rest/v1/projects.zones.clusters) - pub cluster: Option, -} - -impl RequestValue for CreateClusterRequest {} - - /// UpdateClusterRequest updates the settings of a cluster. /// /// # Activities @@ -228,23 +213,6 @@ pub struct HttpLoadBalancing { impl Part for HttpLoadBalancing {} -/// Configuration for the addons that can be automatically spun up in the cluster, enabling additional functionality. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AddonsConfig { - /// Configuration for the HTTP (L7) load balancing controller addon, which makes it easy to set up HTTP load balancers for services in a cluster. - #[serde(rename="httpLoadBalancing")] - pub http_load_balancing: Option, - /// Configuration for the horizontal pod autoscaling feature, which increases or decreases the number of replica pods a replication controller has based on the resource usage of the existing pods. - #[serde(rename="horizontalPodAutoscaling")] - pub horizontal_pod_autoscaling: Option, -} - -impl Part for AddonsConfig {} - - /// ListClustersResponse is the result of ListClustersRequest. /// /// # Activities @@ -266,6 +234,180 @@ pub struct ListClustersResponse { impl ResponseResult for ListClustersResponse {} +/// Configuration options for the horizontal pod autoscaling feature, which increases or decreases the number of replica pods a replication controller has based on the resource usage of the existing pods. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct HorizontalPodAutoscaling { + /// Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. When enabled, it ensures that a Heapster pod is running in the cluster, which is also used by the Cloud Monitoring service. + pub disabled: Option, +} + +impl Part for HorizontalPodAutoscaling {} + + +/// Parameters that describe the nodes in a cluster. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct NodeConfig { + /// Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB. If unspecified, the default disk size is 100GB. + #[serde(rename="diskSizeGb")] + pub disk_size_gb: Option, + /// The name of a Google Compute Engine [machine type](/compute/docs/machine-types) (e.g. `n1-standard-1`). If unspecified, the default machine type is `n1-standard-1`. + #[serde(rename="machineType")] + pub machine_type: Option, + /// The set of Google API scopes to be made available on all of the node VMs under the "default" service account. The following scopes are recommended, but not required, and by default are not included: * `https://www.googleapis.com/auth/compute` is required for mounting persistent storage on your nodes. * `https://www.googleapis.com/auth/devstorage.read_only` is required for communicating with **gcr.io** (the [Google Container Registry](/container-registry/)). If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are enabled, in which case their required scopes will be added. + #[serde(rename="oauthScopes")] + pub oauth_scopes: Option>, + /// The metadata key/value pairs assigned to instances in the cluster. Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. These are 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 or be one of the four reserved keys: "instance-template", "kube-env", "startup-script", and "user-data" Values are free-form strings, and only have meaning as interpreted by the image running in the instance. The only restriction placed on them is that each value's size must be less than or equal to 32 KB. The total size of all keys and values must be less than 512 KB. + pub metadata: Option>, +} + +impl Part for NodeConfig {} + + +/// Container Engine service configuration. +/// +/// # 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*). +/// +/// * [zones get serverconfig projects](struct.ProjectZoneGetServerconfigCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ServerConfig { + /// Version of Kubernetes the service deploys by default. + #[serde(rename="defaultClusterVersion")] + pub default_cluster_version: Option, + /// List of valid node upgrade target versions. + #[serde(rename="validNodeVersions")] + pub valid_node_versions: Option>, + /// Default image family. + #[serde(rename="defaultImageFamily")] + pub default_image_family: Option, + /// List of valid image families. + #[serde(rename="validImageFamilies")] + pub valid_image_families: Option>, +} + +impl ResponseResult for ServerConfig {} + + +/// ListNodePoolsResponse is the result of ListNodePoolsRequest. +/// +/// # 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*). +/// +/// * [zones clusters node pools list projects](struct.ProjectZoneClusterNodePoolListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListNodePoolsResponse { + /// A list of node pools for a cluster. + #[serde(rename="nodePools")] + pub node_pools: Option>, +} + +impl ResponseResult for ListNodePoolsResponse {} + + +/// NodePool contains the name and configuration for a cluster's node pool. Node pools are a set of nodes (i.e. VM's), with a common configuration and specification, under the control of the cluster master. They may have a set of Kubernetes labels applied to them, which may be used to reference them during pod scheduling. They may also be resized up or down, to accommodate the workload. +/// +/// # 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*). +/// +/// * [zones clusters node pools get projects](struct.ProjectZoneClusterNodePoolGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct NodePool { + /// The status of the nodes in this pool instance. + pub status: Option, + /// Server-defined URL for the resource. + #[serde(rename="selfLink")] + pub self_link: Option, + /// The name of the node pool. + pub name: Option, + /// [Output only] The resource URLs of [instance groups](/compute/docs/instance-groups/) associated with this node pool. + #[serde(rename="instanceGroupUrls")] + pub instance_group_urls: Option>, + /// The version of the Kubernetes of this node. + pub version: Option, + /// The initial node count for the pool. You must ensure that your Compute Engine resource quota is sufficient for this number of instances. You must also have available firewall and routes quota. + #[serde(rename="initialNodeCount")] + pub initial_node_count: Option, + /// The node configuration of the pool. + pub config: Option, + /// [Output only] Additional information about the current status of this node pool instance, if available. + #[serde(rename="statusMessage")] + pub status_message: Option, +} + +impl ResponseResult for NodePool {} + + +/// CreateClusterRequest creates a cluster. +/// +/// # 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*). +/// +/// * [zones clusters create projects](struct.ProjectZoneClusterCreateCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreateClusterRequest { + /// A [cluster resource](/container-engine/reference/rest/v1/projects.zones.clusters) + pub cluster: Option, +} + +impl RequestValue for CreateClusterRequest {} + + +/// ListOperationsResponse is the result of ListOperationsRequest. +/// +/// # 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*). +/// +/// * [zones operations list projects](struct.ProjectZoneOperationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListOperationsResponse { + /// A list of operations in the project in the specified zone. + pub operations: Option>, + /// If any zones are listed here, the list of operations returned may be missing the operations from those zones. + #[serde(rename="missingZones")] + pub missing_zones: Option>, +} + +impl ResponseResult for ListOperationsResponse {} + + +/// Configuration for the addons that can be automatically spun up in the cluster, enabling additional functionality. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AddonsConfig { + /// Configuration for the HTTP (L7) load balancing controller addon, which makes it easy to set up HTTP load balancers for services in a cluster. + #[serde(rename="httpLoadBalancing")] + pub http_load_balancing: Option, + /// Configuration for the horizontal pod autoscaling feature, which increases or decreases the number of replica pods a replication controller has based on the resource usage of the existing pods. + #[serde(rename="horizontalPodAutoscaling")] + pub horizontal_pod_autoscaling: Option, +} + +impl Part for AddonsConfig {} + + /// The authentication information for accessing the master endpoint. Authentication can be done using HTTP basic auth or using client certificates. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -290,19 +432,6 @@ pub struct MasterAuth { impl Part for MasterAuth {} -/// Configuration options for the horizontal pod autoscaling feature, which increases or decreases the number of replica pods a replication controller has based on the resource usage of the existing pods. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct HorizontalPodAutoscaling { - /// Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. When enabled, it ensures that a Heapster pod is running in the cluster, which is also used by the Cloud Monitoring service. - pub disabled: Option, -} - -impl Part for HorizontalPodAutoscaling {} - - /// A Google Container Engine cluster. /// /// # Activities @@ -330,12 +459,17 @@ pub struct Cluster { /// Configurations for the various addons available to run in the cluster. #[serde(rename="addonsConfig")] pub addons_config: Option, + /// The list of Google Compute Engine [locations](/compute/docs/zones#available) in which the cluster's nodes should be located. + pub locations: Option>, /// The authentication information for accessing the master endpoint. #[serde(rename="masterAuth")] pub master_auth: Option, /// The number of nodes to create in this cluster. You must ensure that your Compute Engine resource quota is sufficient for this number of instances. You must also have available firewall and routes quota. For requests, this field should only be used in lieu of a "node_pool" object, since this configuration (along with the "node_config") will be used to create a "NodePool" object with an auto-generated name. Do not use this and a node_pool at the same time. #[serde(rename="initialNodeCount")] pub initial_node_count: Option, + /// The node pools associated with this cluster. When creating a new cluster, only a single node pool should be specified. This field should not be set if "node_config" or "initial_node_count" are specified. + #[serde(rename="nodePools")] + pub node_pools: Option>, /// The monitoring service the cluster should use to write metrics. Currently available options: * `monitoring.googleapis.com` - the Google Cloud Monitoring service. * `none` - no metrics will be exported from the cluster. * if left as an empty string, `monitoring.googleapis.com` will be used. #[serde(rename="monitoringService")] pub monitoring_service: Option, @@ -384,26 +518,23 @@ pub struct Cluster { impl ResponseResult for Cluster {} -/// Parameters that describe the nodes in a cluster. +/// CreateNodePoolRequest creates a node pool for a cluster. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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*). +/// +/// * [zones clusters node pools create projects](struct.ProjectZoneClusterNodePoolCreateCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct NodeConfig { - /// Size of the disk attached to each node, specified in GB. The smallest allowed disk size is 10GB. If unspecified, the default disk size is 100GB. - #[serde(rename="diskSizeGb")] - pub disk_size_gb: Option, - /// The name of a Google Compute Engine [machine type](/compute/docs/machine-types) (e.g. `n1-standard-1`). If unspecified, the default machine type is `n1-standard-1`. - #[serde(rename="machineType")] - pub machine_type: Option, - /// The set of Google API scopes to be made available on all of the node VMs under the "default" service account. The following scopes are recommended, but not required, and by default are not included: * `https://www.googleapis.com/auth/compute` is required for mounting persistent storage on your nodes. * `https://www.googleapis.com/auth/devstorage.read_only` is required for communicating with **gcr.io** (the [Google Container Registry](/container-registry/)). If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are enabled, in which case their required scopes will be added. - #[serde(rename="oauthScopes")] - pub oauth_scopes: Option>, - /// The metadata key/value pairs assigned to instances in the cluster. Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. These are 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 or be one of the four reserved keys: "instance-template", "kube-env", "startup-script", and "user-data" Values are free-form strings, and only have meaning as interpreted by the image running in the instance. The only restriction placed on them is that each value's size must be less than or equal to 32 KB. The total size of all keys and values must be less than 512 KB. - pub metadata: Option>, +pub struct CreateNodePoolRequest { + /// The node pool to create. + #[serde(rename="nodePool")] + pub node_pool: Option, } -impl Part for NodeConfig {} +impl RequestValue for CreateNodePoolRequest {} /// This operation resource represents operations that may have happened or are happening on the cluster. All fields are output only. @@ -413,9 +544,11 @@ impl Part for NodeConfig {} /// 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*). /// -/// * [zones clusters update projects](struct.ProjectZoneClusterUpdateCall.html) (response) -/// * [zones operations get projects](struct.ProjectZoneOperationGetCall.html) (response) +/// * [zones clusters node pools create projects](struct.ProjectZoneClusterNodePoolCreateCall.html) (response) /// * [zones clusters delete projects](struct.ProjectZoneClusterDeleteCall.html) (response) +/// * [zones operations get projects](struct.ProjectZoneOperationGetCall.html) (response) +/// * [zones clusters node pools delete projects](struct.ProjectZoneClusterNodePoolDeleteCall.html) (response) +/// * [zones clusters update projects](struct.ProjectZoneClusterUpdateCall.html) (response) /// * [zones clusters create projects](struct.ProjectZoneClusterCreateCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -445,49 +578,6 @@ pub struct Operation { impl ResponseResult for Operation {} -/// Container Engine service configuration. -/// -/// # 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*). -/// -/// * [zones get serverconfig projects](struct.ProjectZoneGetServerconfigCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ServerConfig { - /// Version of Kubernetes the service deploys by default. - #[serde(rename="defaultClusterVersion")] - pub default_cluster_version: Option, - /// List of valid node upgrade target versions. - #[serde(rename="validNodeVersions")] - pub valid_node_versions: Option>, -} - -impl ResponseResult for ServerConfig {} - - -/// ListOperationsResponse is the result of ListOperationsRequest. -/// -/// # 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*). -/// -/// * [zones operations list projects](struct.ProjectZoneOperationListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListOperationsResponse { - /// A list of operations in the project in the specified zone. - pub operations: Option>, - /// If any zones are listed here, the list of operations returned may be missing the operations from those zones. - #[serde(rename="missingZones")] - pub missing_zones: Option>, -} - -impl ResponseResult for ListOperationsResponse {} - - // ################### // MethodBuilders ### @@ -516,7 +606,7 @@ impl ResponseResult for ListOperationsResponse {} /// ::default(), None); /// let mut hub = Container::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `zones_clusters_create(...)`, `zones_clusters_delete(...)`, `zones_clusters_get(...)`, `zones_clusters_list(...)`, `zones_clusters_update(...)`, `zones_get_serverconfig(...)`, `zones_operations_get(...)` and `zones_operations_list(...)` +/// // like `zones_clusters_create(...)`, `zones_clusters_delete(...)`, `zones_clusters_get(...)`, `zones_clusters_list(...)`, `zones_clusters_node_pools_create(...)`, `zones_clusters_node_pools_delete(...)`, `zones_clusters_node_pools_get(...)`, `zones_clusters_node_pools_list(...)`, `zones_clusters_update(...)`, `zones_get_serverconfig(...)`, `zones_operations_get(...)` and `zones_operations_list(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } @@ -554,17 +644,44 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns configuration info about the Container Engine service. + /// Creates a node pool for a cluster. /// /// # Arguments /// - /// * `projectId` - The Google Developers Console [project ID or project number](https://support.google.com/cloud/answer/6158840). - /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) to return operations for. - pub fn zones_get_serverconfig(&self, project_id: &str, zone: &str) -> ProjectZoneGetServerconfigCall<'a, C, A> { - ProjectZoneGetServerconfigCall { + /// * `request` - No description provided. + /// * `projectId` - The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// * `clusterId` - The name of the cluster. + pub fn zones_clusters_node_pools_create(&self, request: CreateNodePoolRequest, project_id: &str, zone: &str, cluster_id: &str) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + ProjectZoneClusterNodePoolCreateCall { + hub: self.hub, + _request: request, + _project_id: project_id.to_string(), + _zone: zone.to_string(), + _cluster_id: cluster_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the node pool requested. + /// + /// # Arguments + /// + /// * `projectId` - The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// * `clusterId` - The name of the cluster. + /// * `nodePoolId` - The name of the node pool. + pub fn zones_clusters_node_pools_get(&self, project_id: &str, zone: &str, cluster_id: &str, node_pool_id: &str) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { + ProjectZoneClusterNodePoolGetCall { hub: self.hub, _project_id: project_id.to_string(), _zone: zone.to_string(), + _cluster_id: cluster_id.to_string(), + _node_pool_id: node_pool_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -594,14 +711,14 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all clusters owned by a project in either the specified zone or all zones. + /// Returns configuration info about the Container Engine service. /// /// # Arguments /// /// * `projectId` - The Google Developers Console [project ID or project number](https://support.google.com/cloud/answer/6158840). - /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides, or "-" for all zones. - pub fn zones_clusters_list(&self, project_id: &str, zone: &str) -> ProjectZoneClusterListCall<'a, C, A> { - ProjectZoneClusterListCall { + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) to return operations for. + pub fn zones_get_serverconfig(&self, project_id: &str, zone: &str) -> ProjectZoneGetServerconfigCall<'a, C, A> { + ProjectZoneGetServerconfigCall { hub: self.hub, _project_id: project_id.to_string(), _zone: zone.to_string(), @@ -611,6 +728,48 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Lists the node pools for a cluster. + /// + /// # Arguments + /// + /// * `projectId` - The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// * `clusterId` - The name of the cluster. + pub fn zones_clusters_node_pools_list(&self, project_id: &str, zone: &str, cluster_id: &str) -> ProjectZoneClusterNodePoolListCall<'a, C, A> { + ProjectZoneClusterNodePoolListCall { + hub: self.hub, + _project_id: project_id.to_string(), + _zone: zone.to_string(), + _cluster_id: cluster_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the specified operation. + /// + /// # Arguments + /// + /// * `projectId` - The Google Developers Console [project ID or project number](https://support.google.com/cloud/answer/6158840). + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// * `operationId` - The server-assigned `name` of the operation. + pub fn zones_operations_get(&self, project_id: &str, zone: &str, operation_id: &str) -> ProjectZoneOperationGetCall<'a, C, A> { + ProjectZoneOperationGetCall { + hub: self.hub, + _project_id: project_id.to_string(), + _zone: zone.to_string(), + _operation_id: operation_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists all operations in a project in a specific zone or all zones. @@ -676,19 +835,40 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets the specified operation. + /// Lists all clusters owned by a project in either the specified zone or all zones. /// /// # Arguments /// /// * `projectId` - The Google Developers Console [project ID or project number](https://support.google.com/cloud/answer/6158840). - /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. - /// * `operationId` - The server-assigned `name` of the operation. - pub fn zones_operations_get(&self, project_id: &str, zone: &str, operation_id: &str) -> ProjectZoneOperationGetCall<'a, C, A> { - ProjectZoneOperationGetCall { + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides, or "-" for all zones. + pub fn zones_clusters_list(&self, project_id: &str, zone: &str) -> ProjectZoneClusterListCall<'a, C, A> { + ProjectZoneClusterListCall { hub: self.hub, _project_id: project_id.to_string(), _zone: zone.to_string(), - _operation_id: operation_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a node pool from a cluster. + /// + /// # Arguments + /// + /// * `projectId` - The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// * `zone` - The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// * `clusterId` - The name of the cluster. + /// * `nodePoolId` - The name of the node pool to delete. + pub fn zones_clusters_node_pools_delete(&self, project_id: &str, zone: &str, cluster_id: &str, node_pool_id: &str) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + ProjectZoneClusterNodePoolDeleteCall { + hub: self.hub, + _project_id: project_id.to_string(), + _zone: zone.to_string(), + _cluster_id: cluster_id.to_string(), + _node_pool_id: node_pool_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -969,9 +1149,305 @@ impl<'a, C, A> ProjectZoneClusterGetCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Container::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 = CreateNodePoolRequest::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().zones_clusters_node_pools_create(req, "projectId", "zone", "clusterId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectZoneClusterNodePoolCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Container, + _request: CreateNodePoolRequest, + _project_id: String, + _zone: String, + _cluster_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectZoneClusterNodePoolCreateCall<'a, C, A> {} + +impl<'a, C, A> ProjectZoneClusterNodePoolCreateCall<'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: "container.projects.zones.clusters.nodePools.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(("zone", self._zone.to_string())); + params.push(("clusterId", self._cluster_id.to_string())); + for &field in ["alt", "projectId", "zone", "clusterId"].iter() { + if self._additional_params.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://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters/{clusterId}/nodePools".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{projectId}", "projectId"), ("{zone}", "zone"), ("{clusterId}", "clusterId")].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 ["clusterId", "zone", "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: CreateNodePoolRequest) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// + /// 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) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// + /// 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) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + self._zone = new_value.to_string(); + self + } + /// The name of the cluster. + /// + /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + self._cluster_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) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectZoneClusterNodePoolCreateCall<'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) -> ProjectZoneClusterNodePoolCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the node pool requested. +/// +/// A builder for the *zones.clusters.nodePools.get* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example @@ -995,28 +1471,30 @@ impl<'a, C, A> ProjectZoneClusterGetCall<'a, C, A> where C: BorrowMut +pub struct ProjectZoneClusterNodePoolGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Container, _project_id: String, _zone: String, + _cluster_id: String, + _node_pool_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectZoneGetServerconfigCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectZoneClusterNodePoolGetCall<'a, C, A> {} -impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectZoneClusterNodePoolGetCall<'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, ServerConfig)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, NodePool)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1024,12 +1502,14 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "container.projects.zones.getServerconfig", + dlg.begin(MethodInfo { id: "container.projects.zones.clusters.nodePools.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("projectId", self._project_id.to_string())); params.push(("zone", self._zone.to_string())); - for &field in ["alt", "projectId", "zone"].iter() { + params.push(("clusterId", self._cluster_id.to_string())); + params.push(("nodePoolId", self._node_pool_id.to_string())); + for &field in ["alt", "projectId", "zone", "clusterId", "nodePoolId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1041,12 +1521,12 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -1057,8 +1537,8 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(2); - for param_name in ["zone", "projectId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["nodePoolId", "clusterId", "zone", "projectId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -1144,33 +1624,53 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut ProjectZoneGetServerconfigCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { self._project_id = new_value.to_string(); self } - /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) to return operations for. + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. /// /// 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) -> ProjectZoneGetServerconfigCall<'a, C, A> { + pub fn zone(mut self, new_value: &str) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { self._zone = new_value.to_string(); self } + /// The name of the cluster. + /// + /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { + self._cluster_id = new_value.to_string(); + self + } + /// The name of the node pool. + /// + /// Sets the *node pool 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 node_pool_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { + self._node_pool_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) -> ProjectZoneGetServerconfigCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1197,7 +1697,7 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectZoneGetServerconfigCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1214,7 +1714,7 @@ impl<'a, C, A> ProjectZoneGetServerconfigCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectZoneGetServerconfigCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectZoneClusterNodePoolGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -1487,9 +1987,9 @@ impl<'a, C, A> ProjectZoneClusterDeleteCall<'a, C, A> where C: BorrowMut ProjectZoneClusterDeleteCall<'a, C, A> where C: BorrowMut +pub struct ProjectZoneGetServerconfigCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Container, @@ -1528,13 +2028,13 @@ pub struct ProjectZoneClusterListCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectZoneClusterListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectZoneGetServerconfigCall<'a, C, A> {} -impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectZoneGetServerconfigCall<'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, ListClustersResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ServerConfig)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1542,7 +2042,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "container.projects.zones.clusters.list", + dlg.begin(MethodInfo { id: "container.projects.zones.getServerconfig", 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())); @@ -1559,7 +2059,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut ProjectZoneClusterListCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectZoneGetServerconfigCall<'a, C, A> { self._project_id = new_value.to_string(); self } - /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides, or "-" for all zones. + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) to return operations for. /// /// 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) -> ProjectZoneClusterListCall<'a, C, A> { + pub fn zone(mut self, new_value: &str) -> ProjectZoneGetServerconfigCall<'a, C, A> { self._zone = new_value.to_string(); self } @@ -1688,7 +2188,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut ProjectZoneClusterListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectZoneGetServerconfigCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1715,7 +2215,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectZoneClusterListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectZoneGetServerconfigCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1732,7 +2232,537 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectZoneClusterListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectZoneGetServerconfigCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the node pools for a cluster. +/// +/// A builder for the *zones.clusters.nodePools.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_container1 as container1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use container1::Container; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Container::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().zones_clusters_node_pools_list("projectId", "zone", "clusterId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectZoneClusterNodePoolListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Container, + _project_id: String, + _zone: String, + _cluster_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectZoneClusterNodePoolListCall<'a, C, A> {} + +impl<'a, C, A> ProjectZoneClusterNodePoolListCall<'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, ListNodePoolsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "container.projects.zones.clusters.nodePools.list", + 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(("zone", self._zone.to_string())); + params.push(("clusterId", self._cluster_id.to_string())); + for &field in ["alt", "projectId", "zone", "clusterId"].iter() { + if self._additional_params.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://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters/{clusterId}/nodePools".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{projectId}", "projectId"), ("{zone}", "zone"), ("{clusterId}", "clusterId")].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 ["clusterId", "zone", "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) + } + } + } + } + + + /// The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// + /// 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) -> ProjectZoneClusterNodePoolListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// + /// 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) -> ProjectZoneClusterNodePoolListCall<'a, C, A> { + self._zone = new_value.to_string(); + self + } + /// The name of the cluster. + /// + /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolListCall<'a, C, A> { + self._cluster_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) -> ProjectZoneClusterNodePoolListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectZoneClusterNodePoolListCall<'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) -> ProjectZoneClusterNodePoolListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the specified operation. +/// +/// A builder for the *zones.operations.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_container1 as container1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use container1::Container; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Container::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().zones_operations_get("projectId", "zone", "operationId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectZoneOperationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Container, + _project_id: String, + _zone: String, + _operation_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectZoneOperationGetCall<'a, C, A> {} + +impl<'a, C, A> ProjectZoneOperationGetCall<'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: "container.projects.zones.operations.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(("zone", self._zone.to_string())); + params.push(("operationId", self._operation_id.to_string())); + for &field in ["alt", "projectId", "zone", "operationId"].iter() { + if self._additional_params.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://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/operations/{operationId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{projectId}", "projectId"), ("{zone}", "zone"), ("{operationId}", "operationId")].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 ["operationId", "zone", "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) + } + } + } + } + + + /// The Google Developers Console [project ID or project number](https://support.google.com/cloud/answer/6158840). + /// + /// 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) -> ProjectZoneOperationGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// + /// 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) -> ProjectZoneOperationGetCall<'a, C, A> { + self._zone = new_value.to_string(); + self + } + /// The server-assigned `name` of the operation. + /// + /// Sets the *operation 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 operation_id(mut self, new_value: &str) -> ProjectZoneOperationGetCall<'a, C, A> { + self._operation_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) -> ProjectZoneOperationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectZoneOperationGetCall<'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) -> ProjectZoneOperationGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -2573,9 +3603,9 @@ impl<'a, C, A> ProjectZoneClusterUpdateCall<'a, C, A> where C: BorrowMut ProjectZoneClusterUpdateCall<'a, C, A> where C: BorrowMut +pub struct ProjectZoneClusterListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Container, _project_id: String, _zone: String, - _operation_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectZoneOperationGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectZoneClusterListCall<'a, C, A> {} -impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectZoneClusterListCall<'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)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListClustersResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2629,13 +3658,12 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "container.projects.zones.operations.get", + dlg.begin(MethodInfo { id: "container.projects.zones.clusters.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("projectId", self._project_id.to_string())); params.push(("zone", self._zone.to_string())); - params.push(("operationId", self._operation_id.to_string())); - for &field in ["alt", "projectId", "zone", "operationId"].iter() { + for &field in ["alt", "projectId", "zone"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2647,12 +3675,12 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -2663,8 +3691,8 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(3); - for param_name in ["operationId", "zone", "projectId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["zone", "projectId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -2756,37 +3784,27 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut ProjectZoneOperationGetCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectZoneClusterListCall<'a, C, A> { self._project_id = new_value.to_string(); self } - /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides, or "-" for all zones. /// /// 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) -> ProjectZoneOperationGetCall<'a, C, A> { + pub fn zone(mut self, new_value: &str) -> ProjectZoneClusterListCall<'a, C, A> { self._zone = new_value.to_string(); self } - /// The server-assigned `name` of the operation. - /// - /// Sets the *operation 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 operation_id(mut self, new_value: &str) -> ProjectZoneOperationGetCall<'a, C, A> { - self._operation_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) -> ProjectZoneOperationGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectZoneClusterListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -2813,7 +3831,7 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectZoneOperationGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectZoneClusterListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -2830,7 +3848,284 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectZoneOperationGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectZoneClusterListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a node pool from a cluster. +/// +/// A builder for the *zones.clusters.nodePools.delete* 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_container1 as container1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use container1::Container; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Container::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().zones_clusters_node_pools_delete("projectId", "zone", "clusterId", "nodePoolId") +/// .doit(); +/// # } +/// ``` +pub struct ProjectZoneClusterNodePoolDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Container, + _project_id: String, + _zone: String, + _cluster_id: String, + _node_pool_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectZoneClusterNodePoolDeleteCall<'a, C, A> {} + +impl<'a, C, A> ProjectZoneClusterNodePoolDeleteCall<'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: "container.projects.zones.clusters.nodePools.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("projectId", self._project_id.to_string())); + params.push(("zone", self._zone.to_string())); + params.push(("clusterId", self._cluster_id.to_string())); + params.push(("nodePoolId", self._node_pool_id.to_string())); + for &field in ["alt", "projectId", "zone", "clusterId", "nodePoolId"].iter() { + if self._additional_params.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://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters/{clusterId}/nodePools/{nodePoolId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{projectId}", "projectId"), ("{zone}", "zone"), ("{clusterId}", "clusterId"), ("{nodePoolId}", "nodePoolId")].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 ["nodePoolId", "clusterId", "zone", "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::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) + } + } + } + } + + + /// The Google Developers Console [project ID or project number](https://developers.google.com/console/help/new/#projectnumber). + /// + /// 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) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// The name of the Google Compute Engine [zone](/compute/docs/zones#available) in which the cluster resides. + /// + /// 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) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + self._zone = new_value.to_string(); + self + } + /// The name of the cluster. + /// + /// Sets the *cluster 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 cluster_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + self._cluster_id = new_value.to_string(); + self + } + /// The name of the node pool to delete. + /// + /// Sets the *node pool 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 node_pool_id(mut self, new_value: &str) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + self._node_pool_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) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectZoneClusterNodePoolDeleteCall<'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) -> ProjectZoneClusterNodePoolDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self diff --git a/gen/content2-cli/Cargo.toml b/gen/content2-cli/Cargo.toml index 1d995a001c..3e3cadd247 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+20160331" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "content2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-content2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-content2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-content2] diff --git a/gen/content2-cli/README.md b/gen/content2-cli/README.md index 4874229c62..02b056d0fe 100644 --- a/gen/content2-cli/README.md +++ b/gen/content2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Shopping Content* API at revision *20160331*. 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 *0.3.6*. ```bash content2 [options] @@ -94,6 +94,13 @@ content2 [options] custombatch (-r )... [-p ]... [-o ] get [-p ]... [-o ] list [-p ]... [-o ] + shippingsettings + custombatch (-r )... [-p ]... [-o ] + get [-p ]... [-o ] + getsupportedcarriers [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] content2 --help Configuration: diff --git a/gen/content2-cli/mkdocs.yml b/gen/content2-cli/mkdocs.yml index 95a1f8b721..dc4bb8d4b6 100644 --- a/gen/content2-cli/mkdocs.yml +++ b/gen/content2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Shopping Content v0.3.6+20160331 +site_name: Shopping Content v0.3.6+20160905 site_url: http://byron.github.io/google-apis-rs/google-content2-cli site_description: Write integrating applications with bcore @@ -65,6 +65,12 @@ pages: - ['productstatuses_custombatch.md', 'Productstatuses', 'Custombatch'] - ['productstatuses_get.md', 'Productstatuses', 'Get'] - ['productstatuses_list.md', 'Productstatuses', 'List'] +- ['shippingsettings_custombatch.md', 'Shippingsettings', 'Custombatch'] +- ['shippingsettings_get.md', 'Shippingsettings', 'Get'] +- ['shippingsettings_getsupportedcarriers.md', 'Shippingsettings', 'Getsupportedcarriers'] +- ['shippingsettings_list.md', 'Shippingsettings', 'List'] +- ['shippingsettings_patch.md', 'Shippingsettings', 'Patch'] +- ['shippingsettings_update.md', 'Shippingsettings', 'Update'] theme: readthedocs diff --git a/gen/content2-cli/src/main.rs b/gen/content2-cli/src/main.rs index 14b6965500..b3540751c2 100644 --- a/gen/content2-cli/src/main.rs +++ b/gen/content2-cli/src/main.rs @@ -3937,7 +3937,7 @@ impl<'n> Engine<'n> { "size-type" => Some(("sizeType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "offer-id" => Some(("offerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "title" => Some(("title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "pattern" => Some(("pattern", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "additional-product-types" => Some(("additionalProductTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "unit-pricing-measure.value" => Some(("unitPricingMeasure.value", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "unit-pricing-measure.unit" => Some(("unitPricingMeasure.unit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "validated-destinations" => Some(("validatedDestinations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), @@ -3988,6 +3988,7 @@ impl<'n> Engine<'n> { "sale-price.currency" => Some(("salePrice.currency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "sale-price.value" => Some(("salePrice.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "product-type" => Some(("productType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pattern" => Some(("pattern", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "loyalty-points.ratio" => Some(("loyaltyPoints.ratio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "loyalty-points.name" => Some(("loyaltyPoints.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "loyalty-points.points-value" => Some(("loyaltyPoints.pointsValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -3996,7 +3997,7 @@ impl<'n> Engine<'n> { "age-group" => Some(("ageGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "display-ads-title" => Some(("displayAdsTitle", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-image-links", "adult", "adwords-grouping", "adwords-labels", "adwords-redirect", "age-group", "amount", "availability", "availability-date", "brand", "channel", "color", "condition", "content-language", "currency", "custom-label0", "custom-label1", "custom-label2", "custom-label3", "custom-label4", "description", "display-ads-id", "display-ads-link", "display-ads-similar-ids", "display-ads-title", "display-ads-value", "energy-efficiency-class", "expiration-date", "gender", "google-product-category", "gtin", "id", "identifier-exists", "image-link", "installment", "is-bundle", "item-group-id", "kind", "link", "loyalty-points", "material", "mobile-link", "months", "mpn", "multipack", "name", "offer-id", "online-only", "pattern", "points-value", "price", "product-type", "promotion-ids", "ratio", "sale-price", "sale-price-effective-date", "sell-on-google-quantity", "shipping-height", "shipping-label", "shipping-length", "shipping-weight", "shipping-width", "size-system", "size-type", "sizes", "target-country", "title", "unit", "unit-pricing-base-measure", "unit-pricing-measure", "validated-destinations", "value"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-image-links", "additional-product-types", "adult", "adwords-grouping", "adwords-labels", "adwords-redirect", "age-group", "amount", "availability", "availability-date", "brand", "channel", "color", "condition", "content-language", "currency", "custom-label0", "custom-label1", "custom-label2", "custom-label3", "custom-label4", "description", "display-ads-id", "display-ads-link", "display-ads-similar-ids", "display-ads-title", "display-ads-value", "energy-efficiency-class", "expiration-date", "gender", "google-product-category", "gtin", "id", "identifier-exists", "image-link", "installment", "is-bundle", "item-group-id", "kind", "link", "loyalty-points", "material", "mobile-link", "months", "mpn", "multipack", "name", "offer-id", "online-only", "pattern", "points-value", "price", "product-type", "promotion-ids", "ratio", "sale-price", "sale-price-effective-date", "sell-on-google-quantity", "shipping-height", "shipping-label", "shipping-length", "shipping-weight", "shipping-width", "size-system", "size-type", "sizes", "target-country", "title", "unit", "unit-pricing-base-measure", "unit-pricing-measure", "validated-destinations", "value"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -4320,6 +4321,435 @@ impl<'n> Engine<'n> { } } + fn _shippingsettings_custombatch(&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::ShippingsettingsCustomBatchRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.shippingsettings().custombatch(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 { + "dry-run" => { + call = call.dry_run(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); + }, + _ => { + 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(["dry-run"].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 _shippingsettings_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.shippingsettings().get(opt.value_of("merchant-id").unwrap_or(""), opt.value_of("account-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 _shippingsettings_getsupportedcarriers(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.shippingsettings().getsupportedcarriers(opt.value_of("merchant-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 _shippingsettings_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.shippingsettings().list(opt.value_of("merchant-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("")); + }, + "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(["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 _shippingsettings_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()[..] { + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id"]); + 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::ShippingSettings = json::value::from_value(object).unwrap(); + let mut call = self.hub.shippingsettings().patch(request, opt.value_of("merchant-id").unwrap_or(""), opt.value_of("account-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 { + "dry-run" => { + call = call.dry_run(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); + }, + _ => { + 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(["dry-run"].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 _shippingsettings_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()[..] { + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id"]); + 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::ShippingSettings = json::value::from_value(object).unwrap(); + let mut call = self.hub.shippingsettings().update(request, opt.value_of("merchant-id").unwrap_or(""), opt.value_of("account-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 { + "dry-run" => { + call = call.dry_run(arg_from_str(value.unwrap_or("false"), err, "dry-run", "boolean")); + }, + _ => { + 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(["dry-run"].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(()); @@ -4573,6 +5003,32 @@ impl<'n> Engine<'n> { } } }, + ("shippingsettings", Some(opt)) => { + match opt.subcommand() { + ("custombatch", Some(opt)) => { + call_result = self._shippingsettings_custombatch(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._shippingsettings_get(opt, dry_run, &mut err); + }, + ("getsupportedcarriers", Some(opt)) => { + call_result = self._shippingsettings_getsupportedcarriers(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._shippingsettings_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._shippingsettings_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._shippingsettings_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("shippingsettings".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, _ => { err.issues.push(CLIError::MissingCommandError); writeln!(io::stderr(), "{}\n", self.opt.usage()).ok(); @@ -6217,11 +6673,176 @@ fn main() { ]), ]), + ("shippingsettings", "methods: 'custombatch', 'get', 'getsupportedcarriers', 'list', 'patch' and 'update'", vec![ + ("custombatch", + Some(r##"Retrieves and updates the shipping settings of multiple accounts in a single request."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_custombatch", + 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)), + ]), + ("get", + Some(r##"Retrieves the shipping settings of the account."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_get", + vec![ + (Some(r##"merchant-id"##), + None, + Some(r##"The ID of the managing account."##), + Some(true), + Some(false)), + + (Some(r##"account-id"##), + None, + Some(r##"The ID of the account for which to get/update shipping settings."##), + 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)), + ]), + ("getsupportedcarriers", + Some(r##"Retrieves supported carriers and carrier services for an account."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_getsupportedcarriers", + vec![ + (Some(r##"merchant-id"##), + None, + Some(r##"The ID of the account for which to retrieve the supported carriers."##), + 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##"Lists the shipping settings of the sub-accounts in your Merchant Center account."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_list", + vec![ + (Some(r##"merchant-id"##), + None, + Some(r##"The ID of the managing account."##), + 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 shipping settings of the account. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_patch", + vec![ + (Some(r##"merchant-id"##), + None, + Some(r##"The ID of the managing account."##), + Some(true), + Some(false)), + + (Some(r##"account-id"##), + None, + Some(r##"The ID of the account for which to get/update shipping settings."##), + 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 shipping settings of the account."##), + "Details at http://byron.github.io/google-apis-rs/google_content2_cli/shippingsettings_update", + vec![ + (Some(r##"merchant-id"##), + None, + Some(r##"The ID of the managing account."##), + Some(true), + Some(false)), + + (Some(r##"account-id"##), + None, + Some(r##"The ID of the account for which to get/update shipping settings."##), + 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("content2") .author("Sebastian Thiel ") - .version("0.3.6+20160331") + .version("0.3.6+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/Cargo.toml b/gen/content2/Cargo.toml index f396f229f5..1f05479e13 100644 --- a/gen/content2/Cargo.toml +++ b/gen/content2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/content2/README.md b/gen/content2/README.md index 7e0b36620d..63c97ed76f 100644 --- a/gen/content2/README.md +++ b/gen/content2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-content2` library allows access to all features of the *Google Shopping Content* service. -This documentation was generated from *Shopping Content* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Shopping Content* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Shopping Content* *v2* API can be found at the [official documentation site](https://developers.google.com/shopping-content). @@ -33,6 +33,8 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*custombatch*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductCustombatchCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductListCall.html) * productstatuses * [*custombatch*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductstatuseCustombatchCall.html), [*get*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductstatuseGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_content2/struct.ProductstatuseListCall.html) +* shippingsettings + * [*custombatch*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingCustombatchCall.html), [*get*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingGetCall.html), [*getsupportedcarriers*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingGetsupportedcarrierCall.html), [*list*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_content2/struct.ShippingsettingUpdateCall.html) diff --git a/gen/content2/src/lib.rs b/gen/content2/src/lib.rs index 6823eed56d..5761211531 100644 --- a/gen/content2/src/lib.rs +++ b/gen/content2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Shopping Content* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Shopping Content* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *content:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Shopping Content* *v2* API can be found at the //! [official documentation site](https://developers.google.com/shopping-content). @@ -31,6 +31,8 @@ //! * [*custombatch*](struct.ProductCustombatchCall.html), [*delete*](struct.ProductDeleteCall.html), [*get*](struct.ProductGetCall.html), [*insert*](struct.ProductInsertCall.html) and [*list*](struct.ProductListCall.html) //! * productstatuses //! * [*custombatch*](struct.ProductstatuseCustombatchCall.html), [*get*](struct.ProductstatuseGetCall.html) and [*list*](struct.ProductstatuseListCall.html) +//! * shippingsettings +//! * [*custombatch*](struct.ShippingsettingCustombatchCall.html), [*get*](struct.ShippingsettingGetCall.html), [*getsupportedcarriers*](struct.ShippingsettingGetsupportedcarrierCall.html), [*list*](struct.ShippingsettingListCall.html), [*patch*](struct.ShippingsettingPatchCall.html) and [*update*](struct.ShippingsettingUpdateCall.html) //! //! //! @@ -126,13 +128,13 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.orders().list("merchantId") -//! .add_statuses("dolor") -//! .placed_date_start("diam") -//! .placed_date_end("kasd") -//! .page_token("invidunt") +//! .add_statuses("sit") +//! .placed_date_start("takimata") +//! .placed_date_end("elitr") +//! .page_token("nonumy") //! .order_by("rebum.") -//! .max_results(50) -//! .acknowledged(false) +//! .max_results(95) +//! .acknowledged(true) //! .doit(); //! //! match result { diff --git a/gen/content2/src/lib.rs.in b/gen/content2/src/lib.rs.in index 56cfe9470c..8c56e044a5 100644 --- a/gen/content2/src/lib.rs.in +++ b/gen/content2/src/lib.rs.in @@ -168,6 +168,9 @@ impl<'a, C, A> ShoppingContent pub fn productstatuses(&'a self) -> ProductstatuseMethods<'a, C, A> { ProductstatuseMethods { hub: &self } } + pub fn shippingsettings(&'a self) -> ShippingsettingMethods<'a, C, A> { + ShippingsettingMethods { 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`. @@ -222,24 +225,53 @@ pub struct Errors { impl Part for Errors {} -/// A batch entry encoding a single non-batch products response. +/// 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 ProductsCustomBatchResponseEntry { - /// The ID of the request entry this entry responds to. - #[serde(rename="batchId")] - pub batch_id: Option, - /// Identifies what kind of resource this is. Value: the fixed string "content#productsCustomBatchResponseEntry". - pub kind: Option, - /// A list of errors defined if and only if the request failed. - pub errors: Option, - /// The inserted product. Only defined if the method is insert and if the request was successful. - pub product: Option, +pub struct Service { + /// The CLDR code of the currency to which this service applies. Must match that of the prices in rate groups. + pub currency: Option, + /// Free-form name of the service. Must be unique within target account. Required. + pub name: Option, + /// Time spent in various aspects from order to the delivery of the product. Required. + #[serde(rename="deliveryTime")] + pub delivery_time: Option, + /// A boolean exposing the active status of the shipping service. Required. + pub active: Option, + /// The CLDR territory code of the country to which the service applies. Required. + #[serde(rename="deliveryCountry")] + pub delivery_country: Option, + /// Shipping rate group definitions. Only the last one is allowed to have an empty applicableShippingLabels, which means "everything else". The other applicableShippingLabels must not overlap. + #[serde(rename="rateGroups")] + pub rate_groups: Option>, } -impl Part for ProductsCustomBatchResponseEntry {} +impl Part for Service {} + + +/// 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 shippingsettings](struct.ShippingsettingListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShippingsettingsListResponse { + /// The token for the retrieval of the next page of shipping settings. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "content#shippingsettingsListResponse". + pub kind: Option, + /// no description provided + pub resources: Option>, +} + +impl ResponseResult for ShippingsettingsListResponse {} /// An error returned by the API. @@ -275,6 +307,43 @@ pub struct AccountUser { impl Part for AccountUser {} +/// A batch entry encoding a single non-batch products response. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductsCustomBatchResponseEntry { + /// The ID of the request entry this entry responds to. + #[serde(rename="batchId")] + pub batch_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "content#productsCustomBatchResponseEntry". + pub kind: Option, + /// A list of errors defined if and only if the request failed. + pub errors: Option, + /// The inserted product. Only defined if the method is insert and if the request was successful. + pub product: Option, +} + +impl Part for ProductsCustomBatchResponseEntry {} + + +/// 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 DeliveryTime { + /// Maximum number of business days that is spent in transit. 0 means same day delivery, 1 means next day delivery. Must be greater than or equal to minTransitTimeInDays. Required. + #[serde(rename="maxTransitTimeInDays")] + pub max_transit_time_in_days: Option, + /// Minimum number of business days that is spent in transit. 0 means same day delivery, 1 means next day delivery. Required. + #[serde(rename="minTransitTimeInDays")] + pub min_transit_time_in_days: Option, +} + +impl Part for DeliveryTime {} + + /// There is no detailed description. /// /// # Activities @@ -339,7 +408,7 @@ impl ResponseResult for ProductStatus {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TestOrderCustomer { - /// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. Optional. + /// If set, this indicates the user explicitly chose to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. Optional. #[serde(rename="explicitMarketingPreference")] pub explicit_marketing_preference: Option, /// Full name of the customer. @@ -528,6 +597,32 @@ pub struct ProductShippingDimension { impl Part for ProductShippingDimension {} +/// The single value of a rate group or the value of a rate group table's cell. Exactly one of noShipping, flatRate, pricePercentage, carrierRateName, subtableName must be set. +/// +/// 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 { + /// The name of a carrier rate referring to a carrier rate defined in the same rate group. Can only be set if all other fields are not set. + #[serde(rename="carrierRateName")] + pub carrier_rate_name: Option, + /// If true, then the product can't ship. Must be true when set, can only be set if all other fields are not set. + #[serde(rename="noShipping")] + pub no_shipping: Option, + /// A percentage of the price represented as a number in decimal notation (e.g., "5.4"). Can only be set if all other fields are not set. + #[serde(rename="pricePercentage")] + pub price_percentage: Option, + /// A flat rate. Can only be set if all other fields are not set. + #[serde(rename="flatRate")] + pub flat_rate: Option, + /// The name of a subtable. Can only be set in table cells (i.e., not for single values), and only if all other fields are not set. + #[serde(rename="subtableName")] + pub subtable_name: Option, +} + +impl Part for Value {} + + /// There is no detailed description. /// /// # Activities @@ -551,6 +646,29 @@ pub struct OrdersListResponse { impl ResponseResult for OrdersListResponse {} +/// A non-empty list of row or column headers for a table. Exactly one of prices, weights, numItems, postalCodeGroupNames, or locations must be set. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Headers { + /// be "infinity". For example [{"value": "10", "currency": "USD"}, {"value": "500", "currency": "USD"}, {"value": "infinity", "currency": "USD"}] represents the headers "<= $10", " $500". All prices within a service must have the same currency. Must be non-empty. Can only be set if all other fields are not set. + pub prices: Option>, + /// A list of postal group names. The last value can be "all other locations". Example: ["zone 1", "zone 2", "all other locations"]. The referred postal code groups must match the delivery country of the service. Must be non-empty. Can only be set if all other fields are not set. + #[serde(rename="postalCodeGroupNames")] + pub postal_code_group_names: Option>, + /// be "infinity". For example [{"value": "10", "unit": "kg"}, {"value": "50", "unit": "kg"}, {"value": "infinity", "unit": "kg"}] represents the headers "<= 10kg", " 50kg". All weights within a service must have the same unit. Must be non-empty. Can only be set if all other fields are not set. + pub weights: Option>, + /// A list of location ID sets. Must be non-empty. Can only be set if all other fields are not set. + pub locations: Option>, + /// A list of inclusive number of items upper bounds. The last value can be "infinity". For example ["10", "50", "infinity"] represents the headers "<= 10 items", " 50 items". Must be non-empty. Can only be set if all other fields are not set. + #[serde(rename="numberOfItems")] + pub number_of_items: Option>, +} + +impl Part for Headers {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -785,6 +903,21 @@ pub struct TestOrderPaymentMethod { impl Part for TestOrderPaymentMethod {} +/// 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 ProductCustomGroup { + /// The sub-attributes. + pub attributes: Option>, + /// The name of the group. Underscores will be replaced by spaces upon insertion. + pub name: Option, +} + +impl Part for ProductCustomGroup {} + + /// There is no detailed description. /// /// # Activities @@ -923,6 +1056,24 @@ pub struct DatafeedstatusesListResponse { impl ResponseResult for DatafeedstatusesListResponse {} +/// 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 PostalCodeGroup { + /// A range of postal codes. Required. + #[serde(rename="postalCodeRanges")] + pub postal_code_ranges: Option>, + /// The CLDR territory code of the country the postal code group applies to. Required. + pub country: Option, + /// The name of the postal code group, referred to in headers. Required. + pub name: Option, +} + +impl Part for PostalCodeGroup {} + + /// There is no detailed description. /// /// # Activities @@ -1079,6 +1230,29 @@ pub struct AccounttaxCustomBatchRequest { impl RequestValue for AccounttaxCustomBatchRequest {} +/// 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 accountstatuses](struct.AccountstatuseListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountstatusesListResponse { + /// The token for the retrieval of the next page of account statuses. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "content#accountstatusesListResponse". + pub kind: Option, + /// no description provided + pub resources: Option>, +} + +impl ResponseResult for AccountstatusesListResponse {} + + /// There is no detailed description. /// /// # Activities @@ -1100,6 +1274,41 @@ pub struct OrdersUpdateMerchantOrderIdResponse { impl ResponseResult for OrdersUpdateMerchantOrderIdResponse {} +/// 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*). +/// +/// * [custombatch shippingsettings](struct.ShippingsettingCustombatchCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShippingsettingsCustomBatchRequest { + /// The request entries to be processed in the batch. + pub entries: Option>, +} + +impl RequestValue for ShippingsettingsCustomBatchRequest {} + + +/// 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 CarriersCarrier { + /// A list of supported services (e.g., "ground") for that carrier. Contains at least one service. + pub services: Option>, + /// The CLDR country code of the carrier (e.g., "US"). Always present. + pub country: Option, + /// The name of the carrier (e.g., "UPS"). Always present. + pub name: Option, +} + +impl Part for CarriersCarrier {} + + /// An error occurring in the feed, like "invalid price". /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1119,27 +1328,6 @@ pub struct DatafeedStatusError { impl Part for DatafeedStatusError {} -/// 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*). -/// -/// * [cancellineitem orders](struct.OrderCancellineitemCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OrdersCancelLineItemResponse { - /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelLineItemResponse". - pub kind: Option, - /// The status of the execution. - #[serde(rename="executionStatus")] - pub execution_status: Option, -} - -impl ResponseResult for OrdersCancelLineItemResponse {} - - /// There is no detailed description. /// /// # Activities @@ -1220,7 +1408,7 @@ impl Part for OrderLineItemProductVariantAttribute {} pub struct OrderCancellation { /// The quantity that was canceled. pub quantity: Option, - /// The reason for the cancellation. + /// The reason for the cancellation. Orders that are cancelled with a noInventory reason will lead to the removal of the product from POG until you make an update to that product. This will not affect your Shopping ads. pub reason: Option, /// Date on which the cancellation has been created, in ISO 8601 format. #[serde(rename="creationDate")] @@ -1406,6 +1594,14 @@ impl Part for ProductStatusDataQualityIssue {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountShippingShippingService { + /// The minimum number of days in transit. Must be a value between 0 and maxDaysIntransit included. A value of 0 means same day delivery. + #[serde(rename="minDaysInTransit")] + pub min_days_in_transit: Option, + /// The name of this shipping service. + pub name: Option, + /// The maximum number of days in transit. Must be a value between 0 and 250 included. A value of 0 means same day delivery. + #[serde(rename="maxDaysInTransit")] + pub max_days_in_transit: Option, /// Whether the shipping service is available. pub active: Option, /// Decision tree for "complicated" shipping cost calculation. @@ -1417,8 +1613,6 @@ pub struct AccountShippingShippingService { /// Calculation method for the "simple" case that needs no rules. #[serde(rename="calculationMethod")] pub calculation_method: Option, - /// The name of this shipping service. - pub name: Option, } impl Part for AccountShippingShippingService {} @@ -1634,6 +1828,34 @@ pub struct AccountshippingCustomBatchRequest { impl RequestValue for AccountshippingCustomBatchRequest {} +/// 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 CarrierRate { + /// Shipping origin for this carrier rate. Required. + #[serde(rename="originPostalCode")] + pub origin_postal_code: Option, + /// Additive shipping rate modifier. Can be negative. For example { "value": "1", "currency" : "USD" } adds $1 to the rate, { "value": "-3", "currency" : "USD" } removes $3 from the rate. Optional. + #[serde(rename="flatAdjustment")] + pub flat_adjustment: Option, + /// Name of the carrier rate. Must be unique per rate group. Required. + pub name: Option, + /// Carrier service, such as "UPS" or "Fedex". The list of supported carriers can be retrieved via the getSupportedCarriers method. Required. + #[serde(rename="carrierName")] + pub carrier_name: Option, + /// Carrier service, such as "ground" or "2 days". The list of supported services for a carrier can be retrieved via the getSupportedCarriers method. Required. + #[serde(rename="carrierService")] + pub carrier_service: Option, + /// Multiplicative shipping rate modifier as a number in decimal notation. Can be negative. For example "5.4" increases the rate by 5.4%, "-3" decreases the rate by 3%. Optional. + #[serde(rename="percentageAdjustment")] + pub percentage_adjustment: Option, +} + +impl Part for CarrierRate {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1652,6 +1874,19 @@ pub struct LoyaltyPoints { impl Part for LoyaltyPoints {} +/// 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 Row { + /// The list of cells that constitute the row. Must have the same length as columnHeaders for two-dimensional tables, a length of 1 for one-dimensional tables. Required. + pub cells: Option>, +} + +impl Part for Row {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1733,26 +1968,21 @@ pub struct AccountstatusesCustomBatchRequestEntry { impl Part for AccountstatusesCustomBatchRequestEntry {} -/// A batch entry encoding a single non-batch productstatuses request. +/// 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 ProductstatusesCustomBatchRequestEntry { - /// An entry ID, unique within the batch request. - #[serde(rename="batchId")] - pub batch_id: Option, - /// The ID of the managing account. +pub struct AccountIdentifier { + /// The aggregator ID, set for aggregators and subaccounts (in that case, it represents the aggregator of the subaccount). + #[serde(rename="aggregatorId")] + pub aggregator_id: Option, + /// The merchant account ID, set for individual accounts and subaccounts. #[serde(rename="merchantId")] pub merchant_id: Option, - /// no description provided - pub method: Option, - /// The ID of the product whose status to get. - #[serde(rename="productId")] - pub product_id: Option, } -impl Part for ProductstatusesCustomBatchRequestEntry {} +impl Part for AccountIdentifier {} /// There is no detailed description. @@ -1858,21 +2088,51 @@ pub struct AccountShippingLocationGroup { impl Part for AccountShippingLocationGroup {} +/// A batch entry encoding a single non-batch productstatuses request. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProductstatusesCustomBatchRequestEntry { + /// An entry ID, unique within the batch request. + #[serde(rename="batchId")] + pub batch_id: Option, + /// The ID of the managing account. + #[serde(rename="merchantId")] + pub merchant_id: Option, + /// no description provided + pub method: Option, + /// The ID of the product whose status to get. + #[serde(rename="productId")] + pub product_id: Option, +} + +impl Part for ProductstatusesCustomBatchRequestEntry {} + + /// 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 AccountIdentifier { - /// The aggregator ID, set for aggregators and subaccounts (in that case, it represents the aggregator of the subaccount). - #[serde(rename="aggregatorId")] - pub aggregator_id: Option, - /// The merchant account ID, set for individual accounts and subaccounts. - #[serde(rename="merchantId")] - pub merchant_id: Option, +pub struct RateGroup { + /// A list of shipping labels defining the products to which this rate group applies to. This is a disjunction: only one of the labels has to match for the rate group to apply. May only be empty for the last rate group of a service. Required. + #[serde(rename="applicableShippingLabels")] + pub applicable_shipping_labels: Option>, + /// A list of carrier rates that can be referred to by mainTable or singleValue. + #[serde(rename="carrierRates")] + pub carrier_rates: Option>, + /// The value of the rate group (e.g. flat rate $10). Can only be set if mainTable and subtables are not set. + #[serde(rename="singleValue")] + pub single_value: Option, + /// A list of subtables referred to by mainTable. Can only be set if mainTable is set. + pub subtables: Option>, + /// A table defining the rate group, when singleValue is not expressive enough. Can only be set if singleValue is not set. + #[serde(rename="mainTable")] + pub main_table: Option, } -impl Part for AccountIdentifier {} +impl Part for RateGroup {} /// The status of a datafeed, i.e., the result of the last retrieval of the datafeed computed asynchronously when the feed processing is finished. @@ -1937,19 +2197,26 @@ pub struct OrderPromotionBenefit { impl Part for OrderPromotionBenefit {} -/// There is no detailed description. +/// A batch entry encoding a single non-batch datafeedstatuses request. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ProductCustomGroup { - /// The sub-attributes. - pub attributes: Option>, - /// The name of the group. Underscores will be replaced by spaces upon insertion. - pub name: Option, +pub struct DatafeedstatusesCustomBatchRequestEntry { + /// An entry ID, unique within the batch request. + #[serde(rename="batchId")] + pub batch_id: Option, + /// The ID of the data feed to get or delete. + #[serde(rename="datafeedId")] + pub datafeed_id: Option, + /// The ID of the managing account. + #[serde(rename="merchantId")] + pub merchant_id: Option, + /// no description provided + pub method: Option, } -impl Part for ProductCustomGroup {} +impl Part for DatafeedstatusesCustomBatchRequestEntry {} /// There is no detailed description. @@ -2027,26 +2294,25 @@ pub struct InventoryCustomBatchResponseEntry { impl Part for InventoryCustomBatchResponseEntry {} -/// A batch entry encoding a single non-batch datafeedstatuses request. +/// There is no detailed description. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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*). +/// +/// * [cancellineitem orders](struct.OrderCancellineitemCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct DatafeedstatusesCustomBatchRequestEntry { - /// An entry ID, unique within the batch request. - #[serde(rename="batchId")] - pub batch_id: Option, - /// The ID of the data feed to get or delete. - #[serde(rename="datafeedId")] - pub datafeed_id: Option, - /// The ID of the managing account. - #[serde(rename="merchantId")] - pub merchant_id: Option, - /// no description provided - pub method: Option, +pub struct OrdersCancelLineItemResponse { + /// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelLineItemResponse". + pub kind: Option, + /// The status of the execution. + #[serde(rename="executionStatus")] + pub execution_status: Option, } -impl Part for DatafeedstatusesCustomBatchRequestEntry {} +impl ResponseResult for OrdersCancelLineItemResponse {} /// There is no detailed description. @@ -2055,7 +2321,7 @@ impl Part for DatafeedstatusesCustomBatchRequestEntry {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrderCustomer { - /// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. + /// If set, this indicates the user explicitly chose to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. #[serde(rename="explicitMarketingPreference")] pub explicit_marketing_preference: Option, /// Full name of the customer. @@ -2286,6 +2552,20 @@ impl RequestValue for AccountTax {} impl ResponseResult for AccountTax {} +/// 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 LocationIdSet { + /// A non-empty list of location IDs. They must all be of the same location type (e.g., state). + #[serde(rename="locationIds")] + pub location_ids: Option>, +} + +impl Part for LocationIdSet {} + + /// There is no detailed description. /// /// # Activities @@ -2867,6 +3147,33 @@ pub struct Price { impl Part for Price {} +/// The merchant account's shipping settings. +/// +/// # 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 shippingsettings](struct.ShippingsettingUpdateCall.html) (request|response) +/// * [patch shippingsettings](struct.ShippingsettingPatchCall.html) (request|response) +/// * [get shippingsettings](struct.ShippingsettingGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShippingSettings { + /// The target account's list of services. Optional. + pub services: Option>, + /// A list of postal code groups that can be referred to in services. Optional. + #[serde(rename="postalCodeGroups")] + pub postal_code_groups: Option>, + /// The ID of the account to which these account shipping settings belong. Ignored upon update, always present in get request responses. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for ShippingSettings {} +impl ResponseResult for ShippingSettings {} + + /// There is no detailed description. /// /// # Activities @@ -3044,6 +3351,21 @@ impl RequestValue for AccountShipping {} impl ResponseResult for AccountShipping {} +/// 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 ProductUnitPricingBaseMeasure { + /// The unit of the denominator. + pub unit: Option, + /// The denominator of the unit price. + pub value: Option, +} + +impl Part for ProductUnitPricingBaseMeasure {} + + /// Tax calculation rule to apply in a state or province (USA only). /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3069,27 +3391,29 @@ pub struct AccountTaxTaxRule { impl Part for AccountTaxTaxRule {} -/// There is no detailed description. +/// A batch entry encoding a single non-batch accountshipping request. /// -/// # 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 accountstatuses](struct.AccountstatuseListCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AccountstatusesListResponse { - /// The token for the retrieval of the next page of account statuses. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Identifies what kind of resource this is. Value: the fixed string "content#accountstatusesListResponse". - pub kind: Option, +pub struct ShippingsettingsCustomBatchRequestEntry { + /// An entry ID, unique within the batch request. + #[serde(rename="batchId")] + pub batch_id: Option, + /// The ID of the account for which to get/update account shipping settings. + #[serde(rename="accountId")] + pub account_id: Option, + /// The ID of the managing account. + #[serde(rename="merchantId")] + pub merchant_id: Option, + /// The account shipping settings to update. Only defined if the method is update. + #[serde(rename="shippingSettings")] + pub shipping_settings: Option, /// no description provided - pub resources: Option>, + pub method: Option, } -impl ResponseResult for AccountstatusesListResponse {} +impl Part for ShippingsettingsCustomBatchRequestEntry {} /// There is no detailed description. @@ -3153,6 +3477,9 @@ pub struct Product { pub custom_label4: Option, /// Title of the item. pub title: Option, + /// Additional categories of the item (formatted as in products feed specification). + #[serde(rename="additionalProductTypes")] + pub additional_product_types: Option>, /// Whether an item is available for purchase only online. #[serde(rename="onlineOnly")] pub online_only: Option, @@ -3172,7 +3499,7 @@ pub struct Product { pub content_language: Option, /// Manufacturer Part Number (MPN) of the item. pub mpn: Option, - /// Date range during which the item is on sale (see product feed specifications). + /// Date range during which the item is on sale (see products feed specification). #[serde(rename="salePriceEffectiveDate")] pub sale_price_effective_date: Option, /// Brand of the item. @@ -3220,7 +3547,7 @@ pub struct Product { /// Advertised sale price of the item. #[serde(rename="salePrice")] pub sale_price: Option, - /// Your category of the item (formatted as in product feeds specification). + /// Your category of the item (formatted as in products feed specification). #[serde(rename="productType")] pub product_type: Option, /// Advertiser-specified recommendations. @@ -3238,7 +3565,7 @@ pub struct Product { /// Additional URLs of images of the item. #[serde(rename="additionalImageLinks")] pub additional_image_links: Option>, - /// An identifier of the item. + /// An identifier of the item. Leading and trailing whitespaces are stripped and multiple whitespaces are replaced by a single whitespace upon submission. Only valid unicode characters are accepted. See the products feed specification for details. #[serde(rename="offerId")] pub offer_id: Option, /// Global Trade Item Number (GTIN) of the item. @@ -3381,6 +3708,26 @@ pub struct InventorySetRequest { impl RequestValue for InventorySetRequest {} +/// 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*). +/// +/// * [custombatch shippingsettings](struct.ShippingsettingCustombatchCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShippingsettingsCustomBatchResponse { + /// Identifies what kind of resource this is. Value: the fixed string "content#shippingsettingsCustomBatchResponse". + pub kind: Option, + /// The result of the execution of the batch requests. + pub entries: Option>, +} + +impl ResponseResult for ShippingsettingsCustomBatchResponse {} + + /// A batch entry encoding a single non-batch datafeeds request. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3434,9 +3781,12 @@ pub struct Order { pub shipments: Option>, /// The details of the customer who placed the order. pub customer: Option, - /// The status of the payment. - #[serde(rename="paymentStatus")] - pub payment_status: Option, + /// The total cost of shipping for all items. + #[serde(rename="shippingCost")] + pub shipping_cost: Option, + /// The channel type of the order: "purchaseOnGoogle" or "googleExpress". + #[serde(rename="channelType")] + pub channel_type: Option, /// The net amount for the order. For example, if an order was originally for a grand total of $100 and a refund was issued for $20, the net amount will be $80. #[serde(rename="netAmount")] pub net_amount: Option, @@ -3453,9 +3803,9 @@ pub struct Order { pub refunds: Option>, /// Whether the order was acknowledged. pub acknowledged: Option, - /// The total cost of shipping for all items. - #[serde(rename="shippingCost")] - pub shipping_cost: Option, + /// The status of the payment. + #[serde(rename="paymentStatus")] + pub payment_status: Option, /// no description provided #[serde(rename="merchantId")] pub merchant_id: Option, @@ -3485,6 +3835,23 @@ impl Resource for Order {} impl ResponseResult for Order {} +/// 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 PostalCodeRange { + /// A postal code or a pattern of the form prefix* denoting the inclusive lower bound of the range defining the area. Examples values: "94108", "9410*", "9*". Required. + #[serde(rename="postalCodeRangeBegin")] + pub postal_code_range_begin: Option, + /// A postal code or a pattern of the form prefix* denoting the inclusive upper bound of the range defining the area. It must have the same length as postalCodeRangeBegin: if postalCodeRangeBegin is a postal code then postalCodeRangeEnd must be a postal code too; if postalCodeRangeBegin is a pattern then postalCodeRangeEnd must be a pattern with the same prefix length. Optional: if not set, then the area is defined as being all the postal codes matching postalCodeRangeBegin. + #[serde(rename="postalCodeRangeEnd")] + pub postal_code_range_end: Option, +} + +impl Part for PostalCodeRange {} + + /// There is no detailed description. /// /// # Activities @@ -3744,17 +4111,22 @@ impl Part for OrdersCustomBatchResponseEntry {} /// There is no detailed description. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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*). +/// +/// * [getsupportedcarriers shippingsettings](struct.ShippingsettingGetsupportedcarrierCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ProductUnitPricingBaseMeasure { - /// The unit of the denominator. - pub unit: Option, - /// The denominator of the unit price. - pub value: Option, +pub struct ShippingsettingsGetSupportedCarriersResponse { + /// Identifies what kind of resource this is. Value: the fixed string "content#shippingsettingsGetSupportedCarriersResponse". + pub kind: Option, + /// A list of supported carriers. May be empty. + pub carriers: Option>, } -impl Part for ProductUnitPricingBaseMeasure {} +impl ResponseResult for ShippingsettingsGetSupportedCarriersResponse {} /// There is no detailed description. @@ -3806,6 +4178,27 @@ pub struct DatafeedFormat { impl Part for DatafeedFormat {} +/// 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 Table { + /// Headers of the table's rows. Required. + #[serde(rename="rowHeaders")] + pub row_headers: Option, + /// The list of rows that constitute the table. Must have the same length as rowHeaders. Required. + pub rows: Option>, + /// Headers of the table's columns. Optional: if not set then the table has only one dimension. + #[serde(rename="columnHeaders")] + pub column_headers: Option, + /// Name of the table. Required for subtables, ignored for the main table. + pub name: Option, +} + +impl Part for Table {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3842,6 +4235,27 @@ pub struct AccountAdwordsLink { impl Part for AccountAdwordsLink {} +/// A batch entry encoding a single non-batch shipping settings response. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ShippingsettingsCustomBatchResponseEntry { + /// The ID of the request entry to which this entry responds. + #[serde(rename="batchId")] + pub batch_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "content#shippingsettingsCustomBatchResponseEntry". + pub kind: Option, + /// A list of errors defined if, and only if, the request failed. + pub errors: Option, + /// The retrieved or updated account shipping settings. + #[serde(rename="shippingSettings")] + pub shipping_settings: Option, +} + +impl Part for ShippingsettingsCustomBatchResponseEntry {} + + // ################### // MethodBuilders ### @@ -4081,6 +4495,164 @@ impl<'a, C, A> DatafeedstatuseMethods<'a, C, A> { +/// A builder providing access to all methods supported on *shippingsetting* resources. +/// It is not used directly, but through the `ShoppingContent` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_content2 as content2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use content2::ShoppingContent; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `custombatch(...)`, `get(...)`, `getsupportedcarriers(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.shippingsettings(); +/// # } +/// ``` +pub struct ShippingsettingMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, +} + +impl<'a, C, A> MethodsBuilder for ShippingsettingMethods<'a, C, A> {} + +impl<'a, C, A> ShippingsettingMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates the shipping settings of the account. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account for which to get/update shipping settings. + pub fn patch(&self, request: ShippingSettings, merchant_id: &str, account_id: &str) -> ShippingsettingPatchCall<'a, C, A> { + ShippingsettingPatchCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves supported carriers and carrier services for an account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the account for which to retrieve the supported carriers. + pub fn getsupportedcarriers(&self, merchant_id: &str) -> ShippingsettingGetsupportedcarrierCall<'a, C, A> { + ShippingsettingGetsupportedcarrierCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists the shipping settings of the sub-accounts in your Merchant Center account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + pub fn list(&self, merchant_id: &str) -> ShippingsettingListCall<'a, C, A> { + ShippingsettingListCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _page_token: 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: + /// + /// Retrieves and updates the shipping settings of multiple accounts in a single request. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn custombatch(&self, request: ShippingsettingsCustomBatchRequest) -> ShippingsettingCustombatchCall<'a, C, A> { + ShippingsettingCustombatchCall { + hub: self.hub, + _request: request, + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates the shipping settings of the account. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account for which to get/update shipping settings. + pub fn update(&self, request: ShippingSettings, merchant_id: &str, account_id: &str) -> ShippingsettingUpdateCall<'a, C, A> { + ShippingsettingUpdateCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the shipping settings of the account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account for which to get/update shipping settings. + pub fn get(&self, merchant_id: &str, account_id: &str) -> ShippingsettingGetCall<'a, C, A> { + ShippingsettingGetCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *datafeed* resources. /// It is not used directly, but through the `ShoppingContent` hub. /// @@ -4259,6 +4831,375 @@ impl<'a, C, A> DatafeedMethods<'a, C, A> { +/// A builder providing access to all methods supported on *accountstatuse* resources. +/// It is not used directly, but through the `ShoppingContent` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_content2 as content2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use content2::ShoppingContent; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `custombatch(...)`, `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.accountstatuses(); +/// # } +/// ``` +pub struct AccountstatuseMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, +} + +impl<'a, C, A> MethodsBuilder for AccountstatuseMethods<'a, C, A> {} + +impl<'a, C, A> AccountstatuseMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the status of a Merchant Center account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account. + pub fn get(&self, merchant_id: &str, account_id: &str) -> AccountstatuseGetCall<'a, C, A> { + AccountstatuseGetCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn custombatch(&self, request: AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'a, C, A> { + AccountstatuseCustombatchCall { + 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 statuses of the sub-accounts in your Merchant Center account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + pub fn list(&self, merchant_id: &str) -> AccountstatuseListCall<'a, C, A> { + AccountstatuseListCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *account* resources. +/// It is not used directly, but through the `ShoppingContent` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_content2 as content2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use content2::ShoppingContent; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `authinfo(...)`, `custombatch(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.accounts(); +/// # } +/// ``` +pub struct AccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, +} + +impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} + +impl<'a, C, A> AccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates a Merchant Center account. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account. + pub fn update(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountUpdateCall<'a, C, A> { + AccountUpdateCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns information about the authenticated user. + pub fn authinfo(&self) -> AccountAuthinfoCall<'a, C, A> { + AccountAuthinfoCall { + hub: self.hub, + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a Merchant Center account. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account. + pub fn patch(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountPatchCall<'a, C, A> { + AccountPatchCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists the sub-accounts in your Merchant Center account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + pub fn list(&self, merchant_id: &str) -> AccountListCall<'a, C, A> { + AccountListCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _page_token: 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: + /// + /// Deletes a Merchant Center sub-account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account. + pub fn delete(&self, merchant_id: &str, account_id: &str) -> AccountDeleteCall<'a, C, A> { + AccountDeleteCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves, inserts, updates, and deletes multiple Merchant Center (sub-)accounts in a single request. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn custombatch(&self, request: AccountsCustomBatchRequest) -> AccountCustombatchCall<'a, C, A> { + AccountCustombatchCall { + hub: self.hub, + _request: request, + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a Merchant Center account. + /// + /// # Arguments + /// + /// * `merchantId` - The ID of the managing account. + /// * `accountId` - The ID of the account. + pub fn get(&self, merchant_id: &str, account_id: &str) -> AccountGetCall<'a, C, A> { + AccountGetCall { + hub: self.hub, + _merchant_id: merchant_id.to_string(), + _account_id: account_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a Merchant Center sub-account. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + pub fn insert(&self, request: Account, merchant_id: &str) -> AccountInsertCall<'a, C, A> { + AccountInsertCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *inventory* resources. +/// It is not used directly, but through the `ShoppingContent` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_content2 as content2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use content2::ShoppingContent; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `custombatch(...)` and `set(...)` +/// // to build up your call. +/// let rb = hub.inventory(); +/// # } +/// ``` +pub struct InventoryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, +} + +impl<'a, C, A> MethodsBuilder for InventoryMethods<'a, C, A> {} + +impl<'a, C, A> InventoryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates price and availability for multiple products or stores in a single request. This operation does not update the expiration date of the products. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn custombatch(&self, request: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { + InventoryCustombatchCall { + hub: self.hub, + _request: request, + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates price and availability of a product in your Merchant Center account. This operation does not update the expiration date of the product. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `merchantId` - The ID of the managing account. + /// * `storeCode` - The code of the store for which to update price and availability. Use online to update price and availability of an online product. + /// * `productId` - The ID of the product for which to update price and availability. + pub fn set(&self, request: InventorySetRequest, merchant_id: &str, store_code: &str, product_id: &str) -> InventorySetCall<'a, C, A> { + InventorySetCall { + hub: self.hub, + _request: request, + _merchant_id: merchant_id.to_string(), + _store_code: store_code.to_string(), + _product_id: product_id.to_string(), + _dry_run: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *productstatuse* resources. /// It is not used directly, but through the `ShoppingContent` hub. /// @@ -4356,375 +5297,6 @@ impl<'a, C, A> ProductstatuseMethods<'a, C, A> { -/// A builder providing access to all methods supported on *account* resources. -/// It is not used directly, but through the `ShoppingContent` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_content2 as content2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use content2::ShoppingContent; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `authinfo(...)`, `custombatch(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` -/// // to build up your call. -/// let rb = hub.accounts(); -/// # } -/// ``` -pub struct AccountMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, -} - -impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} - -impl<'a, C, A> AccountMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns information about the authenticated user. - pub fn authinfo(&self) -> AccountAuthinfoCall<'a, C, A> { - AccountAuthinfoCall { - hub: self.hub, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a Merchant Center account. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `merchantId` - The ID of the managing account. - /// * `accountId` - The ID of the account. - pub fn patch(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountPatchCall<'a, C, A> { - AccountPatchCall { - hub: self.hub, - _request: request, - _merchant_id: merchant_id.to_string(), - _account_id: account_id.to_string(), - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a Merchant Center account. - /// - /// # Arguments - /// - /// * `merchantId` - The ID of the managing account. - /// * `accountId` - The ID of the account. - pub fn get(&self, merchant_id: &str, account_id: &str) -> AccountGetCall<'a, C, A> { - AccountGetCall { - hub: self.hub, - _merchant_id: merchant_id.to_string(), - _account_id: account_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a Merchant Center account. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `merchantId` - The ID of the managing account. - /// * `accountId` - The ID of the account. - pub fn update(&self, request: Account, merchant_id: &str, account_id: &str) -> AccountUpdateCall<'a, C, A> { - AccountUpdateCall { - hub: self.hub, - _request: request, - _merchant_id: merchant_id.to_string(), - _account_id: account_id.to_string(), - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists the sub-accounts in your Merchant Center account. - /// - /// # Arguments - /// - /// * `merchantId` - The ID of the managing account. - pub fn list(&self, merchant_id: &str) -> AccountListCall<'a, C, A> { - AccountListCall { - hub: self.hub, - _merchant_id: merchant_id.to_string(), - _page_token: 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: - /// - /// Deletes a Merchant Center sub-account. - /// - /// # Arguments - /// - /// * `merchantId` - The ID of the managing account. - /// * `accountId` - The ID of the account. - pub fn delete(&self, merchant_id: &str, account_id: &str) -> AccountDeleteCall<'a, C, A> { - AccountDeleteCall { - hub: self.hub, - _merchant_id: merchant_id.to_string(), - _account_id: account_id.to_string(), - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves, inserts, updates, and deletes multiple Merchant Center (sub-)accounts in a single request. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn custombatch(&self, request: AccountsCustomBatchRequest) -> AccountCustombatchCall<'a, C, A> { - AccountCustombatchCall { - hub: self.hub, - _request: request, - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a Merchant Center sub-account. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `merchantId` - The ID of the managing account. - pub fn insert(&self, request: Account, merchant_id: &str) -> AccountInsertCall<'a, C, A> { - AccountInsertCall { - hub: self.hub, - _request: request, - _merchant_id: merchant_id.to_string(), - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *inventory* resources. -/// It is not used directly, but through the `ShoppingContent` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_content2 as content2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use content2::ShoppingContent; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `custombatch(...)` and `set(...)` -/// // to build up your call. -/// let rb = hub.inventory(); -/// # } -/// ``` -pub struct InventoryMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, -} - -impl<'a, C, A> MethodsBuilder for InventoryMethods<'a, C, A> {} - -impl<'a, C, A> InventoryMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Updates price and availability of a product in your Merchant Center account. This operation does not update the expiration date of the product. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `merchantId` - The ID of the managing account. - /// * `storeCode` - The code of the store for which to update price and availability. Use online to update price and availability of an online product. - /// * `productId` - The ID of the product for which to update price and availability. - pub fn set(&self, request: InventorySetRequest, merchant_id: &str, store_code: &str, product_id: &str) -> InventorySetCall<'a, C, A> { - InventorySetCall { - hub: self.hub, - _request: request, - _merchant_id: merchant_id.to_string(), - _store_code: store_code.to_string(), - _product_id: product_id.to_string(), - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates price and availability for multiple products or stores in a single request. This operation does not update the expiration date of the products. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn custombatch(&self, request: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { - InventoryCustombatchCall { - hub: self.hub, - _request: request, - _dry_run: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *accountstatuse* resources. -/// It is not used directly, but through the `ShoppingContent` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_content2 as content2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use content2::ShoppingContent; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `custombatch(...)`, `get(...)` and `list(...)` -/// // to build up your call. -/// let rb = hub.accountstatuses(); -/// # } -/// ``` -pub struct AccountstatuseMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, -} - -impl<'a, C, A> MethodsBuilder for AccountstatuseMethods<'a, C, A> {} - -impl<'a, C, A> AccountstatuseMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves the status of a Merchant Center account. - /// - /// # Arguments - /// - /// * `merchantId` - The ID of the managing account. - /// * `accountId` - The ID of the account. - pub fn get(&self, merchant_id: &str, account_id: &str) -> AccountstatuseGetCall<'a, C, A> { - AccountstatuseGetCall { - hub: self.hub, - _merchant_id: merchant_id.to_string(), - _account_id: account_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists the statuses of the sub-accounts in your Merchant Center account. - /// - /// # Arguments - /// - /// * `merchantId` - The ID of the managing account. - pub fn list(&self, merchant_id: &str) -> AccountstatuseListCall<'a, C, A> { - AccountstatuseListCall { - hub: self.hub, - _merchant_id: merchant_id.to_string(), - _page_token: Default::default(), - _max_results: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn custombatch(&self, request: AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'a, C, A> { - AccountstatuseCustombatchCall { - hub: self.hub, - _request: request, - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - /// A builder providing access to all methods supported on *product* resources. /// It is not used directly, but through the `ShoppingContent` hub. /// @@ -7421,6 +7993,1572 @@ impl<'a, C, A> DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = ShoppingContent::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 = ShippingSettings::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.shippingsettings().patch(req, "merchantId", "accountId") +/// .dry_run(false) +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _request: ShippingSettings, + _merchant_id: String, + _account_id: String, + _dry_run: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingPatchCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingPatchCall<'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, ShippingSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + params.push(("accountId", self._account_id.to_string())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { + if self._additional_params.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/content/v2/{merchantId}/shippingsettings/{accountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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: ShippingSettings) -> ShippingsettingPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> ShippingsettingPatchCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The ID of the account for which to get/update shipping settings. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ShippingsettingPatchCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> ShippingsettingPatchCall<'a, C, A> { + self._dry_run = 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) -> ShippingsettingPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingPatchCall<'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) -> ShippingsettingPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves supported carriers and carrier services for an account. +/// +/// A builder for the *getsupportedcarriers* method supported by a *shippingsetting* resource. +/// It is not used directly, but through a `ShippingsettingMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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.shippingsettings().getsupportedcarriers("merchantId") +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingGetsupportedcarrierCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _merchant_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingGetsupportedcarrierCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingGetsupportedcarrierCall<'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, ShippingsettingsGetSupportedCarriersResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.getsupportedcarriers", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + for &field in ["alt", "merchantId"].iter() { + if self._additional_params.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/content/v2/{merchantId}/supportedCarriers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId")].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 ["merchantId"].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) + } + } + } + } + + + /// The ID of the account for which to retrieve the supported carriers. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> ShippingsettingGetsupportedcarrierCall<'a, C, A> { + self._merchant_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) -> ShippingsettingGetsupportedcarrierCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingGetsupportedcarrierCall<'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) -> ShippingsettingGetsupportedcarrierCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the shipping settings of the sub-accounts in your Merchant Center account. +/// +/// A builder for the *list* method supported by a *shippingsetting* resource. +/// It is not used directly, but through a `ShippingsettingMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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.shippingsettings().list("merchantId") +/// .page_token("elitr") +/// .max_results(4) +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _merchant_id: String, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingListCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingListCall<'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, ShippingsettingsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.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())); + } + for &field in ["alt", "merchantId", "pageToken", "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/content/v2/{merchantId}/shippingsettings".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId")].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 ["merchantId"].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) + } + } + } + } + + + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> ShippingsettingListCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The token returned by the previous request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ShippingsettingListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The maximum number of shipping settings to return in the response, used for paging. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> ShippingsettingListCall<'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) -> ShippingsettingListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingListCall<'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) -> ShippingsettingListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves and updates the shipping settings of multiple accounts in a single request. +/// +/// A builder for the *custombatch* method supported by a *shippingsetting* resource. +/// It is not used directly, but through a `ShippingsettingMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// use content2::ShippingsettingsCustomBatchRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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 = ShippingsettingsCustomBatchRequest::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.shippingsettings().custombatch(req) +/// .dry_run(false) +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingCustombatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _request: ShippingsettingsCustomBatchRequest, + _dry_run: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingCustombatchCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingCustombatchCall<'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, ShippingsettingsCustomBatchResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.custombatch", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "dryRun"].iter() { + if self._additional_params.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/content/v2/shippingsettings/batch".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: ShippingsettingsCustomBatchRequest) -> ShippingsettingCustombatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> ShippingsettingCustombatchCall<'a, C, A> { + self._dry_run = 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) -> ShippingsettingCustombatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingCustombatchCall<'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) -> ShippingsettingCustombatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the shipping settings of the account. +/// +/// A builder for the *update* method supported by a *shippingsetting* resource. +/// It is not used directly, but through a `ShippingsettingMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// use content2::ShippingSettings; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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 = ShippingSettings::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.shippingsettings().update(req, "merchantId", "accountId") +/// .dry_run(true) +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _request: ShippingSettings, + _merchant_id: String, + _account_id: String, + _dry_run: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingUpdateCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingUpdateCall<'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, ShippingSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + params.push(("accountId", self._account_id.to_string())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { + if self._additional_params.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/content/v2/{merchantId}/shippingsettings/{accountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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: ShippingSettings) -> ShippingsettingUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> ShippingsettingUpdateCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The ID of the account for which to get/update shipping settings. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ShippingsettingUpdateCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> ShippingsettingUpdateCall<'a, C, A> { + self._dry_run = 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) -> ShippingsettingUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingUpdateCall<'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) -> ShippingsettingUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the shipping settings of the account. +/// +/// A builder for the *get* method supported by a *shippingsetting* resource. +/// It is not used directly, but through a `ShippingsettingMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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.shippingsettings().get("merchantId", "accountId") +/// .doit(); +/// # } +/// ``` +pub struct ShippingsettingGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _merchant_id: String, + _account_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ShippingsettingGetCall<'a, C, A> {} + +impl<'a, C, A> ShippingsettingGetCall<'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, ShippingSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.shippingsettings.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + params.push(("accountId", self._account_id.to_string())); + for &field in ["alt", "merchantId", "accountId"].iter() { + if self._additional_params.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/content/v2/{merchantId}/shippingsettings/{accountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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) + } + } + } + } + + + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> ShippingsettingGetCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The ID of the account for which to get/update shipping settings. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> ShippingsettingGetCall<'a, C, A> { + self._account_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) -> ShippingsettingGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ShippingsettingGetCall<'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) -> ShippingsettingGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// A builder for the *custombatch* method supported by a *datafeed* resource. /// It is not used directly, but through a `DatafeedMethods` instance. /// @@ -8747,8 +10885,8 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.datafeeds().list("merchantId") -/// .page_token("aliquyam") -/// .max_results(28) +/// .page_token("ut") +/// .max_results(85) /// .doit(); /// # } /// ``` @@ -9267,10 +11405,10 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A } -/// Gets the status of a product from your Merchant Center account. +/// Retrieves the status of a Merchant Center account. /// -/// A builder for the *get* method supported by a *productstatuse* resource. -/// It is not used directly, but through a `ProductstatuseMethods` instance. +/// A builder for the *get* method supported by a *accountstatuse* resource. +/// It is not used directly, but through a `AccountstatuseMethods` instance. /// /// # Example /// @@ -9293,28 +11431,28 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.productstatuses().get("merchantId", "productId") +/// let result = hub.accountstatuses().get("merchantId", "accountId") /// .doit(); /// # } /// ``` -pub struct ProductstatuseGetCall<'a, C, A> +pub struct AccountstatuseGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, _merchant_id: String, - _product_id: String, + _account_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProductstatuseGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for AccountstatuseGetCall<'a, C, A> {} -impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> AccountstatuseGetCall<'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, ProductStatus)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, AccountStatus)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -9322,12 +11460,12 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.productstatuses.get", + dlg.begin(MethodInfo { id: "content.accountstatuses.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); - params.push(("productId", self._product_id.to_string())); - for &field in ["alt", "merchantId", "productId"].iter() { + params.push(("accountId", self._account_id.to_string())); + for &field in ["alt", "merchantId", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9339,12 +11477,12 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/content/v2/{merchantId}/productstatuses/{productId}".to_string(); + let mut url = "https://www.googleapis.com/content/v2/{merchantId}/accountstatuses/{accountId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{productId}", "productId")].iter() { + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -9356,7 +11494,7 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["productId", "merchantId"].iter() { + for param_name in ["accountId", "merchantId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -9448,18 +11586,18 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn merchant_id(mut self, new_value: &str) -> ProductstatuseGetCall<'a, C, A> { + pub fn merchant_id(mut self, new_value: &str) -> AccountstatuseGetCall<'a, C, A> { self._merchant_id = new_value.to_string(); self } - /// The ID of the product. + /// The ID of the account. /// - /// Sets the *product id* path property to the given value. + /// Sets the *account 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 product_id(mut self, new_value: &str) -> ProductstatuseGetCall<'a, C, A> { - self._product_id = new_value.to_string(); + pub fn account_id(mut self, new_value: &str) -> AccountstatuseGetCall<'a, C, A> { + self._account_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -9468,7 +11606,7 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductstatuseGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountstatuseGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9489,7 +11627,7 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// * *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) -> ProductstatuseGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> AccountstatuseGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -9506,7 +11644,7 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// 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) -> ProductstatuseGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> AccountstatuseGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -9514,10 +11652,241 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut } -/// Lists the statuses of the products in your Merchant Center account. +/// A builder for the *custombatch* method supported by a *accountstatuse* resource. +/// It is not used directly, but through a `AccountstatuseMethods` instance. /// -/// A builder for the *list* method supported by a *productstatuse* resource. -/// It is not used directly, but through a `ProductstatuseMethods` instance. +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// use content2::AccountstatusesCustomBatchRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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 = AccountstatusesCustomBatchRequest::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.accountstatuses().custombatch(req) +/// .doit(); +/// # } +/// ``` +pub struct AccountstatuseCustombatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _request: AccountstatusesCustomBatchRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountstatuseCustombatchCall<'a, C, A> {} + +impl<'a, C, A> AccountstatuseCustombatchCall<'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, AccountstatusesCustomBatchResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.accountstatuses.custombatch", + 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/content/v2/accountstatuses/batch".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: AccountstatusesCustomBatchRequest) -> AccountstatuseCustombatchCall<'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) -> AccountstatuseCustombatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountstatuseCustombatchCall<'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) -> AccountstatuseCustombatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the statuses of the sub-accounts in your Merchant Center account. +/// +/// A builder for the *list* method supported by a *accountstatuse* resource. +/// It is not used directly, but through a `AccountstatuseMethods` instance. /// /// # Example /// @@ -9540,33 +11909,31 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.productstatuses().list("merchantId") -/// .page_token("sanctus") -/// .max_results(79) -/// .include_invalid_inserted_items(true) +/// let result = hub.accountstatuses().list("merchantId") +/// .page_token("amet.") +/// .max_results(74) /// .doit(); /// # } /// ``` -pub struct ProductstatuseListCall<'a, C, A> +pub struct AccountstatuseListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, _merchant_id: String, _page_token: Option, _max_results: Option, - _include_invalid_inserted_items: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProductstatuseListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for AccountstatuseListCall<'a, C, A> {} -impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> AccountstatuseListCall<'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, ProductstatusesListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, AccountstatusesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -9574,9 +11941,9 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.productstatuses.list", + dlg.begin(MethodInfo { id: "content.accountstatuses.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -9584,10 +11951,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseListCall<'a, C, A> { + pub fn merchant_id(mut self, new_value: &str) -> AccountstatuseListCall<'a, C, A> { self._merchant_id = new_value.to_string(); self } /// The token returned by the previous request. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProductstatuseListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> AccountstatuseListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } - /// The maximum number of product statuses to return in the response, used for paging. + /// The maximum number of account statuses to return in the response, used for paging. /// /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ProductstatuseListCall<'a, C, A> { + pub fn max_results(mut self, new_value: u32) -> AccountstatuseListCall<'a, C, A> { self._max_results = Some(new_value); self } - /// Flag to include the invalid inserted items in the result of the list request. By default the invalid items are not shown (the default value is false). - /// - /// Sets the *include invalid inserted items* query property to the given value. - pub fn include_invalid_inserted_items(mut self, new_value: bool) -> ProductstatuseListCall<'a, C, A> { - self._include_invalid_inserted_items = 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) -> ProductstatuseListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountstatuseListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9760,7 +12117,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProductstatuseListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> AccountstatuseListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -9777,7 +12134,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProductstatuseListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> AccountstatuseListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -9785,10 +12142,10 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseListCall<'a, C, A> where C: BorrowMut +pub struct AccountUpdateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, - _request: ProductstatusesCustomBatchRequest, + _request: Account, + _merchant_id: String, + _account_id: String, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProductstatuseCustombatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} -impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> AccountUpdateCall<'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, ProductstatusesCustomBatchResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -9845,10 +12206,15 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.productstatuses.custombatch", - 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() { + dlg.begin(MethodInfo { id: "content.accounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + params.push(("accountId", self._account_id.to_string())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9860,11 +12226,32 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut = 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 ["accountId", "merchantId"].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('?'); @@ -9901,7 +12288,7 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut ProductstatuseCustombatchCall<'a, C, A> { + pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C, A> { self._request = new_value; self } + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The ID of the account. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> AccountUpdateCall<'a, C, A> { + self._dry_run = 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) -> ProductstatuseCustombatchCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountUpdateCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9993,7 +12407,7 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProductstatuseCustombatchCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> AccountUpdateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -10010,7 +12424,7 @@ impl<'a, C, A> ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProductstatuseCustombatchCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> AccountUpdateCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -10510,543 +12924,6 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: } -/// Retrieves a Merchant Center account. -/// -/// A builder for the *get* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_content2 as content2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use content2::ShoppingContent; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ShoppingContent::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.accounts().get("merchantId", "accountId") -/// .doit(); -/// # } -/// ``` -pub struct AccountGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, - _merchant_id: String, - _account_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} - -impl<'a, C, A> AccountGetCall<'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, Account)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "content.accounts.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("merchantId", self._merchant_id.to_string())); - params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { - if self._additional_params.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/content/v2/{merchantId}/accounts/{accountId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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) - } - } - } - } - - - /// The ID of the managing account. - /// - /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { - self._merchant_id = new_value.to_string(); - self - } - /// The ID of the account. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { - self._account_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) -> AccountGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> AccountGetCall<'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) -> AccountGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a Merchant Center account. -/// -/// A builder for the *update* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_content2 as content2; -/// use content2::Account; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use content2::ShoppingContent; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ShoppingContent::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 = Account::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.accounts().update(req, "merchantId", "accountId") -/// .dry_run(true) -/// .doit(); -/// # } -/// ``` -pub struct AccountUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, - _request: Account, - _merchant_id: String, - _account_id: String, - _dry_run: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} - -impl<'a, C, A> AccountUpdateCall<'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, Account)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "content.accounts.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("merchantId", self._merchant_id.to_string())); - params.push(("accountId", self._account_id.to_string())); - if let Some(value) = self._dry_run { - params.push(("dryRun", value.to_string())); - } - for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { - if self._additional_params.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/content/v2/{merchantId}/accounts/{accountId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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: Account) -> AccountUpdateCall<'a, C, A> { - self._request = new_value; - self - } - /// The ID of the managing account. - /// - /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { - self._merchant_id = new_value.to_string(); - self - } - /// The ID of the account. - /// - /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { - self._account_id = new_value.to_string(); - self - } - /// Flag to run the request in dry-run mode. - /// - /// Sets the *dry run* query property to the given value. - pub fn dry_run(mut self, new_value: bool) -> AccountUpdateCall<'a, C, A> { - self._dry_run = 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) -> AccountUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> AccountUpdateCall<'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) -> AccountUpdateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Lists the sub-accounts in your Merchant Center account. /// /// A builder for the *list* method supported by a *account* resource. @@ -11075,7 +12952,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().list("merchantId") /// .page_token("consetetur") -/// .max_results(49) +/// .max_results(57) /// .doit(); /// # } /// ``` @@ -11333,7 +13210,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().delete("merchantId", "accountId") -/// .dry_run(true) +/// .dry_run(false) /// .doit(); /// # } /// ``` @@ -11587,7 +13464,7 @@ impl<'a, C, A> AccountDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().custombatch(req) -/// .dry_run(true) +/// .dry_run(false) /// .doit(); /// # } /// ``` @@ -11799,6 +13676,253 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = ShoppingContent::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.accounts().get("merchantId", "accountId") +/// .doit(); +/// # } +/// ``` +pub struct AccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _merchant_id: String, + _account_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} + +impl<'a, C, A> AccountGetCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.accounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("merchantId", self._merchant_id.to_string())); + params.push(("accountId", self._account_id.to_string())); + for &field in ["alt", "merchantId", "accountId"].iter() { + if self._additional_params.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/content/v2/{merchantId}/accounts/{accountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].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 ["accountId", "merchantId"].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) + } + } + } + } + + + /// The ID of the managing account. + /// + /// Sets the *merchant 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 merchant_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._merchant_id = new_value.to_string(); + self + } + /// The ID of the account. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._account_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) -> AccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountGetCall<'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) -> AccountGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Creates a Merchant Center sub-account. /// /// A builder for the *insert* method supported by a *account* resource. @@ -12077,6 +14201,251 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut, A: } +/// Updates price and availability for multiple products or stores in a single request. This operation does not update the expiration date of the products. +/// +/// A builder for the *custombatch* method supported by a *inventory* resource. +/// It is not used directly, but through a `InventoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_content2 as content2; +/// use content2::InventoryCustomBatchRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use content2::ShoppingContent; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = ShoppingContent::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 = InventoryCustomBatchRequest::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.inventory().custombatch(req) +/// .dry_run(true) +/// .doit(); +/// # } +/// ``` +pub struct InventoryCustombatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a ShoppingContent, + _request: InventoryCustomBatchRequest, + _dry_run: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InventoryCustombatchCall<'a, C, A> {} + +impl<'a, C, A> InventoryCustombatchCall<'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, InventoryCustomBatchResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "content.inventory.custombatch", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "dryRun"].iter() { + if self._additional_params.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/content/v2/inventory/batch".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: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { + self._request = new_value; + self + } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> InventoryCustombatchCall<'a, C, A> { + self._dry_run = 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) -> InventoryCustombatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InventoryCustombatchCall<'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) -> InventoryCustombatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates price and availability of a product in your Merchant Center account. This operation does not update the expiration date of the product. /// /// A builder for the *set* method supported by a *inventory* resource. @@ -12379,255 +14748,10 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: } -/// Updates price and availability for multiple products or stores in a single request. This operation does not update the expiration date of the products. +/// Gets the status of a product from your Merchant Center account. /// -/// A builder for the *custombatch* method supported by a *inventory* resource. -/// It is not used directly, but through a `InventoryMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_content2 as content2; -/// use content2::InventoryCustomBatchRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use content2::ShoppingContent; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = ShoppingContent::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 = InventoryCustomBatchRequest::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.inventory().custombatch(req) -/// .dry_run(false) -/// .doit(); -/// # } -/// ``` -pub struct InventoryCustombatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a ShoppingContent, - _request: InventoryCustomBatchRequest, - _dry_run: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for InventoryCustombatchCall<'a, C, A> {} - -impl<'a, C, A> InventoryCustombatchCall<'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, InventoryCustomBatchResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "content.inventory.custombatch", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - if let Some(value) = self._dry_run { - params.push(("dryRun", value.to_string())); - } - for &field in ["alt", "dryRun"].iter() { - if self._additional_params.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/content/v2/inventory/batch".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: InventoryCustomBatchRequest) -> InventoryCustombatchCall<'a, C, A> { - self._request = new_value; - self - } - /// Flag to run the request in dry-run mode. - /// - /// Sets the *dry run* query property to the given value. - pub fn dry_run(mut self, new_value: bool) -> InventoryCustombatchCall<'a, C, A> { - self._dry_run = 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) -> InventoryCustombatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> InventoryCustombatchCall<'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) -> InventoryCustombatchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves the status of a Merchant Center account. -/// -/// A builder for the *get* method supported by a *accountstatuse* resource. -/// It is not used directly, but through a `AccountstatuseMethods` instance. +/// A builder for the *get* method supported by a *productstatuse* resource. +/// It is not used directly, but through a `ProductstatuseMethods` instance. /// /// # Example /// @@ -12650,28 +14774,28 @@ impl<'a, C, A> InventoryCustombatchCall<'a, C, A> where C: BorrowMut +pub struct ProductstatuseGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, _merchant_id: String, - _account_id: String, + _product_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for AccountstatuseGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductstatuseGetCall<'a, C, A> {} -impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductstatuseGetCall<'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, AccountStatus)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProductStatus)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -12679,12 +14803,12 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.accountstatuses.get", + dlg.begin(MethodInfo { id: "content.productstatuses.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); - params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { + params.push(("productId", self._product_id.to_string())); + for &field in ["alt", "merchantId", "productId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12696,12 +14820,12 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/content/v2/{merchantId}/accountstatuses/{accountId}".to_string(); + let mut url = "https://www.googleapis.com/content/v2/{merchantId}/productstatuses/{productId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{accountId}", "accountId")].iter() { + for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{productId}", "productId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -12713,7 +14837,7 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut } { let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["accountId", "merchantId"].iter() { + for param_name in ["productId", "merchantId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -12805,18 +14929,18 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn merchant_id(mut self, new_value: &str) -> AccountstatuseGetCall<'a, C, A> { + pub fn merchant_id(mut self, new_value: &str) -> ProductstatuseGetCall<'a, C, A> { self._merchant_id = new_value.to_string(); self } - /// The ID of the account. + /// The ID of the product. /// - /// Sets the *account id* path property to the given value. + /// Sets the *product 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 account_id(mut self, new_value: &str) -> AccountstatuseGetCall<'a, C, A> { - self._account_id = new_value.to_string(); + pub fn product_id(mut self, new_value: &str) -> ProductstatuseGetCall<'a, C, A> { + self._product_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -12825,7 +14949,7 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountstatuseGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductstatuseGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -12846,7 +14970,7 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// * *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) -> AccountstatuseGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductstatuseGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -12863,7 +14987,7 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// 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) -> AccountstatuseGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductstatuseGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -12871,10 +14995,10 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut } -/// Lists the statuses of the sub-accounts in your Merchant Center account. +/// Lists the statuses of the products in your Merchant Center account. /// -/// A builder for the *list* method supported by a *accountstatuse* resource. -/// It is not used directly, but through a `AccountstatuseMethods` instance. +/// A builder for the *list* method supported by a *productstatuse* resource. +/// It is not used directly, but through a `ProductstatuseMethods` instance. /// /// # Example /// @@ -12897,31 +15021,33 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.accountstatuses().list("merchantId") -/// .page_token("dolore") -/// .max_results(82) +/// let result = hub.productstatuses().list("merchantId") +/// .page_token("At") +/// .max_results(15) +/// .include_invalid_inserted_items(true) /// .doit(); /// # } /// ``` -pub struct AccountstatuseListCall<'a, C, A> +pub struct ProductstatuseListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, _merchant_id: String, _page_token: Option, _max_results: Option, + _include_invalid_inserted_items: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for AccountstatuseListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductstatuseListCall<'a, C, A> {} -impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductstatuseListCall<'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, AccountstatusesListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProductstatusesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -12929,9 +15055,9 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.accountstatuses.list", + dlg.begin(MethodInfo { id: "content.productstatuses.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -12939,7 +15065,10 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseListCall<'a, C, A> { + pub fn merchant_id(mut self, new_value: &str) -> ProductstatuseListCall<'a, C, A> { self._merchant_id = new_value.to_string(); self } /// The token returned by the previous request. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AccountstatuseListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> ProductstatuseListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } - /// The maximum number of account statuses to return in the response, used for paging. + /// The maximum number of product statuses to return in the response, used for paging. /// /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> AccountstatuseListCall<'a, C, A> { + pub fn max_results(mut self, new_value: u32) -> ProductstatuseListCall<'a, C, A> { self._max_results = Some(new_value); self } + /// Flag to include the invalid inserted items in the result of the list request. By default the invalid items are not shown (the default value is false). + /// + /// Sets the *include invalid inserted items* query property to the given value. + pub fn include_invalid_inserted_items(mut self, new_value: bool) -> ProductstatuseListCall<'a, C, A> { + self._include_invalid_inserted_items = 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) -> AccountstatuseListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductstatuseListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -13105,7 +15241,7 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> AccountstatuseListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductstatuseListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -13122,7 +15258,7 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> AccountstatuseListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductstatuseListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -13130,8 +15266,10 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseListCall<'a, C, A> where C: BorrowMut +pub struct ProductstatuseCustombatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a ShoppingContent, - _request: AccountstatusesCustomBatchRequest, + _request: ProductstatusesCustomBatchRequest, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for AccountstatuseCustombatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProductstatuseCustombatchCall<'a, C, A> {} -impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProductstatuseCustombatchCall<'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, AccountstatusesCustomBatchResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ProductstatusesCustomBatchResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -13188,7 +15326,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "content.accountstatuses.custombatch", + dlg.begin(MethodInfo { id: "content.productstatuses.custombatch", 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() { @@ -13203,7 +15341,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> { + pub fn request(mut self, new_value: ProductstatusesCustomBatchRequest) -> ProductstatuseCustombatchCall<'a, C, A> { self._request = new_value; self } @@ -13315,7 +15453,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProductstatuseCustombatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -13336,7 +15474,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> AccountstatuseCustombatchCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProductstatuseCustombatchCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -13353,7 +15491,7 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> AccountstatuseCustombatchCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProductstatuseCustombatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -13388,8 +15526,8 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut ProductDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.products().custombatch(req) -/// .dry_run(false) +/// .dry_run(true) /// .doit(); /// # } /// ``` @@ -14405,7 +16543,7 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut ProductInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accountshipping().list("merchantId") -/// .page_token("ea") -/// .max_results(6) +/// .page_token("gubergren") +/// .max_results(19) /// .doit(); /// # } /// ``` @@ -14942,7 +17080,7 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut AccountshippingPatchCall<'a, C, A> where C: BorrowMut AccountshippingUpdateCall<'a, C, A> where C: BorrowMut AccountshippingGetCall<'a, C, A> where C: BorrowMut"] 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" @@ -19,10 +19,10 @@ name = "content2-sandbox" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-content2_sandbox] diff --git a/gen/content2_sandbox-cli/README.md b/gen/content2_sandbox-cli/README.md index 2adf506388..7047fde2c5 100644 --- a/gen/content2_sandbox-cli/README.md +++ b/gen/content2_sandbox-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Shopping Content* API at revision *20160331*. 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 *0.3.6*. ```bash content2-sandbox [options] diff --git a/gen/content2_sandbox-cli/mkdocs.yml b/gen/content2_sandbox-cli/mkdocs.yml index 94b023d937..281d2b205a 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+20160331 +site_name: Shopping Content v0.3.6+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 c6507551b1..9dd6429d5c 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+20160331") + .version("0.3.6+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/content2_sandbox/Cargo.toml b/gen/content2_sandbox/Cargo.toml index 561be4dd7e..7e713462e8 100644 --- a/gen/content2_sandbox/Cargo.toml +++ b/gen/content2_sandbox/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-content2_sandbox" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/content2_sandbox/README.md b/gen/content2_sandbox/README.md index 2da9a32983..ab86fbc352 100644 --- a/gen/content2_sandbox/README.md +++ b/gen/content2_sandbox/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-content2_sandbox` library allows access to all features of the *Google Shopping Content* service. -This documentation was generated from *Shopping Content* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *content:v2sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Shopping Content* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *content:v2sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Shopping Content* *v2_sandbox* API can be found at the [official documentation site](https://developers.google.com/shopping-content). diff --git a/gen/content2_sandbox/src/lib.rs b/gen/content2_sandbox/src/lib.rs index b0bf5523e9..3be751bcbc 100644 --- a/gen/content2_sandbox/src/lib.rs +++ b/gen/content2_sandbox/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Shopping Content* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *content:v2sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Shopping Content* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *content:v2sandbox* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Shopping Content* *v2_sandbox* API can be found at the //! [official documentation site](https://developers.google.com/shopping-content). diff --git a/gen/content2_sandbox/src/lib.rs.in b/gen/content2_sandbox/src/lib.rs.in index e88246fa76..c9ba39435d 100644 --- a/gen/content2_sandbox/src/lib.rs.in +++ b/gen/content2_sandbox/src/lib.rs.in @@ -505,9 +505,12 @@ pub struct Order { pub shipments: Option>, /// The details of the customer who placed the order. pub customer: Option, - /// The status of the payment. - #[serde(rename="paymentStatus")] - pub payment_status: Option, + /// The total cost of shipping for all items. + #[serde(rename="shippingCost")] + pub shipping_cost: Option, + /// The channel type of the order: "purchaseOnGoogle" or "googleExpress". + #[serde(rename="channelType")] + pub channel_type: Option, /// The net amount for the order. For example, if an order was originally for a grand total of $100 and a refund was issued for $20, the net amount will be $80. #[serde(rename="netAmount")] pub net_amount: Option, @@ -524,9 +527,9 @@ pub struct Order { pub refunds: Option>, /// Whether the order was acknowledged. pub acknowledged: Option, - /// The total cost of shipping for all items. - #[serde(rename="shippingCost")] - pub shipping_cost: Option, + /// The status of the payment. + #[serde(rename="paymentStatus")] + pub payment_status: Option, /// no description provided #[serde(rename="merchantId")] pub merchant_id: Option, @@ -699,7 +702,7 @@ impl ResponseResult for OrdersCancelLineItemResponse {} pub struct OrderCancellation { /// The quantity that was canceled. pub quantity: Option, - /// The reason for the cancellation. + /// The reason for the cancellation. Orders that are cancelled with a noInventory reason will lead to the removal of the product from POG until you make an update to that product. This will not affect your Shopping ads. pub reason: Option, /// Date on which the cancellation has been created, in ISO 8601 format. #[serde(rename="creationDate")] @@ -974,7 +977,7 @@ impl ResponseResult for OrdersCustomBatchResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrderCustomer { - /// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. + /// If set, this indicates the user explicitly chose to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. #[serde(rename="explicitMarketingPreference")] pub explicit_marketing_preference: Option, /// Full name of the customer. @@ -1123,7 +1126,7 @@ impl RequestValue for OrdersRefundRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TestOrderCustomer { - /// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. Optional. + /// If set, this indicates the user explicitly chose to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. Optional. #[serde(rename="explicitMarketingPreference")] pub explicit_marketing_preference: Option, /// Full name of the customer. diff --git a/gen/coordinate1-cli/Cargo.toml b/gen/coordinate1-cli/Cargo.toml index da8961f395..63a62d95db 100644 --- a/gen/coordinate1-cli/Cargo.toml +++ b/gen/coordinate1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "coordinate1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-coordinate1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-coordinate1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-coordinate1] diff --git a/gen/coordinate1/Cargo.toml b/gen/coordinate1/Cargo.toml index b64a6edd1e..5c938300c1 100644 --- a/gen/coordinate1/Cargo.toml +++ b/gen/coordinate1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/customsearch1-cli/Cargo.toml b/gen/customsearch1-cli/Cargo.toml index 699c7bed9f..a9ff906001 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+20151130" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "customsearch1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-customsearch1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-customsearch1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-customsearch1] diff --git a/gen/customsearch1-cli/README.md b/gen/customsearch1-cli/README.md index 1a941fdf56..9728515cc6 100644 --- a/gen/customsearch1-cli/README.md +++ b/gen/customsearch1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *customsearch* API at revision *20151130*. The CLI is at version *0.3.6*. +This documentation was generated from the *customsearch* API at revision *20160411*. The CLI is at version *0.3.6*. ```bash customsearch1 [options] diff --git a/gen/customsearch1-cli/mkdocs.yml b/gen/customsearch1-cli/mkdocs.yml index ee056b80e1..be3825e727 100644 --- a/gen/customsearch1-cli/mkdocs.yml +++ b/gen/customsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: customsearch v0.3.6+20151130 +site_name: customsearch v0.3.6+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 29948c9cd1..005ad8be94 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+20151130") + .version("0.3.6+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/customsearch1/Cargo.toml b/gen/customsearch1/Cargo.toml index d8eda0710d..cf31d830d3 100644 --- a/gen/customsearch1/Cargo.toml +++ b/gen/customsearch1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-customsearch1" -version = "0.1.14+20151130" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/customsearch1/README.md b/gen/customsearch1/README.md index ea57f8f45d..87af0cea8d 100644 --- a/gen/customsearch1/README.md +++ b/gen/customsearch1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-customsearch1` library allows access to all features of the *Google customsearch* service. -This documentation was generated from *customsearch* crate version *0.1.14+20151130*, where *20151130* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *customsearch* crate version *0.1.14+20160411*, where *20160411* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *customsearch* *v1* API can be found at the [official documentation site](https://developers.google.com/custom-search/v1/using_rest). diff --git a/gen/customsearch1/src/lib.rs b/gen/customsearch1/src/lib.rs index bc243c5b86..aae6af26d3 100644 --- a/gen/customsearch1/src/lib.rs +++ b/gen/customsearch1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *customsearch* crate version *0.1.14+20151130*, where *20151130* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *customsearch* crate version *0.1.14+20160411*, where *20160411* is the exact revision of the *customsearch:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *customsearch* *v1* API can be found at the //! [official documentation site](https://developers.google.com/custom-search/v1/using_rest). diff --git a/gen/dataproc1-cli/Cargo.toml b/gen/dataproc1-cli/Cargo.toml index 44c7ba24ef..ef699ec3ed 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+20160219" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "dataproc1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dataproc1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dataproc1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dataproc1] diff --git a/gen/dataproc1-cli/README.md b/gen/dataproc1-cli/README.md index 864ae14437..c71c301a05 100644 --- a/gen/dataproc1-cli/README.md +++ b/gen/dataproc1-cli/README.md @@ -24,13 +24,10 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *dataproc* API at revision *20160219*. The CLI is at version *0.3.6*. +This documentation was generated from the *dataproc* API at revision *20160503*. The CLI is at version *0.3.6*. ```bash dataproc1 [options] - media - download [-p ]... [-o ] - upload (-r )... (-u (simple|resumable) -f [-m ]) [-p ]... [-o ] projects regions-clusters-create (-r )... [-p ]... [-o ] regions-clusters-delete [-p ]... [-o ] diff --git a/gen/dataproc1-cli/mkdocs.yml b/gen/dataproc1-cli/mkdocs.yml index 55bae49a8d..453dfa2ba2 100644 --- a/gen/dataproc1-cli/mkdocs.yml +++ b/gen/dataproc1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dataproc v0.3.6+20160219 +site_name: dataproc v0.3.6+20160503 site_url: http://byron.github.io/google-apis-rs/google-dataproc1-cli site_description: Write integrating applications with bcore @@ -9,8 +9,6 @@ site_dir: build_html pages: - ['index.md', 'Home'] -- ['media_download.md', 'Media', 'Download'] -- ['media_upload.md', 'Media', 'Upload'] - ['projects_regions-clusters-create.md', 'Projects', 'Regions Clusters Create'] - ['projects_regions-clusters-delete.md', 'Projects', 'Regions Clusters Delete'] - ['projects_regions-clusters-diagnose.md', 'Projects', 'Regions Clusters Diagnose'] diff --git a/gen/dataproc1-cli/src/main.rs b/gen/dataproc1-cli/src/main.rs index 9b66b22d58..b1233e22c0 100644 --- a/gen/dataproc1-cli/src/main.rs +++ b/gen/dataproc1-cli/src/main.rs @@ -45,156 +45,6 @@ struct Engine<'n> { impl<'n> Engine<'n> { - fn _media_download(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) - -> Result<(), DoitError> { - let mut download_mode = false; - let mut call = self.hub.media().download(opt.value_of("resource-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 { - 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 _media_upload(&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-name" => Some(("resourceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-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::Media = json::value::from_value(object).unwrap(); - let mut call = self.hub.media().upload(request, opt.value_of("resource-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 vals = opt.values_of("mode").unwrap().collect::>(); - let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); - let mut input_file = input_file_from_opts(vals[1], err); - let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); - 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::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), - CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), - CallType::Standard => 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_regions_clusters_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { @@ -1310,20 +1160,6 @@ impl<'n> Engine<'n> { let mut call_result: Result<(), DoitError> = Ok(()); let mut err_opt: Option = None; match self.opt.subcommand() { - ("media", Some(opt)) => { - match opt.subcommand() { - ("download", Some(opt)) => { - call_result = self._media_download(opt, dry_run, &mut err); - }, - ("upload", Some(opt)) => { - call_result = self._media_upload(opt, dry_run, &mut err); - }, - _ => { - err.issues.push(CLIError::MissingMethodError("media".to_string())); - writeln!(io::stderr(), "{}\n", opt.usage()).ok(); - } - } - }, ("projects", Some(opt)) => { match opt.subcommand() { ("regions-clusters-create", Some(opt)) => { @@ -1462,67 +1298,7 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; - let upload_value_names = ["mode", "file"]; let arg_data = [ - ("media", "methods: 'download' and 'upload'", vec![ - ("download", - Some(r##"Method for media download. Download is supported on the URI `/v1/media/{+name}?alt=media`."##), - "Details at http://byron.github.io/google-apis-rs/google_dataproc1_cli/media_download", - vec![ - (Some(r##"resource-name"##), - None, - Some(r##"Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name."##), - 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)), - ]), - ("upload", - Some(r##"Method for media upload. Upload is supported on the URI `/upload/v1/media/{+name}`."##), - "Details at http://byron.github.io/google-apis-rs/google_dataproc1_cli/media_upload", - vec![ - (Some(r##"resource-name"##), - None, - Some(r##"Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_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##"mode"##), - Some(r##"u"##), - Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), - 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)), - ]), - ]), - ("projects", "methods: 'regions-clusters-create', 'regions-clusters-delete', 'regions-clusters-diagnose', 'regions-clusters-get', 'regions-clusters-list', 'regions-clusters-patch', 'regions-jobs-cancel', 'regions-jobs-delete', 'regions-jobs-get', 'regions-jobs-list', 'regions-jobs-submit', 'regions-operations-cancel', 'regions-operations-delete', 'regions-operations-get' and 'regions-operations-list'", vec![ ("regions-clusters-create", Some(r##"Creates a cluster in a project."##), @@ -1998,8 +1774,8 @@ fn main() { let mut app = App::new("dataproc1") .author("Sebastian Thiel ") - .version("0.3.6+20160219") - .about("An API for managing Hadoop-based clusters and jobs on Google Cloud Platform.") + .version("0.3.6+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") .long("scope") @@ -2056,17 +1832,6 @@ fn main() { if let &Some(multi) = multi { arg = arg.multiple(multi); } - if arg_name_str == "mode" { - arg = arg.number_of_values(2); - arg = arg.value_names(&upload_value_names); - - scmd = scmd.arg(Arg::with_name("mime") - .short("m") - .requires("mode") - .required(false) - .help("The file's mime time, like 'application/octet-stream'") - .takes_value(true)); - } scmd = scmd.arg(arg); } mcmd = mcmd.subcommand(scmd); diff --git a/gen/dataproc1/Cargo.toml b/gen/dataproc1/Cargo.toml index e0b5985fb4..8795debcc0 100644 --- a/gen/dataproc1/Cargo.toml +++ b/gen/dataproc1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dataproc1" -version = "0.1.14+20160219" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dataproc1/README.md b/gen/dataproc1/README.md index 27521bf004..9dbb48e524 100644 --- a/gen/dataproc1/README.md +++ b/gen/dataproc1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dataproc1` library allows access to all features of the *Google dataproc* service. -This documentation was generated from *dataproc* crate version *0.1.14+20160219*, where *20160219* is the exact revision of the *dataproc:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *dataproc* crate version *0.1.14+20160503*, where *20160503* is the exact revision of the *dataproc:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *dataproc* *v1* API can be found at the [official documentation site](https://cloud.google.com/dataproc/). @@ -13,20 +13,10 @@ Everything else about the *dataproc* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dataproc1/struct.Dataproc.html) ... -* [media](http://byron.github.io/google-apis-rs/google_dataproc1/struct.Media.html) - * [*download*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.MediaDownloadCall.html) and [*upload*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.MediaUploadCall.html) * projects * [*regions clusters create*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterCreateCall.html), [*regions clusters delete*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterDeleteCall.html), [*regions clusters diagnose*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterDiagnoseCall.html), [*regions clusters get*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterGetCall.html), [*regions clusters list*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterListCall.html), [*regions clusters patch*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionClusterPatchCall.html), [*regions jobs cancel*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionJobCancelCall.html), [*regions jobs delete*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionJobDeleteCall.html), [*regions jobs get*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionJobGetCall.html), [*regions jobs list*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionJobListCall.html), [*regions jobs submit*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionJobSubmitCall.html), [*regions operations cancel*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionOperationCancelCall.html), [*regions operations delete*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionOperationDeleteCall.html), [*regions operations get*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionOperationGetCall.html) and [*regions operations list*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.ProjectRegionOperationListCall.html) -Upload supported by ... - -* [*upload media*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.MediaUploadCall.html) - -Download supported by ... - -* [*download media*](http://byron.github.io/google-apis-rs/google_dataproc1/struct.MediaDownloadCall.html) - # Structure of this Library diff --git a/gen/dataproc1/src/lib.rs b/gen/dataproc1/src/lib.rs index d3ae9f2bf6..f093468081 100644 --- a/gen/dataproc1/src/lib.rs +++ b/gen/dataproc1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dataproc* crate version *0.1.14+20160219*, where *20160219* is the exact revision of the *dataproc:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *dataproc* crate version *0.1.14+20160503*, where *20160503* is the exact revision of the *dataproc:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *dataproc* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/dataproc/). @@ -11,20 +11,10 @@ //! //! Handle the following *Resources* with ease from the central [hub](struct.Dataproc.html) ... //! -//! * [media](struct.Media.html) -//! * [*download*](struct.MediaDownloadCall.html) and [*upload*](struct.MediaUploadCall.html) //! * projects //! * [*regions clusters create*](struct.ProjectRegionClusterCreateCall.html), [*regions clusters delete*](struct.ProjectRegionClusterDeleteCall.html), [*regions clusters diagnose*](struct.ProjectRegionClusterDiagnoseCall.html), [*regions clusters get*](struct.ProjectRegionClusterGetCall.html), [*regions clusters list*](struct.ProjectRegionClusterListCall.html), [*regions clusters patch*](struct.ProjectRegionClusterPatchCall.html), [*regions jobs cancel*](struct.ProjectRegionJobCancelCall.html), [*regions jobs delete*](struct.ProjectRegionJobDeleteCall.html), [*regions jobs get*](struct.ProjectRegionJobGetCall.html), [*regions jobs list*](struct.ProjectRegionJobListCall.html), [*regions jobs submit*](struct.ProjectRegionJobSubmitCall.html), [*regions operations cancel*](struct.ProjectRegionOperationCancelCall.html), [*regions operations delete*](struct.ProjectRegionOperationDeleteCall.html), [*regions operations get*](struct.ProjectRegionOperationGetCall.html) and [*regions operations list*](struct.ProjectRegionOperationListCall.html) //! //! -//! Upload supported by ... -//! -//! * [*upload media*](struct.MediaUploadCall.html) -//! -//! Download supported by ... -//! -//! * [*download media*](struct.MediaDownloadCall.html) -//! //! //! //! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). diff --git a/gen/dataproc1/src/lib.rs.in b/gen/dataproc1/src/lib.rs.in index 92ff06b84e..ad8ff01268 100644 --- a/gen/dataproc1/src/lib.rs.in +++ b/gen/dataproc1/src/lib.rs.in @@ -36,15 +36,6 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { - /// Administrate log data for your projects - LoggingAdmin, - - /// View log data for your projects - LoggingRead, - - /// Submit log data for your projects - LoggingWrite, - /// View and manage your data across Google Cloud Platform services CloudPlatform, } @@ -52,9 +43,6 @@ pub enum Scope { impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { - Scope::LoggingAdmin => "https://www.googleapis.com/auth/logging.admin", - Scope::LoggingRead => "https://www.googleapis.com/auth/logging.read", - Scope::LoggingWrite => "https://www.googleapis.com/auth/logging.write", Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", } } @@ -62,7 +50,7 @@ impl AsRef for Scope { impl Default for Scope { fn default() -> Scope { - Scope::LoggingRead + Scope::CloudPlatform } } @@ -150,9 +138,6 @@ impl<'a, C, A> Dataproc } } - pub fn media(&'a self) -> MediaMethods<'a, C, A> { - MediaMethods { hub: &self } - } pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { ProjectMethods { hub: &self } } @@ -232,27 +217,6 @@ pub struct InstanceGroupConfig { impl Part for InstanceGroupConfig {} -/// Media 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*). -/// -/// * [upload media](struct.MediaUploadCall.html) (request|response) -/// * [download media](struct.MediaDownloadCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Media { - /// Name of the media resource. - #[serde(rename="resourceName")] - pub resource_name: Option, -} - -impl RequestValue for Media {} -impl ResponseResult for Media {} - - /// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON object `{}`. /// /// # Activities @@ -343,7 +307,7 @@ pub struct ClusterConfig { /// [Optional] A Google Cloud Storage staging bucket used for sharing generated SSH keys and config. If you do not specify a staging bucket, Cloud Dataproc will determine an appropriate Cloud Storage location (US, ASIA, or EU) for your cluster's staging bucket according to the Google Compute Engine zone where your cluster is deployed, and then it will create and manage this project-level, per-location bucket for you. #[serde(rename="configBucket")] pub config_bucket: Option, - /// [Optional] The shared Google Compute Engine config settings for all instances in a cluster. + /// [Required] The shared Google Compute Engine config settings for all instances in a cluster. #[serde(rename="gceClusterConfig")] pub gce_cluster_config: Option, /// [Optional] Commands to execute on each node after config is completed. By default, executables are run on master and all worker nodes. You can test a node's role metadata to run an executable on a master or worker node, as shown below: ROLE=$(/usr/share/google/get_metadata_value attributes/role) if [[ "${ROLE}" == 'Master' ]]; then ... master specific actions ... else ... worker specific actions ... fi @@ -900,83 +864,6 @@ impl RequestValue for CancelJobRequest {} // MethodBuilders ### // ################# -/// A builder providing access to all methods supported on *media* resources. -/// It is not used directly, but through the `Dataproc` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_dataproc1 as dataproc1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dataproc1::Dataproc; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Dataproc::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `download(...)` and `upload(...)` -/// // to build up your call. -/// let rb = hub.media(); -/// # } -/// ``` -pub struct MediaMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dataproc, -} - -impl<'a, C, A> MethodsBuilder for MediaMethods<'a, C, A> {} - -impl<'a, C, A> MediaMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Method for media download. Download is supported on the URI `/v1/media/{+name}?alt=media`. - /// - /// # Arguments - /// - /// * `resourceName` - Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. - pub fn download(&self, resource_name: &str) -> MediaDownloadCall<'a, C, A> { - MediaDownloadCall { - hub: self.hub, - _resource_name: resource_name.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Method for media upload. Upload is supported on the URI `/upload/v1/media/{+name}`. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `resourceName` - Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. - pub fn upload(&self, request: Media, resource_name: &str) -> MediaUploadCall<'a, C, A> { - MediaUploadCall { - hub: self.hub, - _request: request, - _resource_name: resource_name.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 `Dataproc` hub. /// @@ -1015,27 +902,6 @@ 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: - /// - /// Submits a job to a cluster. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - [Required] The ID of the Google Cloud Platform project that the job belongs to. - /// * `region` - [Required] The Cloud Dataproc region in which to handle the request. - pub fn regions_jobs_submit(&self, request: SubmitJobRequest, project_id: &str, region: &str) -> ProjectRegionJobSubmitCall<'a, C, A> { - ProjectRegionJobSubmitCall { - hub: self.hub, - _request: request, - _project_id: project_id.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: /// /// Gets the resource representation for a cluster in a project. @@ -1080,21 +946,21 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets cluster diagnostic information. After the operation completes, the Operation.response field contains `DiagnoseClusterOutputLocation`. + /// Lists regions/{region}/jobs in a project. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `projectId` - [Required] The ID of the Google Cloud Platform project that the cluster belongs to. + /// * `projectId` - [Required] The ID of the Google Cloud Platform project that the job belongs to. /// * `region` - [Required] The Cloud Dataproc region in which to handle the request. - /// * `clusterName` - [Required] The cluster name. - pub fn regions_clusters_diagnose(&self, request: DiagnoseClusterRequest, project_id: &str, region: &str, cluster_name: &str) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { - ProjectRegionClusterDiagnoseCall { + pub fn regions_jobs_list(&self, project_id: &str, region: &str) -> ProjectRegionJobListCall<'a, C, A> { + ProjectRegionJobListCall { hub: self.hub, - _request: request, _project_id: project_id.to_string(), _region: region.to_string(), - _cluster_name: cluster_name.to_string(), + _page_token: Default::default(), + _page_size: Default::default(), + _job_state_matcher: Default::default(), + _cluster_name: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1165,13 +1031,13 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. + /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. /// /// # Arguments /// - /// * `name` - The name of the operation resource to be deleted. - pub fn regions_operations_delete(&self, name: &str) -> ProjectRegionOperationDeleteCall<'a, C, A> { - ProjectRegionOperationDeleteCall { + /// * `name` - The name of the operation resource. + pub fn regions_operations_get(&self, name: &str) -> ProjectRegionOperationGetCall<'a, C, A> { + ProjectRegionOperationGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), @@ -1203,15 +1069,21 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. + /// Gets cluster diagnostic information. After the operation completes, the Operation.response field contains `DiagnoseClusterOutputLocation`. /// /// # Arguments /// - /// * `name` - The name of the operation resource. - pub fn regions_operations_get(&self, name: &str) -> ProjectRegionOperationGetCall<'a, C, A> { - ProjectRegionOperationGetCall { + /// * `request` - No description provided. + /// * `projectId` - [Required] The ID of the Google Cloud Platform project that the cluster belongs to. + /// * `region` - [Required] The Cloud Dataproc region in which to handle the request. + /// * `clusterName` - [Required] The cluster name. + pub fn regions_clusters_diagnose(&self, request: DiagnoseClusterRequest, project_id: &str, region: &str, cluster_name: &str) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + ProjectRegionClusterDiagnoseCall { hub: self.hub, - _name: name.to_string(), + _request: request, + _project_id: project_id.to_string(), + _region: region.to_string(), + _cluster_name: cluster_name.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1220,21 +1092,19 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists regions/{region}/jobs in a project. + /// Submits a job to a cluster. /// /// # Arguments /// + /// * `request` - No description provided. /// * `projectId` - [Required] The ID of the Google Cloud Platform project that the job belongs to. /// * `region` - [Required] The Cloud Dataproc region in which to handle the request. - pub fn regions_jobs_list(&self, project_id: &str, region: &str) -> ProjectRegionJobListCall<'a, C, A> { - ProjectRegionJobListCall { + pub fn regions_jobs_submit(&self, request: SubmitJobRequest, project_id: &str, region: &str) -> ProjectRegionJobSubmitCall<'a, C, A> { + ProjectRegionJobSubmitCall { hub: self.hub, + _request: request, _project_id: project_id.to_string(), _region: region.to_string(), - _page_token: Default::default(), - _page_size: Default::default(), - _job_state_matcher: Default::default(), - _cluster_name: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1283,6 +1153,23 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. + /// + /// # Arguments + /// + /// * `name` - The name of the operation resource to be deleted. + pub fn regions_operations_delete(&self, name: &str) -> ProjectRegionOperationDeleteCall<'a, C, A> { + ProjectRegionOperationDeleteCall { + hub: self.hub, + _name: name.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. @@ -1335,942 +1222,6 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { // CallBuilders ### // ################# -/// Method for media download. Download is supported on the URI `/v1/media/{+name}?alt=media`. -/// -/// 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 `Media` structure that you would usually get. The latter will be a default value. -/// -/// A builder for the *download* method supported by a *media* resource. -/// It is not used directly, but through a `MediaMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dataproc1 as dataproc1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dataproc1::Dataproc; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Dataproc::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.media().download("resourceName") -/// .doit(); -/// # } -/// ``` -pub struct MediaDownloadCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dataproc, - _resource_name: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for MediaDownloadCall<'a, C, A> {} - -impl<'a, C, A> MediaDownloadCall<'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, Media)> { - use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dataproc.media.download", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - params.push(("resourceName", self._resource_name.to_string())); - for &field in ["resourceName"].iter() { - if self._additional_params.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://dataproc.googleapis.com/v1/media/{+resourceName}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() { - let mut replace_with = String::new(); - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = value.to_string(); - break; - } - } - if find_this.as_bytes()[1] == '+' as u8 { - replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); - } - url = url.replace(find_this, &replace_with); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["resourceName"].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 = 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) - } - } - } - } - - - /// Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. - /// - /// Sets the *resource name* path property to 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_name(mut self, new_value: &str) -> MediaDownloadCall<'a, C, A> { - self._resource_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) -> MediaDownloadCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> MediaDownloadCall<'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) -> MediaDownloadCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Method for media upload. Upload is supported on the URI `/upload/v1/media/{+name}`. -/// -/// A builder for the *upload* method supported by a *media* resource. -/// It is not used directly, but through a `MediaMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dataproc1 as dataproc1; -/// use dataproc1::Media; -/// use std::fs; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dataproc1::Dataproc; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Dataproc::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 = Media::default(); -/// -/// // You can configure optional parameters by calling the respective setters at will, and -/// // execute the final call using `upload(...)`. -/// // Values shown here are possibly random and not representative ! -/// let result = hub.media().upload(req, "resourceName") -/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); -/// # } -/// ``` -pub struct MediaUploadCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dataproc, - _request: Media, - _resource_name: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for MediaUploadCall<'a, C, A> {} - -impl<'a, C, A> MediaUploadCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, Media)> - where RS: ReadSeek { - use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dataproc.media.upload", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("resourceName", self._resource_name.to_string())); - for &field in ["alt", "resourceName"].iter() { - if self._additional_params.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, upload_type) = - if protocol == "simple" { - ("https://dataproc.googleapis.com/upload/v1/media/{+resourceName}".to_string(), "multipart") - } else if protocol == "resumable" { - ("https://dataproc.googleapis.com/resumable/upload/v1/media/{+resourceName}".to_string(), "resumable") - } else { - unreachable!() - }; - params.push(("uploadType", upload_type.to_string())); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() { - let mut replace_with = String::new(); - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = value.to_string(); - break; - } - } - if find_this.as_bytes()[1] == '+' as u8 { - replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); - } - url = url.replace(find_this, &replace_with); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["resourceName"].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(); - - let mut should_ask_dlg_for_url = false; - let mut upload_url_from_server; - let mut upload_url: Option = None; - - 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 = { - if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { - should_ask_dlg_for_url = false; - upload_url_from_server = false; - let url = upload_url.as_ref().and_then(|s| Some(hyper::Url::parse(s).unwrap())).unwrap(); - hyper::client::Response::new(url, Box::new(cmn::DummyNetworkStream)).and_then(|mut res| { - res.status = hyper::status::StatusCode::Ok; - res.headers.set(Location(upload_url.as_ref().unwrap().clone())); - Ok(res) - }) - } else { - let mut mp_reader: MultiPartReader = Default::default(); - let (mut body_reader, content_type) = match protocol { - "simple" => { - mp_reader.reserve_exact(2); - let size = reader.seek(io::SeekFrom::End(0)).unwrap(); - reader.seek(io::SeekFrom::Start(0)).unwrap(); - - mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) - .add_part(&mut reader, size, reader_mime_type.clone()); - let mime_type = mp_reader.mime_type(); - (&mut mp_reader as &mut io::Read, ContentType(mime_type)) - }, - _ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())), - }; - 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(content_type) - .body(&mut body_reader); - upload_url_from_server = true; - if protocol == "resumable" { - req = req.header(cmn::XUploadContentType(reader_mime_type.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)) - } - } - if protocol == "resumable" { - let size = reader.seek(io::SeekFrom::End(0)).unwrap(); - reader.seek(io::SeekFrom::Start(0)).unwrap(); - - let mut client = &mut *self.hub.client.borrow_mut(); - let upload_result = { - let url_str = &res.headers.get::().expect("Location header is part of protocol").0; - if upload_url_from_server { - dlg.store_upload_url(Some(url_str)); - } - - cmn::ResumableUploadHelper { - client: &mut client.borrow_mut(), - delegate: dlg, - start_at: if upload_url_from_server { Some(0) } else { None }, - auth: &mut *self.hub.auth.borrow_mut(), - user_agent: &self.hub._user_agent, - auth_header: auth_header.clone(), - url: url_str, - reader: &mut reader, - media_type: reader_mime_type.clone(), - content_length: size - }.upload() - }; - match upload_result { - None => { - dlg.finished(false); - return Err(Error::Cancelled) - } - Some(Err(err)) => { - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Some(Ok(upload_result)) => { - res = upload_result; - if !res.status.is_success() { - dlg.store_upload_url(None); - dlg.finished(false); - return Err(Error::Failure(res)) - } - } - } - } - 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) - } - } - } - } - - /// Upload media all at once. - /// If the upload fails for whichever reason, all progress is lost. - /// - /// * *max size*: 0kb - /// * *multipart*: yes - /// * *valid mime types*: '*/*' - pub fn upload(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Media)> - where RS: ReadSeek { - self.doit(stream, mime_type, "simple") - } - /// Upload media in a resumable fashion. - /// Even if the upload fails or is interrupted, it can be resumed for a - /// certain amount of time as the server maintains state temporarily. - /// - /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL - /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate - /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using - /// `cancel_chunk_upload(...)`. - /// - /// * *max size*: 0kb - /// * *multipart*: yes - /// * *valid mime types*: '*/*' - pub fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, Media)> - where RS: ReadSeek { - self.doit(resumeable_stream, mime_type, "resumable") - } - - /// - /// 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: Media) -> MediaUploadCall<'a, C, A> { - self._request = new_value; - self - } - /// Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. - /// - /// Sets the *resource name* path property to 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_name(mut self, new_value: &str) -> MediaUploadCall<'a, C, A> { - self._resource_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) -> MediaUploadCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> MediaUploadCall<'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) -> MediaUploadCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Submits a job to a cluster. -/// -/// A builder for the *regions.jobs.submit* 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_dataproc1 as dataproc1; -/// use dataproc1::SubmitJobRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dataproc1::Dataproc; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Dataproc::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 = SubmitJobRequest::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().regions_jobs_submit(req, "projectId", "region") -/// .doit(); -/// # } -/// ``` -pub struct ProjectRegionJobSubmitCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dataproc, - _request: SubmitJobRequest, - _project_id: String, - _region: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectRegionJobSubmitCall<'a, C, A> {} - -impl<'a, C, A> ProjectRegionJobSubmitCall<'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, Job)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dataproc.projects.regions.jobs.submit", - 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())); - params.push(("region", self._region.to_string())); - for &field in ["alt", "projectId", "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://dataproc.googleapis.com/v1/projects/{projectId}/regions/{region}/jobs:submit".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{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", "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: SubmitJobRequest) -> ProjectRegionJobSubmitCall<'a, C, A> { - self._request = new_value; - self - } - /// [Required] The ID of the Google Cloud Platform project that the job belongs to. - /// - /// 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) -> ProjectRegionJobSubmitCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// [Required] The Cloud Dataproc region in which to handle the 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) -> ProjectRegionJobSubmitCall<'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) -> ProjectRegionJobSubmitCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> ProjectRegionJobSubmitCall<'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) -> ProjectRegionJobSubmitCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Gets the resource representation for a cluster in a project. /// /// A builder for the *regions.clusters.get* method supported by a *project* resource. @@ -2563,8 +1514,8 @@ impl<'a, C, A> ProjectRegionClusterGetCall<'a, C, A> where C: BorrowMut ProjectRegionClusterListCall<'a, C, A> where C: BorrowMut ProjectRegionClusterListCall<'a, C, A> where C: BorrowMut ProjectRegionClusterListCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Dataproc::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 = DiagnoseClusterRequest::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().regions_clusters_diagnose(req, "projectId", "region", "clusterName") +/// let result = hub.projects().regions_jobs_list("projectId", "region") +/// .page_token("sadipscing") +/// .page_size(-31) +/// .job_state_matcher("ea") +/// .cluster_name("no") /// .doit(); /// # } /// ``` -pub struct ProjectRegionClusterDiagnoseCall<'a, C, A> +pub struct ProjectRegionJobListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dataproc, - _request: DiagnoseClusterRequest, _project_id: String, _region: String, - _cluster_name: String, + _page_token: Option, + _page_size: Option, + _job_state_matcher: Option, + _cluster_name: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectRegionClusterDiagnoseCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectRegionJobListCall<'a, C, A> {} -impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectRegionJobListCall<'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)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListJobsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2876,13 +1827,24 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dataproc.projects.regions.clusters.diagnose", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "dataproc.projects.regions.jobs.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(("region", self._region.to_string())); - params.push(("clusterName", self._cluster_name.to_string())); - for &field in ["alt", "projectId", "region", "clusterName"].iter() { + 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._job_state_matcher { + params.push(("jobStateMatcher", value.to_string())); + } + if let Some(value) = self._cluster_name { + params.push(("clusterName", value.to_string())); + } + for &field in ["alt", "projectId", "region", "pageToken", "pageSize", "jobStateMatcher", "clusterName"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2894,12 +1856,12 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -2910,8 +1872,8 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut = Vec::with_capacity(3); - for param_name in ["clusterName", "region", "projectId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["region", "projectId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -2926,17 +1888,6 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDiagnoseCall<'a, C, A> { - self._request = new_value; - self - } - /// [Required] The ID of the Google Cloud Platform project that the cluster belongs to. + /// [Required] The ID of the Google Cloud Platform project that the job belongs to. /// /// 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) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { self._project_id = new_value.to_string(); self } @@ -3037,18 +1975,36 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDiagnoseCall<'a, C, A> { + pub fn region(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { self._region = new_value.to_string(); self } - /// [Required] The cluster name. + /// [Optional] The page token, returned by a previous call, to request the next page of results. /// - /// Sets the *cluster name* path property to the given value. + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// [Optional] The number of results to return in each response. /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn cluster_name(mut self, new_value: &str) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { - self._cluster_name = new_value.to_string(); + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> ProjectRegionJobListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// [Optional] Specifies enumerated categories of jobs to list. + /// + /// Sets the *job state matcher* query property to the given value. + pub fn job_state_matcher(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { + self._job_state_matcher = Some(new_value.to_string()); + self + } + /// [Optional] If set, the returned jobs list includes only jobs that were submitted to the named cluster. + /// + /// Sets the *cluster name* query property to the given value. + pub fn cluster_name(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { + self._cluster_name = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -3057,7 +2013,7 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDiagnoseCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectRegionJobListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -3084,7 +2040,7 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectRegionClusterDiagnoseCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectRegionJobListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -3101,7 +2057,7 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectRegionClusterDiagnoseCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectRegionJobListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -3142,7 +2098,7 @@ impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'a, C, A> where C: BorrowMut ProjectRegionClusterPatchCall<'a, C, A> where C: BorrowMut ProjectRegionClusterPatchCall<'a, C, A> { @@ -3927,9 +2883,9 @@ impl<'a, C, A> ProjectRegionOperationCancelCall<'a, C, A> where C: BorrowMut ProjectRegionOperationCancelCall<'a, C, A> where C: BorrowMut +pub struct ProjectRegionOperationGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dataproc, @@ -3967,13 +2923,13 @@ pub struct ProjectRegionOperationDeleteCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectRegionOperationDeleteCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectRegionOperationGetCall<'a, C, A> {} -impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectRegionOperationGetCall<'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, Empty)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> { use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; @@ -3982,8 +2938,8 @@ impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dataproc.projects.regions.operations.delete", - http_method: hyper::method::Method::Delete }); + dlg.begin(MethodInfo { id: "dataproc.projects.regions.operations.get", + http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].iter() { @@ -4051,7 +3007,7 @@ impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut ProjectRegionOperationDeleteCall<'a, C, A> { + pub fn name(mut self, new_value: &str) -> ProjectRegionOperationGetCall<'a, C, A> { self._name = new_value.to_string(); self } @@ -4120,7 +3076,7 @@ impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut ProjectRegionOperationDeleteCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectRegionOperationGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4147,7 +3103,7 @@ impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectRegionOperationDeleteCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectRegionOperationGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4164,7 +3120,7 @@ impl<'a, C, A> ProjectRegionOperationDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectRegionOperationDeleteCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectRegionOperationGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4437,9 +3393,9 @@ impl<'a, C, A> ProjectRegionClusterDeleteCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDeleteCall<'a, C, A> where C: BorrowMut ProjectRegionClusterDeleteCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Dataproc::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 = DiagnoseClusterRequest::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().regions_operations_get("name") +/// let result = hub.projects().regions_clusters_diagnose(req, "projectId", "region", "clusterName") /// .doit(); /// # } /// ``` -pub struct ProjectRegionOperationGetCall<'a, C, A> +pub struct ProjectRegionClusterDiagnoseCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dataproc, - _name: String, + _request: DiagnoseClusterRequest, + _project_id: String, + _region: String, + _cluster_name: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectRegionOperationGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectRegionClusterDiagnoseCall<'a, C, A> {} -impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectRegionClusterDiagnoseCall<'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 url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4492,11 +3456,13 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dataproc.projects.regions.operations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("name", self._name.to_string())); - for &field in ["alt", "name"].iter() { + dlg.begin(MethodInfo { id: "dataproc.projects.regions.clusters.diagnose", + 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(("region", self._region.to_string())); + params.push(("clusterName", self._cluster_name.to_string())); + for &field in ["alt", "projectId", "region", "clusterName"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4508,27 +3474,24 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut = None; for &(name, ref value) in params.iter() { if name == param_name { - replace_with = value.to_string(); + replace_with = Some(value); break; } } - if find_this.as_bytes()[1] == '+' as u8 { - replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); - } - url = url.replace(find_this, &replace_with); + 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 ["name"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["clusterName", "region", "projectId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -4543,6 +3506,17 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> { - self._name = new_value.to_string(); + pub fn request(mut self, new_value: DiagnoseClusterRequest) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + self._request = new_value; + self + } + /// [Required] The ID of the Google Cloud Platform project that the cluster belongs to. + /// + /// 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) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// [Required] The Cloud Dataproc region in which to handle the 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) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + self._region = new_value.to_string(); + self + } + /// [Required] The cluster name. + /// + /// Sets the *cluster name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn cluster_name(mut self, new_value: &str) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { + self._cluster_name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -4630,7 +3637,7 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectRegionClusterDiagnoseCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4657,7 +3664,7 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectRegionOperationGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectRegionClusterDiagnoseCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4674,7 +3681,7 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectRegionOperationGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectRegionClusterDiagnoseCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4682,9 +3689,9 @@ impl<'a, C, A> ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut ProjectRegionOperationGetCall<'a, C, A> where C: BorrowMut::default(), None); /// # let mut hub = Dataproc::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 = SubmitJobRequest::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().regions_jobs_list("projectId", "region") -/// .page_token("eirmod") -/// .page_size(-43) -/// .job_state_matcher("amet") -/// .cluster_name("no") +/// let result = hub.projects().regions_jobs_submit(req, "projectId", "region") /// .doit(); /// # } /// ``` -pub struct ProjectRegionJobListCall<'a, C, A> +pub struct ProjectRegionJobSubmitCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dataproc, + _request: SubmitJobRequest, _project_id: String, _region: String, - _page_token: Option, - _page_size: Option, - _job_state_matcher: Option, - _cluster_name: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for ProjectRegionJobListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for ProjectRegionJobSubmitCall<'a, C, A> {} -impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> ProjectRegionJobSubmitCall<'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, ListJobsResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Job)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -4745,24 +3751,12 @@ impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dataproc.projects.regions.jobs.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "dataproc.projects.regions.jobs.submit", + 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())); 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._page_size { - params.push(("pageSize", value.to_string())); - } - if let Some(value) = self._job_state_matcher { - params.push(("jobStateMatcher", value.to_string())); - } - if let Some(value) = self._cluster_name { - params.push(("clusterName", value.to_string())); - } - for &field in ["alt", "projectId", "region", "pageToken", "pageSize", "jobStateMatcher", "clusterName"].iter() { + for &field in ["alt", "projectId", "region"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4774,7 +3768,7 @@ impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut ProjectRegionJobListCall<'a, C, A> where C: BorrowMut ProjectRegionJobListCall<'a, C, A> where C: BorrowMut ProjectRegionJobListCall<'a, C, A> where C: BorrowMut ProjectRegionJobSubmitCall<'a, C, A> { + self._request = new_value; + self + } /// [Required] The ID of the Google Cloud Platform project that the job belongs to. /// /// 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) -> ProjectRegionJobListCall<'a, C, A> { + pub fn project_id(mut self, new_value: &str) -> ProjectRegionJobSubmitCall<'a, C, A> { self._project_id = new_value.to_string(); self } @@ -4893,45 +3911,17 @@ impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut ProjectRegionJobListCall<'a, C, A> { + pub fn region(mut self, new_value: &str) -> ProjectRegionJobSubmitCall<'a, C, A> { self._region = new_value.to_string(); self } - /// [Optional] The page token, returned by a previous call, to request the next page of results. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// [Optional] The number of results to return in each response. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> ProjectRegionJobListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// [Optional] Specifies enumerated categories of jobs to list. - /// - /// Sets the *job state matcher* query property to the given value. - pub fn job_state_matcher(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { - self._job_state_matcher = Some(new_value.to_string()); - self - } - /// [Optional] If set, the returned jobs list includes only jobs that were submitted to the named cluster. - /// - /// Sets the *cluster name* query property to the given value. - pub fn cluster_name(mut self, new_value: &str) -> ProjectRegionJobListCall<'a, C, A> { - self._cluster_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) -> ProjectRegionJobListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectRegionJobSubmitCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -4958,7 +3948,7 @@ impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut(mut self, name: T, value: T) -> ProjectRegionJobListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> ProjectRegionJobSubmitCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -4975,7 +3965,7 @@ impl<'a, C, A> ProjectRegionJobListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> ProjectRegionJobListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> ProjectRegionJobSubmitCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -5532,6 +4522,251 @@ impl<'a, C, A> ProjectRegionJobDeleteCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Dataproc::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().regions_operations_delete("name") +/// .doit(); +/// # } +/// ``` +pub struct ProjectRegionOperationDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dataproc, + _name: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectRegionOperationDeleteCall<'a, C, A> {} + +impl<'a, C, A> ProjectRegionOperationDeleteCall<'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, Empty)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dataproc.projects.regions.operations.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("name", self._name.to_string())); + for &field in ["alt", "name"].iter() { + if self._additional_params.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://dataproc.googleapis.com/v1/{+name}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{+name}", "name")].iter() { + let mut replace_with = String::new(); + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = value.to_string(); + break; + } + } + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["name"].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) + } + } + } + } + + + /// The name of the operation resource to be deleted. + /// + /// Sets the *name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn name(mut self, new_value: &str) -> ProjectRegionOperationDeleteCall<'a, C, A> { + self._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) -> ProjectRegionOperationDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectRegionOperationDeleteCall<'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) -> ProjectRegionOperationDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding below allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. /// /// A builder for the *regions.operations.list* method supported by a *project* resource. @@ -5559,9 +4794,9 @@ impl<'a, C, A> ProjectRegionJobDeleteCall<'a, C, A> where C: BorrowMut"] description = "A complete library to interact with Deployment Manager (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/deploymentmanager2-cli" @@ -19,10 +19,10 @@ name = "deploymentmanager2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-deploymentmanager2/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-deploymentmanager2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-deploymentmanager2] diff --git a/gen/deploymentmanager2-cli/README.md b/gen/deploymentmanager2-cli/README.md index 409a52c360..45f91e50a8 100644 --- a/gen/deploymentmanager2-cli/README.md +++ b/gen/deploymentmanager2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Deployment Manager* API at revision *20160406*. 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 *0.3.6*. ```bash deploymentmanager2 [options] diff --git a/gen/deploymentmanager2-cli/mkdocs.yml b/gen/deploymentmanager2-cli/mkdocs.yml index 386378f87f..5809b75faf 100644 --- a/gen/deploymentmanager2-cli/mkdocs.yml +++ b/gen/deploymentmanager2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Deployment Manager v0.3.6+20160406 +site_name: Deployment Manager v0.3.6+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 179874326b..5d66f6322d 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+20160406") + .version("0.3.6+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/Cargo.toml b/gen/deploymentmanager2/Cargo.toml index 658db50868..48a942a518 100644 --- a/gen/deploymentmanager2/Cargo.toml +++ b/gen/deploymentmanager2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-deploymentmanager2" -version = "0.1.14+20160406" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/deploymentmanager2/README.md b/gen/deploymentmanager2/README.md index f5a298e037..98c28d316f 100644 --- a/gen/deploymentmanager2/README.md +++ b/gen/deploymentmanager2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-deploymentmanager2` library allows access to all features of the *Google Deployment Manager* service. -This documentation was generated from *Deployment Manager* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *deploymentmanager:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Deployment Manager* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *deploymentmanager:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Deployment Manager* *v2* API can be found at the [official documentation site](https://cloud.google.com/deployment-manager/). diff --git a/gen/deploymentmanager2/src/lib.rs b/gen/deploymentmanager2/src/lib.rs index e5a3e6cd70..347b4b6cf0 100644 --- a/gen/deploymentmanager2/src/lib.rs +++ b/gen/deploymentmanager2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Deployment Manager* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *deploymentmanager:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Deployment Manager* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *deploymentmanager:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Deployment Manager* *v2* API can be found at the //! [official documentation site](https://cloud.google.com/deployment-manager/). diff --git a/gen/deploymentmanager2/src/lib.rs.in b/gen/deploymentmanager2/src/lib.rs.in index 9c7b24c44d..fca54a9f18 100644 --- a/gen/deploymentmanager2/src/lib.rs.in +++ b/gen/deploymentmanager2/src/lib.rs.in @@ -235,7 +235,7 @@ pub struct ResourceType { /// [Output Only] Timestamp when the resource was created or acquired, in RFC3339 text format . #[serde(rename="insertTime")] pub insert_time: Option, - /// [Output Only] The type of the resource, for example compute.v1.instance, or replicaPools.v1beta2.instanceGroupManager. + /// [Output Only] The type of the resource, for example compute.v1.instance, or cloudfunctions.v1beta1.function. #[serde(rename="type")] pub type_: Option, /// [Output Only] Unique identifier for the resource; defined by the server. @@ -486,6 +486,8 @@ impl ResponseResult for OperationsListResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Type { + /// [Output Only] The Operation that most recently ran, or is currently running, on this type. + pub operation: Option, /// [Output Only] Timestamp when the type was created, in RFC3339 text format. #[serde(rename="insertTime")] pub insert_time: Option, @@ -807,7 +809,7 @@ pub struct Operation { /// [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. + /// [Output Only] The URL of the resource that the operation modifies. If creating a persistent disk snapshot, this points to the persistent disk that the snapshot was created from. #[serde(rename="targetLink")] pub target_link: Option, } @@ -1848,9 +1850,9 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: When filtering in the Beta API, you can also 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. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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) -> OperationListCall<'a, C, A> { @@ -2139,9 +2141,9 @@ impl<'a, C, A> ManifestListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: When filtering in the Beta API, you can also 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. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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) -> ManifestListCall<'a, C, A> { @@ -2677,9 +2679,9 @@ impl<'a, C, A> TypeListCall<'a, C, A> where C: BorrowMut, A: oaut /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: When filtering in the Beta API, you can also 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. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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) -> TypeListCall<'a, C, A> { @@ -3227,9 +3229,9 @@ impl<'a, C, A> ResourceListCall<'a, C, A> where C: BorrowMut, A: /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: When filtering in the Beta API, you can also 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. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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) -> ResourceListCall<'a, C, A> { @@ -4623,9 +4625,9 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut, A /// /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance. /// - /// Compute Engine Beta API Only: When filtering in the Beta API, you can also 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. + /// 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. /// - /// The Beta API also supports filtering on multiple expressions by providing 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. + /// 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) -> DeploymentListCall<'a, C, A> { diff --git a/gen/deploymentmanager2_beta2-cli/Cargo.toml b/gen/deploymentmanager2_beta2-cli/Cargo.toml index d677d284fb..50073d0fd2 100644 --- a/gen/deploymentmanager2_beta2-cli/Cargo.toml +++ b/gen/deploymentmanager2_beta2-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "deploymentmanager2-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-deploymentmanager2_beta2/ with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-deploymentmanager2_beta2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-deploymentmanager2_beta2] diff --git a/gen/deploymentmanager2_beta2/Cargo.toml b/gen/deploymentmanager2_beta2/Cargo.toml index 4bb4f8361d..aa2229659b 100644 --- a/gen/deploymentmanager2_beta2/Cargo.toml +++ b/gen/deploymentmanager2_beta2/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dfareporting2d1-cli/Cargo.toml b/gen/dfareporting2d1-cli/Cargo.toml index 807e9feff7..01e8b6e2b2 100644 --- a/gen/dfareporting2d1-cli/Cargo.toml +++ b/gen/dfareporting2d1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "dfareporting2d1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d1] diff --git a/gen/dfareporting2d1/Cargo.toml b/gen/dfareporting2d1/Cargo.toml index 7a57f7908e..98af553354 100644 --- a/gen/dfareporting2d1/Cargo.toml +++ b/gen/dfareporting2d1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dfareporting2d2-cli/Cargo.toml b/gen/dfareporting2d2-cli/Cargo.toml index 7ac7ce84d5..1d06d3046e 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+20160323" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "dfareporting2d2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d2] diff --git a/gen/dfareporting2d2-cli/README.md b/gen/dfareporting2d2-cli/README.md index 4dcb3eefd4..e8b736fada 100644 --- a/gen/dfareporting2d2-cli/README.md +++ b/gen/dfareporting2d2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # 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 *20160803*. The CLI is at version *0.3.6*. ```bash dfareporting2d2 [options] diff --git a/gen/dfareporting2d2-cli/mkdocs.yml b/gen/dfareporting2d2-cli/mkdocs.yml index 97248078e3..9faf582d4a 100644 --- a/gen/dfareporting2d2-cli/mkdocs.yml +++ b/gen/dfareporting2d2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160323 +site_name: dfareporting v0.3.6+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 ab2c61443b..643ef7fd66 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+20160323") + .version("0.3.6+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/dfareporting2d2/Cargo.toml b/gen/dfareporting2d2/Cargo.toml index 8a5f4e4f53..e17c6c3596 100644 --- a/gen/dfareporting2d2/Cargo.toml +++ b/gen/dfareporting2d2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d2" -version = "0.1.14+20160323" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dfareporting2d2/README.md b/gen/dfareporting2d2/README.md index 76562ce22c..80fbd58ae9 100644 --- a/gen/dfareporting2d2/README.md +++ b/gen/dfareporting2d2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dfareporting2d2` library allows access to all features of the *Google dfareporting* service. -This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *dfareporting* *v2d2* API can be found at the [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d2/src/lib.rs b/gen/dfareporting2d2/src/lib.rs index 12ef9919af..c3473ae8d9 100644 --- a/gen/dfareporting2d2/src/lib.rs +++ b/gen/dfareporting2d2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *dfareporting* *v2d2* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d2/src/lib.rs.in b/gen/dfareporting2d2/src/lib.rs.in index 14f28bef92..d45d0d118e 100644 --- a/gen/dfareporting2d2/src/lib.rs.in +++ b/gen/dfareporting2d2/src/lib.rs.in @@ -2626,7 +2626,7 @@ pub struct CreativeAsset { /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. #[serde(rename="collapsedSize")] pub collapsed_size: Option, - /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="flashVersion")] pub flash_version: Option, /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2646,7 +2646,7 @@ pub struct CreativeAsset { pub id: Option, /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_MULTI_FLOATING. pub alignment: Option, - /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. pub size: Option, /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="horizontallyLocked")] @@ -2670,7 +2670,7 @@ pub struct CreativeAsset { /// OTHER refers to assets from sources other than DCM, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. /// PARENT_VIDEO refers to videos uploaded by the user in DCM and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. /// TRANSCODED_VIDEO refers to videos transcoded by DCM from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. - /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR creatives. These cannot be added or removed within DCM. + /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within DCM. /// For VPAID_LINEAR creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR creative. pub role: Option, /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. @@ -2716,7 +2716,7 @@ pub struct CreativeAsset { /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="backupImageExit")] pub backup_image_exit: Option, - /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE and ENHANCED_BANNER. + /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="actionScript3")] pub action_script3: Option, /// Pushdown duration in seconds for an asset. Must be between 0 and 9.99. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2830,7 +2830,7 @@ impl ResponseResult for UserRolePermissionGroup {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickTag { - /// Advertiser event name associated with the click tag. This field is used by ENHANCED_BANNER, ENHANCED_IMAGE, and HTML5_BANNER creatives. + /// Advertiser event name associated with the click tag. This field is used by ENHANCED_IMAGE, and HTML5_BANNER creatives. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE #[serde(rename="eventName")] pub event_name: Option, /// Parameter name for the specified click tag. For ENHANCED_IMAGE creative assets, this field must match the value of the creative asset's creativeAssetId.name field. @@ -3464,7 +3464,7 @@ pub struct Creative { pub advertiser_id: Option, /// Whether the creative is active. Applicable to all creative types. pub active: Option, - /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="timerCustomEvents")] pub timer_custom_events: Option>, /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. @@ -3489,10 +3489,10 @@ pub struct Creative { /// Whether script access is allowed for this creative. This is a read-only and deprecated field which will automatically be set to true on update. Applicable to the following creative types: FLASH_INPAGE. #[serde(rename="allowScriptAccess")] pub allow_script_access: Option, - /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="requiredFlashVersion")] pub required_flash_version: Option, - /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="exitCustomEvents")] pub exit_custom_events: Option>, /// ID of current rendering version. This is a read-only field. Applicable to all creative types. @@ -3501,7 +3501,7 @@ pub struct Creative { /// Description of the video ad. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. #[serde(rename="videoDescription")] pub video_description: Option, - /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyBackupImageImpressionsUrl")] pub third_party_backup_image_impressions_url: Option, /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types. @@ -3520,7 +3520,7 @@ pub struct Creative { pub id_dimension_value: Option, /// Whether images are automatically advanced for enhanced image creatives. Applicable to the following creative types: ENHANCED_IMAGE. pub auto_advance_images: Option, - /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, and for ENHANCED_BANNER creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. pub size: Option, /// Type of this creative.This is a required field. Applicable to all creative types. #[serde(rename="type")] @@ -3528,7 +3528,7 @@ pub struct Creative { /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="totalFileSize")] pub total_file_size: Option, - /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyRichMediaImpressionsUrl")] pub third_party_rich_media_impressions_url: Option, /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -3537,7 +3537,7 @@ pub struct Creative { /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT #[serde(rename="creativeAssets")] pub creative_assets: Option>, - /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: ENHANCED_BANNER and HTML5_BANNER. + /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="backupImageFeatures")] pub backup_image_features: Option>, /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. @@ -3546,16 +3546,16 @@ pub struct Creative { /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, REDIRECT, and INSTREAM_VIDEO_REDIRECT #[serde(rename="redirectUrl")] pub redirect_url: Option, - /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER. + /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="clickTags")] pub click_tags: Option>, - /// Target window for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageTargetWindow")] pub backup_image_target_window: Option, /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="requiredFlashPluginVersion")] pub required_flash_plugin_version: Option, - /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: ENHANCED_BANNER. + /// Reporting label used for HTML5 banner backup image. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageReportingLabel")] pub backup_image_reporting_label: Option, /// Compatibilities associated with this creative. This is a read-only field. WEB and WEB_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. @@ -3583,7 +3583,7 @@ pub struct Creative { /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="adTagKeys")] pub ad_tag_keys: Option>, - /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative types: ENHANCED_BANNER and FLASH_INPAGE. + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="convertFlashToHtml5")] pub convert_flash_to_html5: Option, /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. @@ -3592,7 +3592,7 @@ pub struct Creative { /// Creative last modification information. This is a read-only field. Applicable to all creative types. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, - /// Click-through URL for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Click-through URL for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageClickThroughUrl")] pub backup_image_click_through_url: Option, /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -4084,7 +4084,7 @@ impl Part for ReportPathToConversionCriteriaReportProperties {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TechnologyTargeting { - /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used.The other fields are populated automatically when the ad is inserted or updated. + /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated. pub browsers: Option>, /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. #[serde(rename="operatingSystems")] @@ -4092,7 +4092,7 @@ pub struct TechnologyTargeting { /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. #[serde(rename="mobileCarriers")] pub mobile_carriers: Option>, - /// Connection types that this ad targets. For each connection type only id is required.The other fields are populated automatically when the ad is inserted or updated. + /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated. #[serde(rename="connectionTypes")] pub connection_types: Option>, /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. @@ -4158,27 +4158,30 @@ pub struct CreativeAssetMetadata { /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. /// /// Possible values are: - /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "ADMOB_REFERENCED" + /// - "ASSET_FORMAT_UNSUPPORTED_DCM" + /// - "ASSET_INVALID" + /// - "CLICK_TAG_HARD_CODED" + /// - "CLICK_TAG_INVALID" + /// - "CLICK_TAG_IN_GWD" /// - "CLICK_TAG_MISSING" /// - "CLICK_TAG_MORE_THAN_ONE" - /// - "CLICK_TAG_INVALID" - /// - "ORPHANED_ASSET" - /// - "PRIMARY_HTML_MISSING" + /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "COMPONENT_UNSUPPORTED_DCM" + /// - "ENABLER_UNSUPPORTED_METHOD_DCM" /// - "EXTERNAL_FILE_REFERENCED" - /// - "MRAID_REFERENCED" - /// - "ADMOB_REFERENCED" + /// - "FILE_DETAIL_EMPTY" /// - "FILE_TYPE_INVALID" - /// - "ZIP_INVALID" + /// - "GWD_PROPERTIES_INVALID" + /// - "HTML5_FEATURE_UNSUPPORTED" /// - "LINKED_FILE_NOT_FOUND" /// - "MAX_FLASH_VERSION_11" + /// - "MRAID_REFERENCED" /// - "NOT_SSL_COMPLIANT" - /// - "FILE_DETAIL_EMPTY" - /// - "ASSET_INVALID" - /// - "GWD_PROPERTIES_INVALID" - /// - "ENABLER_UNSUPPORTED_METHOD_DCM" - /// - "ASSET_FORMAT_UNSUPPORTED_DCM" - /// - "COMPONENT_UNSUPPORTED_DCM" - /// - "HTML5_FEATURE_UNSUPPORTED' " + /// - "ORPHANED_ASSET" + /// - "PRIMARY_HTML_MISSING" + /// - "SVG_INVALID" + /// - "ZIP_INVALID" #[serde(rename="warnedValidationRules")] pub warned_validation_rules: Option>, /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. @@ -6102,7 +6105,7 @@ pub struct Ad { /// Advertiser ID of this ad. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, - /// Geographical targeting information for this ad.Applicable when type is AD_SERVING_STANDARD_AD. + /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="geoTargeting")] pub geo_targeting: Option, /// Comments for this ad. @@ -6122,7 +6125,7 @@ pub struct Ad { pub size: Option, /// Whether this ad is archived. pub archived: Option, - /// Technology platform targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="technologyTargeting")] pub technology_targeting: Option, /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment. @@ -6134,7 +6137,7 @@ pub struct Ad { /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments. #[serde(rename="creativeGroupAssignments")] pub creative_group_assignments: Option>, - /// Applicable when type is AD_SERVING_STANDARD_AD. Remarketing list targeting expression for this ad. + /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="remarketingListExpression")] pub remarketing_list_expression: Option, /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. @@ -6152,7 +6155,7 @@ pub struct Ad { /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="audienceSegmentId")] pub audience_segment_id: Option, - /// Key-value targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="keyValueTargetingExpression")] pub key_value_targeting_expression: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. @@ -6161,7 +6164,7 @@ pub struct Ad { /// Default click-through event tag properties for this ad. #[serde(rename="defaultClickThroughEventTagProperties")] pub default_click_through_event_tag_properties: Option, - /// Information about the creation of this ad.This is a read-only field. + /// Information about the creation of this ad. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion. @@ -6178,7 +6181,7 @@ pub struct Ad { pub subaccount_id: Option, /// Name of this ad. This is a required field and must be less than 256 characters long. pub name: Option, - /// Time and day targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="dayPartTargeting")] pub day_part_targeting: Option, /// Information about the most recent modification of this ad. This is a read-only field. diff --git a/gen/dfareporting2d3-cli/Cargo.toml b/gen/dfareporting2d3-cli/Cargo.toml index 1d240d6d5e..1edd44503d 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+20160323" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "dfareporting2d3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d3] diff --git a/gen/dfareporting2d3-cli/README.md b/gen/dfareporting2d3-cli/README.md index 772fb3980b..4dc31e8448 100644 --- a/gen/dfareporting2d3-cli/README.md +++ b/gen/dfareporting2d3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # 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 *20160803*. The CLI is at version *0.3.6*. ```bash dfareporting2d3 [options] diff --git a/gen/dfareporting2d3-cli/mkdocs.yml b/gen/dfareporting2d3-cli/mkdocs.yml index 771ea9d08f..3fd585ac97 100644 --- a/gen/dfareporting2d3-cli/mkdocs.yml +++ b/gen/dfareporting2d3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160323 +site_name: dfareporting v0.3.6+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 5971451b0e..a1b949ddac 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+20160323") + .version("0.3.6+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/dfareporting2d3/Cargo.toml b/gen/dfareporting2d3/Cargo.toml index eac64c3129..9beaeaa84e 100644 --- a/gen/dfareporting2d3/Cargo.toml +++ b/gen/dfareporting2d3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d3" -version = "0.1.14+20160323" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dfareporting2d3/README.md b/gen/dfareporting2d3/README.md index eb5d4258fa..67597b53c3 100644 --- a/gen/dfareporting2d3/README.md +++ b/gen/dfareporting2d3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dfareporting2d3` library allows access to all features of the *Google dfareporting* service. -This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *dfareporting* *v2d3* API can be found at the [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d3/src/lib.rs b/gen/dfareporting2d3/src/lib.rs index 7b3afc410c..e27132e918 100644 --- a/gen/dfareporting2d3/src/lib.rs +++ b/gen/dfareporting2d3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *dfareporting* *v2d3* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d3/src/lib.rs.in b/gen/dfareporting2d3/src/lib.rs.in index 253404dac4..7f550cd9f4 100644 --- a/gen/dfareporting2d3/src/lib.rs.in +++ b/gen/dfareporting2d3/src/lib.rs.in @@ -2628,7 +2628,7 @@ pub struct CreativeAsset { /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. #[serde(rename="collapsedSize")] pub collapsed_size: Option, - /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="flashVersion")] pub flash_version: Option, /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2648,7 +2648,7 @@ pub struct CreativeAsset { pub id: Option, /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_MULTI_FLOATING. pub alignment: Option, - /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. pub size: Option, /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="horizontallyLocked")] @@ -2672,7 +2672,7 @@ pub struct CreativeAsset { /// OTHER refers to assets from sources other than DCM, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. /// PARENT_VIDEO refers to videos uploaded by the user in DCM and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. /// TRANSCODED_VIDEO refers to videos transcoded by DCM from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. - /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR creatives. These cannot be added or removed within DCM. + /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within DCM. /// For VPAID_LINEAR creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR creative. pub role: Option, /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. @@ -2718,7 +2718,7 @@ pub struct CreativeAsset { /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="backupImageExit")] pub backup_image_exit: Option, - /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE and ENHANCED_BANNER. + /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="actionScript3")] pub action_script3: Option, /// Pushdown duration in seconds for an asset. Must be between 0 and 9.99. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2832,7 +2832,7 @@ impl ResponseResult for UserRolePermissionGroup {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickTag { - /// Advertiser event name associated with the click tag. This field is used by ENHANCED_BANNER, ENHANCED_IMAGE, and HTML5_BANNER creatives. + /// Advertiser event name associated with the click tag. This field is used by ENHANCED_IMAGE, and HTML5_BANNER creatives. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE #[serde(rename="eventName")] pub event_name: Option, /// Parameter name for the specified click tag. For ENHANCED_IMAGE creative assets, this field must match the value of the creative asset's creativeAssetId.name field. @@ -3469,7 +3469,7 @@ pub struct Creative { pub advertiser_id: Option, /// Whether the creative is active. Applicable to all creative types. pub active: Option, - /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="timerCustomEvents")] pub timer_custom_events: Option>, /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. @@ -3494,10 +3494,10 @@ pub struct Creative { /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types. #[serde(rename="authoringSource")] pub authoring_source: Option, - /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="requiredFlashVersion")] pub required_flash_version: Option, - /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="exitCustomEvents")] pub exit_custom_events: Option>, /// ID of current rendering version. This is a read-only field. Applicable to all creative types. @@ -3506,7 +3506,7 @@ pub struct Creative { /// Description of the video ad. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. #[serde(rename="videoDescription")] pub video_description: Option, - /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyBackupImageImpressionsUrl")] pub third_party_backup_image_impressions_url: Option, /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types. @@ -3525,7 +3525,7 @@ pub struct Creative { pub id_dimension_value: Option, /// Whether images are automatically advanced for enhanced image creatives. Applicable to the following creative types: ENHANCED_IMAGE. pub auto_advance_images: Option, - /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, and for ENHANCED_BANNER creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. pub size: Option, /// Type of this creative.This is a required field. Applicable to all creative types. #[serde(rename="type")] @@ -3533,7 +3533,7 @@ pub struct Creative { /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="totalFileSize")] pub total_file_size: Option, - /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyRichMediaImpressionsUrl")] pub third_party_rich_media_impressions_url: Option, /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -3542,7 +3542,7 @@ pub struct Creative { /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT #[serde(rename="creativeAssets")] pub creative_assets: Option>, - /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: ENHANCED_BANNER and HTML5_BANNER. + /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="backupImageFeatures")] pub backup_image_features: Option>, /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. @@ -3551,16 +3551,16 @@ pub struct Creative { /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, REDIRECT, and INSTREAM_VIDEO_REDIRECT #[serde(rename="redirectUrl")] pub redirect_url: Option, - /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER. + /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="clickTags")] pub click_tags: Option>, - /// Target window for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageTargetWindow")] pub backup_image_target_window: Option, /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="requiredFlashPluginVersion")] pub required_flash_plugin_version: Option, - /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: ENHANCED_BANNER. + /// Reporting label used for HTML5 banner backup image. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageReportingLabel")] pub backup_image_reporting_label: Option, /// Compatibilities associated with this creative. This is a read-only field. WEB and WEB_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. @@ -3588,7 +3588,7 @@ pub struct Creative { /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="adTagKeys")] pub ad_tag_keys: Option>, - /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative types: ENHANCED_BANNER and FLASH_INPAGE. + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="convertFlashToHtml5")] pub convert_flash_to_html5: Option, /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. @@ -3597,7 +3597,7 @@ pub struct Creative { /// Creative last modification information. This is a read-only field. Applicable to all creative types. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, - /// Click-through URL for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Click-through URL for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageClickThroughUrl")] pub backup_image_click_through_url: Option, /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -4092,7 +4092,7 @@ impl Part for ReportPathToConversionCriteriaReportProperties {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TechnologyTargeting { - /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used.The other fields are populated automatically when the ad is inserted or updated. + /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated. pub browsers: Option>, /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. #[serde(rename="operatingSystems")] @@ -4100,7 +4100,7 @@ pub struct TechnologyTargeting { /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. #[serde(rename="mobileCarriers")] pub mobile_carriers: Option>, - /// Connection types that this ad targets. For each connection type only id is required.The other fields are populated automatically when the ad is inserted or updated. + /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated. #[serde(rename="connectionTypes")] pub connection_types: Option>, /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. @@ -4166,27 +4166,30 @@ pub struct CreativeAssetMetadata { /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. /// /// Possible values are: - /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "ADMOB_REFERENCED" + /// - "ASSET_FORMAT_UNSUPPORTED_DCM" + /// - "ASSET_INVALID" + /// - "CLICK_TAG_HARD_CODED" + /// - "CLICK_TAG_INVALID" + /// - "CLICK_TAG_IN_GWD" /// - "CLICK_TAG_MISSING" /// - "CLICK_TAG_MORE_THAN_ONE" - /// - "CLICK_TAG_INVALID" - /// - "ORPHANED_ASSET" - /// - "PRIMARY_HTML_MISSING" + /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "COMPONENT_UNSUPPORTED_DCM" + /// - "ENABLER_UNSUPPORTED_METHOD_DCM" /// - "EXTERNAL_FILE_REFERENCED" - /// - "MRAID_REFERENCED" - /// - "ADMOB_REFERENCED" + /// - "FILE_DETAIL_EMPTY" /// - "FILE_TYPE_INVALID" - /// - "ZIP_INVALID" + /// - "GWD_PROPERTIES_INVALID" + /// - "HTML5_FEATURE_UNSUPPORTED" /// - "LINKED_FILE_NOT_FOUND" /// - "MAX_FLASH_VERSION_11" + /// - "MRAID_REFERENCED" /// - "NOT_SSL_COMPLIANT" - /// - "FILE_DETAIL_EMPTY" - /// - "ASSET_INVALID" - /// - "GWD_PROPERTIES_INVALID" - /// - "ENABLER_UNSUPPORTED_METHOD_DCM" - /// - "ASSET_FORMAT_UNSUPPORTED_DCM" - /// - "COMPONENT_UNSUPPORTED_DCM" - /// - "HTML5_FEATURE_UNSUPPORTED' " + /// - "ORPHANED_ASSET" + /// - "PRIMARY_HTML_MISSING" + /// - "SVG_INVALID" + /// - "ZIP_INVALID" #[serde(rename="warnedValidationRules")] pub warned_validation_rules: Option>, /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. @@ -6110,7 +6113,7 @@ pub struct Ad { /// Advertiser ID of this ad. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, - /// Geographical targeting information for this ad.Applicable when type is AD_SERVING_STANDARD_AD. + /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="geoTargeting")] pub geo_targeting: Option, /// Comments for this ad. @@ -6130,7 +6133,7 @@ pub struct Ad { pub size: Option, /// Whether this ad is archived. pub archived: Option, - /// Technology platform targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="technologyTargeting")] pub technology_targeting: Option, /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment. @@ -6142,7 +6145,7 @@ pub struct Ad { /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments. #[serde(rename="creativeGroupAssignments")] pub creative_group_assignments: Option>, - /// Applicable when type is AD_SERVING_STANDARD_AD. Remarketing list targeting expression for this ad. + /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="remarketingListExpression")] pub remarketing_list_expression: Option, /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. @@ -6160,7 +6163,7 @@ pub struct Ad { /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="audienceSegmentId")] pub audience_segment_id: Option, - /// Key-value targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="keyValueTargetingExpression")] pub key_value_targeting_expression: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. @@ -6169,7 +6172,7 @@ pub struct Ad { /// Default click-through event tag properties for this ad. #[serde(rename="defaultClickThroughEventTagProperties")] pub default_click_through_event_tag_properties: Option, - /// Information about the creation of this ad.This is a read-only field. + /// Information about the creation of this ad. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion. @@ -6186,7 +6189,7 @@ pub struct Ad { pub subaccount_id: Option, /// Name of this ad. This is a required field and must be less than 256 characters long. pub name: Option, - /// Time and day targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="dayPartTargeting")] pub day_part_targeting: Option, /// Information about the most recent modification of this ad. This is a read-only field. diff --git a/gen/dfareporting2d4-cli/Cargo.toml b/gen/dfareporting2d4-cli/Cargo.toml index f9da4b65ed..b86f79c6e2 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+20160323" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "dfareporting2d4" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d4/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d4/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dfareporting2d4] diff --git a/gen/dfareporting2d4-cli/README.md b/gen/dfareporting2d4-cli/README.md index 46fc91f4f8..15364b53fa 100644 --- a/gen/dfareporting2d4-cli/README.md +++ b/gen/dfareporting2d4-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # 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 *20160803*. The CLI is at version *0.3.6*. ```bash dfareporting2d4 [options] diff --git a/gen/dfareporting2d4-cli/mkdocs.yml b/gen/dfareporting2d4-cli/mkdocs.yml index 7de4c6bdf8..48142b96c0 100644 --- a/gen/dfareporting2d4-cli/mkdocs.yml +++ b/gen/dfareporting2d4-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dfareporting v0.3.6+20160323 +site_name: dfareporting v0.3.6+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 9ed68b4b0b..8af365a627 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+20160323") + .version("0.3.6+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/dfareporting2d4/Cargo.toml b/gen/dfareporting2d4/Cargo.toml index 8364e70cbf..ded89ceb45 100644 --- a/gen/dfareporting2d4/Cargo.toml +++ b/gen/dfareporting2d4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dfareporting2d4" -version = "0.1.14+20160323" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dfareporting2d4/README.md b/gen/dfareporting2d4/README.md index 9e383f8a0a..dc0585919e 100644 --- a/gen/dfareporting2d4/README.md +++ b/gen/dfareporting2d4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dfareporting2d4` library allows access to all features of the *Google dfareporting* service. -This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *dfareporting* *v2d4* API can be found at the [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d4/src/lib.rs b/gen/dfareporting2d4/src/lib.rs index 6a51cc97fe..a1561dfa9c 100644 --- a/gen/dfareporting2d4/src/lib.rs +++ b/gen/dfareporting2d4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dfareporting* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *dfareporting:v2.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *dfareporting* *v2d4* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). diff --git a/gen/dfareporting2d4/src/lib.rs.in b/gen/dfareporting2d4/src/lib.rs.in index 4a4f08e622..c3ae087ade 100644 --- a/gen/dfareporting2d4/src/lib.rs.in +++ b/gen/dfareporting2d4/src/lib.rs.in @@ -1774,7 +1774,7 @@ pub struct Placement { /// Dimension value for the ID of the site. This is a read-only, auto-generated field. #[serde(rename="siteIdDimensionValue")] pub site_id_dimension_value: Option, - /// Placement compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering on desktop, mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are no longer allowed for new placement insertions. Instead, use DISPLAY or DISPLAY_INTERSTITIAL. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. This field is required on insertion. + /// Placement compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering on desktop, on mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are no longer allowed for new placement insertions. Instead, use DISPLAY or DISPLAY_INTERSTITIAL. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. This field is required on insertion. pub compatibility: Option, /// ID of the placement strategy assigned to this placement. #[serde(rename="placementStrategyId")] @@ -2631,7 +2631,7 @@ pub struct CreativeAsset { /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. #[serde(rename="collapsedSize")] pub collapsed_size: Option, - /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="flashVersion")] pub flash_version: Option, /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2651,7 +2651,7 @@ pub struct CreativeAsset { pub id: Option, /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_MULTI_FLOATING. pub alignment: Option, - /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. pub size: Option, /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="horizontallyLocked")] @@ -2675,7 +2675,7 @@ pub struct CreativeAsset { /// OTHER refers to assets from sources other than DCM, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. /// PARENT_VIDEO refers to videos uploaded by the user in DCM and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. /// TRANSCODED_VIDEO refers to videos transcoded by DCM from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR creatives. - /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR creatives. These cannot be added or removed within DCM. + /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within DCM. /// For VPAID_LINEAR creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR creative. pub role: Option, /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. @@ -2721,7 +2721,7 @@ pub struct CreativeAsset { /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="backupImageExit")] pub backup_image_exit: Option, - /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE and ENHANCED_BANNER. + /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="actionScript3")] pub action_script3: Option, /// Pushdown duration in seconds for an asset. Must be between 0 and 9.99. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. @@ -2835,7 +2835,7 @@ impl ResponseResult for UserRolePermissionGroup {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickTag { - /// Advertiser event name associated with the click tag. This field is used by ENHANCED_BANNER, ENHANCED_IMAGE, and HTML5_BANNER creatives. + /// Advertiser event name associated with the click tag. This field is used by ENHANCED_IMAGE, and HTML5_BANNER creatives. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE #[serde(rename="eventName")] pub event_name: Option, /// Parameter name for the specified click tag. For ENHANCED_IMAGE creative assets, this field must match the value of the creative asset's creativeAssetId.name field. @@ -3472,7 +3472,7 @@ pub struct Creative { pub advertiser_id: Option, /// Whether the creative is active. Applicable to all creative types. pub active: Option, - /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of timer events configured for the creative. For ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="timerCustomEvents")] pub timer_custom_events: Option>, /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. @@ -3497,10 +3497,10 @@ pub struct Creative { /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types. #[serde(rename="authoringSource")] pub authoring_source: Option, - /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, ENHANCED_BANNER, all RICH_MEDIA, and all VPAID. + /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="requiredFlashVersion")] pub required_flash_version: Option, - /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. + /// List of exit events configured for the creative. For ENHANCED_BANNER and ENHANCED_IMAGE creatives, these are read-only and auto-generated from clickTags, For ENHANCED_BANNER, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: ENHANCED_IMAGE, all RICH_MEDIA, and all VPAID. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="exitCustomEvents")] pub exit_custom_events: Option>, /// ID of current rendering version. This is a read-only field. Applicable to all creative types. @@ -3509,7 +3509,7 @@ pub struct Creative { /// Description of the video ad. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. #[serde(rename="videoDescription")] pub video_description: Option, - /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyBackupImageImpressionsUrl")] pub third_party_backup_image_impressions_url: Option, /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types. @@ -3528,7 +3528,7 @@ pub struct Creative { pub id_dimension_value: Option, /// Whether images are automatically advanced for enhanced image creatives. Applicable to the following creative types: ENHANCED_IMAGE. pub auto_advance_images: Option, - /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE and FLASH_INPAGE creatives, and for ENHANCED_BANNER creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. pub size: Option, /// Type of this creative.This is a required field. Applicable to all creative types. #[serde(rename="type")] @@ -3536,7 +3536,7 @@ pub struct Creative { /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="totalFileSize")] pub total_file_size: Option, - /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA + /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyRichMediaImpressionsUrl")] pub third_party_rich_media_impressions_url: Option, /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -3545,7 +3545,7 @@ pub struct Creative { /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT #[serde(rename="creativeAssets")] pub creative_assets: Option>, - /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: ENHANCED_BANNER and HTML5_BANNER. + /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset is not HTML_IMAGE. #[serde(rename="backupImageFeatures")] pub backup_image_features: Option>, /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. @@ -3554,19 +3554,19 @@ pub struct Creative { /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, REDIRECT, and INSTREAM_VIDEO_REDIRECT #[serde(rename="redirectUrl")] pub redirect_url: Option, - /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_BANNER, ENHANCED_IMAGE, FLASH_INPAGE, HTML5_BANNER. + /// Click tags of the creative. For ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For ENHANCED_IMAGE creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: ENHANCED_IMAGE, FLASH_INPAGE HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="clickTags")] pub click_tags: Option>, - /// Target window for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageTargetWindow")] pub backup_image_target_window: Option, /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="requiredFlashPluginVersion")] pub required_flash_plugin_version: Option, - /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: ENHANCED_BANNER. + /// Reporting label used for HTML5 banner backup image. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageReportingLabel")] pub backup_image_reporting_label: Option, - /// Compatibilities associated with this creative. This is a read-only field. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. Only pre-existing creatives may have these compatibilities since new creatives will either be assigned DISPLAY or DISPLAY_INTERSTITIAL instead. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. + /// Compatibilities associated with this creative. This is a read-only field. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. Only pre-existing creatives may have these compatibilities since new creatives will either be assigned DISPLAY or DISPLAY_INTERSTITIAL instead. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. /// /// Acceptable values are: /// - "APP" @@ -3591,7 +3591,7 @@ pub struct Creative { /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="adTagKeys")] pub ad_tag_keys: Option>, - /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative types: ENHANCED_BANNER and FLASH_INPAGE. + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="convertFlashToHtml5")] pub convert_flash_to_html5: Option, /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. @@ -3600,7 +3600,7 @@ pub struct Creative { /// Creative last modification information. This is a read-only field. Applicable to all creative types. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, - /// Click-through URL for backup image. Applicable to the following creative types: ENHANCED_BANNER, FLASH_INPAGE, and HTML5_BANNER. + /// Click-through URL for backup image. Applicable to the following creative types: FLASH_INPAGE, and HTML5_BANNER. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageClickThroughUrl")] pub backup_image_click_through_url: Option, /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. @@ -4095,7 +4095,7 @@ impl Part for ReportPathToConversionCriteriaReportProperties {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TechnologyTargeting { - /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used.The other fields are populated automatically when the ad is inserted or updated. + /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated. pub browsers: Option>, /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. #[serde(rename="operatingSystems")] @@ -4103,7 +4103,7 @@ pub struct TechnologyTargeting { /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. #[serde(rename="mobileCarriers")] pub mobile_carriers: Option>, - /// Connection types that this ad targets. For each connection type only id is required.The other fields are populated automatically when the ad is inserted or updated. + /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated. #[serde(rename="connectionTypes")] pub connection_types: Option>, /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. @@ -4169,27 +4169,30 @@ pub struct CreativeAssetMetadata { /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. /// /// Possible values are: - /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "ADMOB_REFERENCED" + /// - "ASSET_FORMAT_UNSUPPORTED_DCM" + /// - "ASSET_INVALID" + /// - "CLICK_TAG_HARD_CODED" + /// - "CLICK_TAG_INVALID" + /// - "CLICK_TAG_IN_GWD" /// - "CLICK_TAG_MISSING" /// - "CLICK_TAG_MORE_THAN_ONE" - /// - "CLICK_TAG_INVALID" - /// - "ORPHANED_ASSET" - /// - "PRIMARY_HTML_MISSING" + /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "COMPONENT_UNSUPPORTED_DCM" + /// - "ENABLER_UNSUPPORTED_METHOD_DCM" /// - "EXTERNAL_FILE_REFERENCED" - /// - "MRAID_REFERENCED" - /// - "ADMOB_REFERENCED" + /// - "FILE_DETAIL_EMPTY" /// - "FILE_TYPE_INVALID" - /// - "ZIP_INVALID" + /// - "GWD_PROPERTIES_INVALID" + /// - "HTML5_FEATURE_UNSUPPORTED" /// - "LINKED_FILE_NOT_FOUND" /// - "MAX_FLASH_VERSION_11" + /// - "MRAID_REFERENCED" /// - "NOT_SSL_COMPLIANT" - /// - "FILE_DETAIL_EMPTY" - /// - "ASSET_INVALID" - /// - "GWD_PROPERTIES_INVALID" - /// - "ENABLER_UNSUPPORTED_METHOD_DCM" - /// - "ASSET_FORMAT_UNSUPPORTED_DCM" - /// - "COMPONENT_UNSUPPORTED_DCM" - /// - "HTML5_FEATURE_UNSUPPORTED' " + /// - "ORPHANED_ASSET" + /// - "PRIMARY_HTML_MISSING" + /// - "SVG_INVALID" + /// - "ZIP_INVALID" #[serde(rename="warnedValidationRules")] pub warned_validation_rules: Option>, /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. @@ -6113,7 +6116,7 @@ pub struct Ad { /// Advertiser ID of this ad. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, - /// Geographical targeting information for this ad.Applicable when type is AD_SERVING_STANDARD_AD. + /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="geoTargeting")] pub geo_targeting: Option, /// Comments for this ad. @@ -6133,7 +6136,7 @@ pub struct Ad { pub size: Option, /// Whether this ad is archived. pub archived: Option, - /// Technology platform targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="technologyTargeting")] pub technology_targeting: Option, /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment. @@ -6145,7 +6148,7 @@ pub struct Ad { /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments. #[serde(rename="creativeGroupAssignments")] pub creative_group_assignments: Option>, - /// Applicable when type is AD_SERVING_STANDARD_AD. Remarketing list targeting expression for this ad. + /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="remarketingListExpression")] pub remarketing_list_expression: Option, /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. @@ -6163,7 +6166,7 @@ pub struct Ad { /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="audienceSegmentId")] pub audience_segment_id: Option, - /// Key-value targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="keyValueTargetingExpression")] pub key_value_targeting_expression: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. @@ -6172,7 +6175,7 @@ pub struct Ad { /// Default click-through event tag properties for this ad. #[serde(rename="defaultClickThroughEventTagProperties")] pub default_click_through_event_tag_properties: Option, - /// Information about the creation of this ad.This is a read-only field. + /// Information about the creation of this ad. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion. @@ -6180,7 +6183,7 @@ pub struct Ad { pub start_time: Option, /// Whether this ad is active. pub active: Option, - /// Compatibility of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to either rendering on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are only used for existing default ads. New mobile placements must be assigned DISPLAY or DISPLAY_INTERSTITIAL and default ads created for those placements will be limited to those compatibility types. IN_STREAM_VIDEO refers to rendering in-stream video ads developed with the VAST standard. + /// Compatibility of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to either rendering on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are only used for existing default ads. New mobile placements must be assigned DISPLAY or DISPLAY_INTERSTITIAL and default ads created for those placements will be limited to those compatibility types. IN_STREAM_VIDEO refers to rendering in-stream video ads developed with the VAST standard. pub compatibility: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ad". pub kind: Option, @@ -6189,7 +6192,7 @@ pub struct Ad { pub subaccount_id: Option, /// Name of this ad. This is a required field and must be less than 256 characters long. pub name: Option, - /// Time and day targeting information for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="dayPartTargeting")] pub day_part_targeting: Option, /// Information about the most recent modification of this ad. This is a read-only field. diff --git a/gen/dfareporting2d5-cli/Cargo.toml b/gen/dfareporting2d5-cli/Cargo.toml new file mode 100644 index 0000000000..67c1c10171 --- /dev/null +++ b/gen/dfareporting2d5-cli/Cargo.toml @@ -0,0 +1,42 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-dfareporting2d5-cli" +version = "0.3.6+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" +homepage = "https://developers.google.com/doubleclick-advertisers/reporting/" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli" +license = "MIT" +keywords = ["dfareporting", "google", "cli"] + +[[bin]] +name = "dfareporting2d5" + +[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.4" +yup-hyper-mock = "^1.0" +clap = "^2.0" + +[features] +default = ["with-serde-codegen"] +nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d5/nightly"] +with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d5/with-serde-codegen"] + +[build-dependencies] +serde_codegen = { version = "^ 0.8", optional = true } + + +[dependencies.google-dfareporting2d5] +path = "../dfareporting2d5" +optional = true +default-features = false diff --git a/gen/dfareporting2d5-cli/LICENSE.md b/gen/dfareporting2d5-cli/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/dfareporting2d5-cli/LICENSE.md @@ -0,0 +1,30 @@ + +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/dfareporting2d5-cli/README.md b/gen/dfareporting2d5-cli/README.md new file mode 100644 index 0000000000..e21b78d1c4 --- /dev/null +++ b/gen/dfareporting2d5-cli/README.md @@ -0,0 +1,364 @@ + +The `dfareporting2d5` command-line interface *(CLI)* allows to use most features of the *Google dfareporting* 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 *dfareporting* API can be found at the +[official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). + +# 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/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) + +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*. + +```bash +dfareporting2d5 [options] + account-active-ad-summaries + get [-p ]... [-o ] + account-permission-groups + get [-p ]... [-o ] + list [-p ]... [-o ] + account-permissions + get [-p ]... [-o ] + list [-p ]... [-o ] + account-user-profiles + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + accounts + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + ads + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + advertiser-groups + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + advertisers + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + browsers + list [-p ]... [-o ] + campaign-creative-associations + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + campaigns + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + change-logs + get [-p ]... [-o ] + list [-p ]... [-o ] + cities + list [-p ]... [-o ] + connection-types + get [-p ]... [-o ] + list [-p ]... [-o ] + content-categories + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + conversions + batchinsert (-r )... [-p ]... [-o ] + countries + get [-p ]... [-o ] + list [-p ]... [-o ] + creative-assets + insert (-r )... (-u (simple|resumable) -f [-m ]) [-p ]... [-o ] + creative-field-values + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creative-fields + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creative-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creatives + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + dimension-values + query (-r )... [-p ]... [-o ] + directory-site-contacts + get [-p ]... [-o ] + list [-p ]... [-o ] + directory-sites + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + dynamic-targeting-keys + delete [-p ]... + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + event-tags + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + files + get [-p ]... [-o ] + list [-p ]... [-o ] + floodlight-activities + delete [-p ]... + generatetag [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + floodlight-activity-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + floodlight-configurations + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + inventory-items + get [-p ]... [-o ] + list [-p ]... [-o ] + landing-pages + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + metros + list [-p ]... [-o ] + mobile-carriers + get [-p ]... [-o ] + list [-p ]... [-o ] + operating-system-versions + get [-p ]... [-o ] + list [-p ]... [-o ] + operating-systems + get [-p ]... [-o ] + list [-p ]... [-o ] + order-documents + get [-p ]... [-o ] + list [-p ]... [-o ] + orders + get [-p ]... [-o ] + list [-p ]... [-o ] + placement-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + placement-strategies + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + placements + generatetags [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + platform-types + get [-p ]... [-o ] + list [-p ]... [-o ] + postal-codes + get [-p ]... [-o ] + list [-p ]... [-o ] + projects + get [-p ]... [-o ] + list [-p ]... [-o ] + regions + list [-p ]... [-o ] + remarketing-list-shares + get [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + remarketing-lists + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + reports + compatible-fields-query (-r )... [-p ]... [-o ] + delete [-p ]... + files-get [-p ]... [-o ] + files-list [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + run [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + sites + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + sizes + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + subaccounts + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + targetable-remarketing-lists + get [-p ]... [-o ] + list [-p ]... [-o ] + user-profiles + get [-p ]... [-o ] + list [-p ]... [-o ] + user-role-permission-groups + get [-p ]... [-o ] + list [-p ]... [-o ] + user-role-permissions + get [-p ]... [-o ] + list [-p ]... [-o ] + user-roles + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + dfareporting2d5 --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 `dfareporting2d5-`. 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/dfareporting2d5-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/dfareporting2d5-secret.json`, assuming that the required *dfareporting* 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. `dfareporting2d5 --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/dfareporting2d5-cli/mkdocs.yml b/gen/dfareporting2d5-cli/mkdocs.yml new file mode 100644 index 0000000000..fe308756e0 --- /dev/null +++ b/gen/dfareporting2d5-cli/mkdocs.yml @@ -0,0 +1,212 @@ +site_name: dfareporting v0.3.6+20160803 +site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d5-cli +site_description: Write integrating applications with bcore + +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d5-cli + +docs_dir: docs +site_dir: build_html + +pages: +- ['index.md', 'Home'] +- ['account-active-ad-summaries_get.md', 'Account Active Ad Summaries', 'Get'] +- ['account-permission-groups_get.md', 'Account Permission Groups', 'Get'] +- ['account-permission-groups_list.md', 'Account Permission Groups', 'List'] +- ['account-permissions_get.md', 'Account Permissions', 'Get'] +- ['account-permissions_list.md', 'Account Permissions', 'List'] +- ['account-user-profiles_get.md', 'Account User Profiles', 'Get'] +- ['account-user-profiles_insert.md', 'Account User Profiles', 'Insert'] +- ['account-user-profiles_list.md', 'Account User Profiles', 'List'] +- ['account-user-profiles_patch.md', 'Account User Profiles', 'Patch'] +- ['account-user-profiles_update.md', 'Account User Profiles', 'Update'] +- ['accounts_get.md', 'Accounts', 'Get'] +- ['accounts_list.md', 'Accounts', 'List'] +- ['accounts_patch.md', 'Accounts', 'Patch'] +- ['accounts_update.md', 'Accounts', 'Update'] +- ['ads_get.md', 'Ads', 'Get'] +- ['ads_insert.md', 'Ads', 'Insert'] +- ['ads_list.md', 'Ads', 'List'] +- ['ads_patch.md', 'Ads', 'Patch'] +- ['ads_update.md', 'Ads', 'Update'] +- ['advertiser-groups_delete.md', 'Advertiser Groups', 'Delete'] +- ['advertiser-groups_get.md', 'Advertiser Groups', 'Get'] +- ['advertiser-groups_insert.md', 'Advertiser Groups', 'Insert'] +- ['advertiser-groups_list.md', 'Advertiser Groups', 'List'] +- ['advertiser-groups_patch.md', 'Advertiser Groups', 'Patch'] +- ['advertiser-groups_update.md', 'Advertiser Groups', 'Update'] +- ['advertisers_get.md', 'Advertisers', 'Get'] +- ['advertisers_insert.md', 'Advertisers', 'Insert'] +- ['advertisers_list.md', 'Advertisers', 'List'] +- ['advertisers_patch.md', 'Advertisers', 'Patch'] +- ['advertisers_update.md', 'Advertisers', 'Update'] +- ['browsers_list.md', 'Browsers', 'List'] +- ['campaign-creative-associations_insert.md', 'Campaign Creative Associations', 'Insert'] +- ['campaign-creative-associations_list.md', 'Campaign Creative Associations', 'List'] +- ['campaigns_get.md', 'Campaigns', 'Get'] +- ['campaigns_insert.md', 'Campaigns', 'Insert'] +- ['campaigns_list.md', 'Campaigns', 'List'] +- ['campaigns_patch.md', 'Campaigns', 'Patch'] +- ['campaigns_update.md', 'Campaigns', 'Update'] +- ['change-logs_get.md', 'Change Logs', 'Get'] +- ['change-logs_list.md', 'Change Logs', 'List'] +- ['cities_list.md', 'Cities', 'List'] +- ['connection-types_get.md', 'Connection Types', 'Get'] +- ['connection-types_list.md', 'Connection Types', 'List'] +- ['content-categories_delete.md', 'Content Categories', 'Delete'] +- ['content-categories_get.md', 'Content Categories', 'Get'] +- ['content-categories_insert.md', 'Content Categories', 'Insert'] +- ['content-categories_list.md', 'Content Categories', 'List'] +- ['content-categories_patch.md', 'Content Categories', 'Patch'] +- ['content-categories_update.md', 'Content Categories', 'Update'] +- ['conversions_batchinsert.md', 'Conversions', 'Batchinsert'] +- ['countries_get.md', 'Countries', 'Get'] +- ['countries_list.md', 'Countries', 'List'] +- ['creative-assets_insert.md', 'Creative Assets', 'Insert'] +- ['creative-field-values_delete.md', 'Creative Field Values', 'Delete'] +- ['creative-field-values_get.md', 'Creative Field Values', 'Get'] +- ['creative-field-values_insert.md', 'Creative Field Values', 'Insert'] +- ['creative-field-values_list.md', 'Creative Field Values', 'List'] +- ['creative-field-values_patch.md', 'Creative Field Values', 'Patch'] +- ['creative-field-values_update.md', 'Creative Field Values', 'Update'] +- ['creative-fields_delete.md', 'Creative Fields', 'Delete'] +- ['creative-fields_get.md', 'Creative Fields', 'Get'] +- ['creative-fields_insert.md', 'Creative Fields', 'Insert'] +- ['creative-fields_list.md', 'Creative Fields', 'List'] +- ['creative-fields_patch.md', 'Creative Fields', 'Patch'] +- ['creative-fields_update.md', 'Creative Fields', 'Update'] +- ['creative-groups_get.md', 'Creative Groups', 'Get'] +- ['creative-groups_insert.md', 'Creative Groups', 'Insert'] +- ['creative-groups_list.md', 'Creative Groups', 'List'] +- ['creative-groups_patch.md', 'Creative Groups', 'Patch'] +- ['creative-groups_update.md', 'Creative Groups', 'Update'] +- ['creatives_get.md', 'Creatives', 'Get'] +- ['creatives_insert.md', 'Creatives', 'Insert'] +- ['creatives_list.md', 'Creatives', 'List'] +- ['creatives_patch.md', 'Creatives', 'Patch'] +- ['creatives_update.md', 'Creatives', 'Update'] +- ['dimension-values_query.md', 'Dimension Values', 'Query'] +- ['directory-site-contacts_get.md', 'Directory Site Contacts', 'Get'] +- ['directory-site-contacts_list.md', 'Directory Site Contacts', 'List'] +- ['directory-sites_get.md', 'Directory Sites', 'Get'] +- ['directory-sites_insert.md', 'Directory Sites', 'Insert'] +- ['directory-sites_list.md', 'Directory Sites', 'List'] +- ['dynamic-targeting-keys_delete.md', 'Dynamic Targeting Keys', 'Delete'] +- ['dynamic-targeting-keys_insert.md', 'Dynamic Targeting Keys', 'Insert'] +- ['dynamic-targeting-keys_list.md', 'Dynamic Targeting Keys', 'List'] +- ['event-tags_delete.md', 'Event Tags', 'Delete'] +- ['event-tags_get.md', 'Event Tags', 'Get'] +- ['event-tags_insert.md', 'Event Tags', 'Insert'] +- ['event-tags_list.md', 'Event Tags', 'List'] +- ['event-tags_patch.md', 'Event Tags', 'Patch'] +- ['event-tags_update.md', 'Event Tags', 'Update'] +- ['files_get.md', 'Files', 'Get'] +- ['files_list.md', 'Files', 'List'] +- ['floodlight-activities_delete.md', 'Floodlight Activities', 'Delete'] +- ['floodlight-activities_generatetag.md', 'Floodlight Activities', 'Generatetag'] +- ['floodlight-activities_get.md', 'Floodlight Activities', 'Get'] +- ['floodlight-activities_insert.md', 'Floodlight Activities', 'Insert'] +- ['floodlight-activities_list.md', 'Floodlight Activities', 'List'] +- ['floodlight-activities_patch.md', 'Floodlight Activities', 'Patch'] +- ['floodlight-activities_update.md', 'Floodlight Activities', 'Update'] +- ['floodlight-activity-groups_get.md', 'Floodlight Activity Groups', 'Get'] +- ['floodlight-activity-groups_insert.md', 'Floodlight Activity Groups', 'Insert'] +- ['floodlight-activity-groups_list.md', 'Floodlight Activity Groups', 'List'] +- ['floodlight-activity-groups_patch.md', 'Floodlight Activity Groups', 'Patch'] +- ['floodlight-activity-groups_update.md', 'Floodlight Activity Groups', 'Update'] +- ['floodlight-configurations_get.md', 'Floodlight Configurations', 'Get'] +- ['floodlight-configurations_list.md', 'Floodlight Configurations', 'List'] +- ['floodlight-configurations_patch.md', 'Floodlight Configurations', 'Patch'] +- ['floodlight-configurations_update.md', 'Floodlight Configurations', 'Update'] +- ['inventory-items_get.md', 'Inventory Items', 'Get'] +- ['inventory-items_list.md', 'Inventory Items', 'List'] +- ['landing-pages_delete.md', 'Landing Pages', 'Delete'] +- ['landing-pages_get.md', 'Landing Pages', 'Get'] +- ['landing-pages_insert.md', 'Landing Pages', 'Insert'] +- ['landing-pages_list.md', 'Landing Pages', 'List'] +- ['landing-pages_patch.md', 'Landing Pages', 'Patch'] +- ['landing-pages_update.md', 'Landing Pages', 'Update'] +- ['metros_list.md', 'Metros', 'List'] +- ['mobile-carriers_get.md', 'Mobile Carriers', 'Get'] +- ['mobile-carriers_list.md', 'Mobile Carriers', 'List'] +- ['operating-system-versions_get.md', 'Operating System Versions', 'Get'] +- ['operating-system-versions_list.md', 'Operating System Versions', 'List'] +- ['operating-systems_get.md', 'Operating Systems', 'Get'] +- ['operating-systems_list.md', 'Operating Systems', 'List'] +- ['order-documents_get.md', 'Order Documents', 'Get'] +- ['order-documents_list.md', 'Order Documents', 'List'] +- ['orders_get.md', 'Orders', 'Get'] +- ['orders_list.md', 'Orders', 'List'] +- ['placement-groups_get.md', 'Placement Groups', 'Get'] +- ['placement-groups_insert.md', 'Placement Groups', 'Insert'] +- ['placement-groups_list.md', 'Placement Groups', 'List'] +- ['placement-groups_patch.md', 'Placement Groups', 'Patch'] +- ['placement-groups_update.md', 'Placement Groups', 'Update'] +- ['placement-strategies_delete.md', 'Placement Strategies', 'Delete'] +- ['placement-strategies_get.md', 'Placement Strategies', 'Get'] +- ['placement-strategies_insert.md', 'Placement Strategies', 'Insert'] +- ['placement-strategies_list.md', 'Placement Strategies', 'List'] +- ['placement-strategies_patch.md', 'Placement Strategies', 'Patch'] +- ['placement-strategies_update.md', 'Placement Strategies', 'Update'] +- ['placements_generatetags.md', 'Placements', 'Generatetags'] +- ['placements_get.md', 'Placements', 'Get'] +- ['placements_insert.md', 'Placements', 'Insert'] +- ['placements_list.md', 'Placements', 'List'] +- ['placements_patch.md', 'Placements', 'Patch'] +- ['placements_update.md', 'Placements', 'Update'] +- ['platform-types_get.md', 'Platform Types', 'Get'] +- ['platform-types_list.md', 'Platform Types', 'List'] +- ['postal-codes_get.md', 'Postal Codes', 'Get'] +- ['postal-codes_list.md', 'Postal Codes', 'List'] +- ['projects_get.md', 'Projects', 'Get'] +- ['projects_list.md', 'Projects', 'List'] +- ['regions_list.md', 'Regions', 'List'] +- ['remarketing-list-shares_get.md', 'Remarketing List Shares', 'Get'] +- ['remarketing-list-shares_patch.md', 'Remarketing List Shares', 'Patch'] +- ['remarketing-list-shares_update.md', 'Remarketing List Shares', 'Update'] +- ['remarketing-lists_get.md', 'Remarketing Lists', 'Get'] +- ['remarketing-lists_insert.md', 'Remarketing Lists', 'Insert'] +- ['remarketing-lists_list.md', 'Remarketing Lists', 'List'] +- ['remarketing-lists_patch.md', 'Remarketing Lists', 'Patch'] +- ['remarketing-lists_update.md', 'Remarketing Lists', 'Update'] +- ['reports_compatible-fields-query.md', 'Reports', 'Compatible Fields Query'] +- ['reports_delete.md', 'Reports', 'Delete'] +- ['reports_files-get.md', 'Reports', 'Files Get'] +- ['reports_files-list.md', 'Reports', 'Files List'] +- ['reports_get.md', 'Reports', 'Get'] +- ['reports_insert.md', 'Reports', 'Insert'] +- ['reports_list.md', 'Reports', 'List'] +- ['reports_patch.md', 'Reports', 'Patch'] +- ['reports_run.md', 'Reports', 'Run'] +- ['reports_update.md', 'Reports', 'Update'] +- ['sites_get.md', 'Sites', 'Get'] +- ['sites_insert.md', 'Sites', 'Insert'] +- ['sites_list.md', 'Sites', 'List'] +- ['sites_patch.md', 'Sites', 'Patch'] +- ['sites_update.md', 'Sites', 'Update'] +- ['sizes_get.md', 'Sizes', 'Get'] +- ['sizes_insert.md', 'Sizes', 'Insert'] +- ['sizes_list.md', 'Sizes', 'List'] +- ['subaccounts_get.md', 'Subaccounts', 'Get'] +- ['subaccounts_insert.md', 'Subaccounts', 'Insert'] +- ['subaccounts_list.md', 'Subaccounts', 'List'] +- ['subaccounts_patch.md', 'Subaccounts', 'Patch'] +- ['subaccounts_update.md', 'Subaccounts', 'Update'] +- ['targetable-remarketing-lists_get.md', 'Targetable Remarketing Lists', 'Get'] +- ['targetable-remarketing-lists_list.md', 'Targetable Remarketing Lists', 'List'] +- ['user-profiles_get.md', 'User Profiles', 'Get'] +- ['user-profiles_list.md', 'User Profiles', 'List'] +- ['user-role-permission-groups_get.md', 'User Role Permission Groups', 'Get'] +- ['user-role-permission-groups_list.md', 'User Role Permission Groups', 'List'] +- ['user-role-permissions_get.md', 'User Role Permissions', 'Get'] +- ['user-role-permissions_list.md', 'User Role Permissions', 'List'] +- ['user-roles_delete.md', 'User Roles', 'Delete'] +- ['user-roles_get.md', 'User Roles', 'Get'] +- ['user-roles_insert.md', 'User Roles', 'Insert'] +- ['user-roles_list.md', 'User Roles', 'List'] +- ['user-roles_patch.md', 'User Roles', 'Patch'] +- ['user-roles_update.md', 'User Roles', 'Update'] + +theme: readthedocs + +copyright: Copyright © 2015-2016, `Sebastian Thiel` + diff --git a/gen/dfareporting2d5-cli/src/cmn.rs b/gen/dfareporting2d5-cli/src/cmn.rs new file mode 100644 index 0000000000..779c1dc086 --- /dev/null +++ b/gen/dfareporting2d5-cli/src/cmn.rs @@ -0,0 +1,721 @@ +// 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/dfareporting2d5-cli/src/main.rs b/gen/dfareporting2d5-cli/src/main.rs new file mode 100644 index 0000000000..58535c77b3 --- /dev/null +++ b/gen/dfareporting2d5-cli/src/main.rs @@ -0,0 +1,22811 @@ +// 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_dfareporting2d5 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::Dfareporting>, + gp: Vec<&'static str>, + gpm: Vec<(&'static str, &'static str)>, +} + + +impl<'n> Engine<'n> { + fn _account_active_ad_summaries_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_active_ad_summaries().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("summary-account-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 _account_permission_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permission_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_permission_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permission_groups().list(opt.value_of("profile-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 _account_permissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permissions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_permissions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permissions().list(opt.value_of("profile-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 _account_user_profiles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_user_profiles().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().insert(request, opt.value_of("profile-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 _account_user_profiles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_user_profiles().list(opt.value_of("profile-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 { + "user-role-id" => { + call = call.user_role_id(value.unwrap_or("")); + }, + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["search-string", "subaccount-id", "sort-field", "ids", "max-results", "page-token", "user-role-id", "sort-order", "active"].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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().update(request, opt.value_of("profile-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 _accounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _accounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order", "active"].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 _accounts_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 })), + "teaser-size-limit" => Some(("teaserSizeLimit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active-view-opt-out" => Some(("activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "maximum-image-size" => Some(("maximumImageSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-creative-size-id" => Some(("defaultCreativeSizeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-permission-ids" => Some(("accountPermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "account-profile" => Some(("accountProfile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.report-generation-time-zone-id" => Some(("reportsConfiguration.reportGenerationTimeZoneId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reports-configuration.exposure-to-conversion-enabled" => Some(("reportsConfiguration.exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.click-duration" => Some(("reportsConfiguration.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.post-impression-activities-duration" => Some(("reportsConfiguration.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comscore-vce-enabled" => Some(("comscoreVceEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-ads-limit-tier" => Some(("activeAdsLimitTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "country-id" => Some(("countryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-permission-ids", "account-profile", "active", "active-ads-limit-tier", "active-view-opt-out", "available-permission-ids", "click-duration", "comscore-vce-enabled", "country-id", "currency-id", "default-creative-size-id", "description", "exposure-to-conversion-enabled", "id", "kind", "locale", "lookback-configuration", "maximum-image-size", "name", "nielsen-ocr-enabled", "post-impression-activities-duration", "report-generation-time-zone-id", "reports-configuration", "teaser-size-limit"]); + 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::Account = json::value::from_value(object).unwrap(); + let mut call = self.hub.accounts().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _accounts_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 })), + "teaser-size-limit" => Some(("teaserSizeLimit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active-view-opt-out" => Some(("activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "maximum-image-size" => Some(("maximumImageSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-creative-size-id" => Some(("defaultCreativeSizeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-permission-ids" => Some(("accountPermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "account-profile" => Some(("accountProfile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.report-generation-time-zone-id" => Some(("reportsConfiguration.reportGenerationTimeZoneId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reports-configuration.exposure-to-conversion-enabled" => Some(("reportsConfiguration.exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.click-duration" => Some(("reportsConfiguration.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.post-impression-activities-duration" => Some(("reportsConfiguration.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comscore-vce-enabled" => Some(("comscoreVceEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-ads-limit-tier" => Some(("activeAdsLimitTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "country-id" => Some(("countryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-permission-ids", "account-profile", "active", "active-ads-limit-tier", "active-view-opt-out", "available-permission-ids", "click-duration", "comscore-vce-enabled", "country-id", "currency-id", "default-creative-size-id", "description", "exposure-to-conversion-enabled", "id", "kind", "locale", "lookback-configuration", "maximum-image-size", "name", "nielsen-ocr-enabled", "post-impression-activities-duration", "report-generation-time-zone-id", "reports-configuration", "teaser-size-limit"]); + 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::Account = json::value::from_value(object).unwrap(); + let mut call = self.hub.accounts().update(request, opt.value_of("profile-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 _ads_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.ads().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().insert(request, opt.value_of("profile-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 _ads_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.ads().list(opt.value_of("profile-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 { + "type" => { + call = call.add_type(value.unwrap_or("")); + }, + "ssl-required" => { + call = call.ssl_required(arg_from_str(value.unwrap_or("false"), err, "ssl-required", "boolean")); + }, + "ssl-compliant" => { + call = call.ssl_compliant(arg_from_str(value.unwrap_or("false"), err, "ssl-compliant", "boolean")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "remarketing-list-ids" => { + call = call.add_remarketing_list_ids(value.unwrap_or("")); + }, + "placement-ids" => { + call = call.add_placement_ids(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "overridden-event-tag-id" => { + call = call.overridden_event_tag_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "landing-page-ids" => { + call = call.add_landing_page_ids(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "dynamic-click-tracker" => { + call = call.dynamic_click_tracker(arg_from_str(value.unwrap_or("false"), err, "dynamic-click-tracker", "boolean")); + }, + "creative-type" => { + call = call.creative_type(value.unwrap_or("")); + }, + "creative-optimization-configuration-ids" => { + call = call.add_creative_optimization_configuration_ids(value.unwrap_or("")); + }, + "creative-ids" => { + call = call.add_creative_ids(value.unwrap_or("")); + }, + "compatibility" => { + call = call.compatibility(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "audience-segment-ids" => { + call = call.add_audience_segment_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["landing-page-ids", "overridden-event-tag-id", "campaign-ids", "archived", "creative-optimization-configuration-ids", "ssl-compliant", "size-ids", "page-token", "sort-order", "type", "ssl-required", "creative-ids", "max-results", "creative-type", "placement-ids", "active", "compatibility", "advertiser-id", "search-string", "sort-field", "audience-segment-ids", "ids", "remarketing-list-ids", "dynamic-click-tracker"].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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().update(request, opt.value_of("profile-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 _advertiser_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _advertiser_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertiser_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().insert(request, opt.value_of("profile-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 _advertiser_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _advertiser_groups_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertiser_groups_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().update(request, opt.value_of("profile-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 _advertisers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertisers().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertisers_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().insert(request, opt.value_of("profile-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 _advertisers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertisers().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "status" => { + call = call.status(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "only-parent" => { + call = call.only_parent(arg_from_str(value.unwrap_or("false"), err, "only-parent", "boolean")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "include-advertisers-without-groups-only" => { + call = call.include_advertisers_without_groups_only(arg_from_str(value.unwrap_or("false"), err, "include-advertisers-without-groups-only", "boolean")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-ids" => { + call = call.add_floodlight_configuration_ids(value.unwrap_or("")); + }, + "advertiser-group-ids" => { + call = call.add_advertiser_group_ids(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(["status", "search-string", "subaccount-id", "include-advertisers-without-groups-only", "sort-field", "ids", "max-results", "page-token", "only-parent", "sort-order", "floodlight-configuration-ids", "advertiser-group-ids"].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 _advertisers_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertisers_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().update(request, opt.value_of("profile-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 _browsers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.browsers().list(opt.value_of("profile-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 _campaign_creative_associations_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()[..] { + "creative-id" => Some(("creativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["creative-id", "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::CampaignCreativeAssociation = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaign_creative_associations().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _campaign_creative_associations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaign_creative_associations().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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", "sort-order", "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 _campaigns_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaigns().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comscore-vce-enabled" => Some(("comscoreVceEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "comscore-vce-enabled", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("default-landing-page-name").unwrap_or(""), opt.value_of("default-landing-page-url").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 _campaigns_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaigns().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "overridden-event-tag-id" => { + call = call.overridden_event_tag_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "excluded-ids" => { + call = call.add_excluded_ids(value.unwrap_or("")); + }, + "at-least-one-optimization-activity" => { + call = call.at_least_one_optimization_activity(arg_from_str(value.unwrap_or("false"), err, "at-least-one-optimization-activity", "boolean")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(value.unwrap_or("")); + }, + "advertiser-group-ids" => { + call = call.add_advertiser_group_ids(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(["archived", "search-string", "subaccount-id", "sort-field", "advertiser-ids", "ids", "max-results", "excluded-ids", "page-token", "advertiser-group-ids", "sort-order", "overridden-event-tag-id", "at-least-one-optimization-activity"].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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comscore-vce-enabled" => Some(("comscoreVceEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "comscore-vce-enabled", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comscore-vce-enabled" => Some(("comscoreVceEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "comscore-vce-enabled", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().update(request, opt.value_of("profile-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 _change_logs_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.change_logs().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _change_logs_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.change_logs().list(opt.value_of("profile-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 { + "user-profile-ids" => { + call = call.add_user_profile_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "object-type" => { + call = call.object_type(value.unwrap_or("")); + }, + "object-ids" => { + call = call.add_object_ids(value.unwrap_or("")); + }, + "min-change-time" => { + call = call.min_change_time(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-change-time" => { + call = call.max_change_time(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "action" => { + call = call.action(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(["min-change-time", "search-string", "max-change-time", "user-profile-ids", "ids", "max-results", "object-ids", "page-token", "action", "object-type"].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 _cities_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.cities().list(opt.value_of("profile-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 { + "region-dart-ids" => { + call = call.add_region_dart_ids(value.unwrap_or("")); + }, + "name-prefix" => { + call = call.name_prefix(value.unwrap_or("")); + }, + "dart-ids" => { + call = call.add_dart_ids(value.unwrap_or("")); + }, + "country-dart-ids" => { + call = call.add_country_dart_ids(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(["dart-ids", "country-dart-ids", "region-dart-ids", "name-prefix"].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 _connection_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.connection_types().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _connection_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.connection_types().list(opt.value_of("profile-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 _content_categories_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _content_categories_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().insert(request, opt.value_of("profile-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 _content_categories_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().update(request, opt.value_of("profile-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 _conversions_batchinsert(&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 })), + "encryption-info.kind" => Some(("encryptionInfo.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-entity-id" => Some(("encryptionInfo.encryptionEntityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-source" => Some(("encryptionInfo.encryptionSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-entity-type" => Some(("encryptionInfo.encryptionEntityType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["encryption-entity-id", "encryption-entity-type", "encryption-info", "encryption-source", "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::ConversionsBatchInsertRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.conversions().batchinsert(request, opt.value_of("profile-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 _countries_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.countries().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("dart-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 _countries_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.countries().list(opt.value_of("profile-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 _creative_assets_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()[..] { + "warned-validation-rules" => Some(("warnedValidationRules", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "detected-features" => Some(("detectedFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "asset-identifier.type" => Some(("assetIdentifier.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "asset-identifier.name" => Some(("assetIdentifier.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["asset-identifier", "detected-features", "kind", "name", "type", "warned-validation-rules"]); + 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::CreativeAssetMetadata = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_assets().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 vals = opt.values_of("mode").unwrap().collect::>(); + let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); + let mut input_file = input_file_from_opts(vals[1], err); + let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); + 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::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), + CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), + CallType::Standard => 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 _creative_field_values_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _creative_field_values_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 _creative_field_values_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 _creative_fields_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _creative_fields_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().insert(request, opt.value_of("profile-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 _creative_fields_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "page-token", "sort-order"].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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().update(request, opt.value_of("profile-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 _creative_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().insert(request, opt.value_of("profile-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 _creative_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "group-number" => { + call = call.group_number(arg_from_str(value.unwrap_or("-0"), err, "group-number", "integer")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "group-number", "page-token", "sort-order"].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 _creative_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().update(request, opt.value_of("profile-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 _creatives_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creatives().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "custom-html", "custom-key-values", "dimension-name", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().insert(request, opt.value_of("profile-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 _creatives_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creatives().list(opt.value_of("profile-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 { + "types" => { + call = call.add_types(value.unwrap_or("")); + }, + "studio-creative-id" => { + call = call.studio_creative_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "rendering-ids" => { + call = call.add_rendering_ids(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "creative-field-ids" => { + call = call.add_creative_field_ids(value.unwrap_or("")); + }, + "companion-creative-ids" => { + call = call.add_companion_creative_ids(value.unwrap_or("")); + }, + "campaign-id" => { + call = call.campaign_id(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["advertiser-id", "archived", "search-string", "max-results", "campaign-id", "sort-field", "rendering-ids", "ids", "studio-creative-id", "size-ids", "page-token", "sort-order", "companion-creative-ids", "active", "creative-field-ids", "types"].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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "custom-html", "custom-key-values", "dimension-name", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "custom-html", "custom-key-values", "dimension-name", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().update(request, opt.value_of("profile-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 _dimension_values_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()[..] { + "dimension-name" => Some(("dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["dimension-name", "end-date", "kind", "start-date"]); + 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::DimensionValueRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.dimension_values().query(request, opt.value_of("profile-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("")); + }, + "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(["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 _directory_site_contacts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_site_contacts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _directory_site_contacts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_site_contacts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(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(["search-string", "directory-site-ids", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _directory_sites_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_sites().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _directory_sites_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 })), + "country-id" => Some(("countryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.nielsen-ocr-opt-out" => Some(("settings.nielsenOcrOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.active-view-opt-out" => Some(("settings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.dfp-network-name" => Some(("settings.dfp_settings.dfp_network_name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.dfp-settings.publisher-portal-only" => Some(("settings.dfp_settings.publisherPortalOnly", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.programmatic-placement-accepted" => Some(("settings.dfp_settings.programmaticPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.pub-paid-placement-accepted" => Some(("settings.dfp_settings.pubPaidPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.dfp-network-code" => Some(("settings.dfp_settings.dfp_network_code", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.verification-tag-opt-out" => Some(("settings.verificationTagOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.instream-video-placement-accepted" => Some(("settings.instream_video_placement_accepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.interstitial-placement-accepted" => Some(("settings.interstitialPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.video-active-view-opt-out" => Some(("settings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "inpage-tag-formats" => Some(("inpageTagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-id" => Some(("parentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "interstitial-tag-formats" => Some(("interstitialTagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["active", "active-view-opt-out", "country-id", "currency-id", "description", "dfp-network-code", "dfp-network-name", "dfp-settings", "dimension-name", "etag", "id", "id-dimension-value", "inpage-tag-formats", "instream-video-placement-accepted", "interstitial-placement-accepted", "interstitial-tag-formats", "kind", "match-type", "name", "nielsen-ocr-opt-out", "parent-id", "programmatic-placement-accepted", "pub-paid-placement-accepted", "publisher-portal-only", "settings", "url", "value", "verification-tag-opt-out", "video-active-view-opt-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::DirectorySite = json::value::from_value(object).unwrap(); + let mut call = self.hub.directory_sites().insert(request, opt.value_of("profile-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 _directory_sites_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_sites().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "parent-id" => { + call = call.parent_id(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "dfp-network-code" => { + call = call.dfp_network_code(value.unwrap_or("")); + }, + "country-id" => { + call = call.country_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "accepts-publisher-paid-placements" => { + call = call.accepts_publisher_paid_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-publisher-paid-placements", "boolean")); + }, + "accepts-interstitial-placements" => { + call = call.accepts_interstitial_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-interstitial-placements", "boolean")); + }, + "accepts-in-stream-video-placements" => { + call = call.accepts_in_stream_video_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-in-stream-video-placements", "boolean")); + }, + _ => { + 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(["accepts-interstitial-placements", "accepts-publisher-paid-placements", "search-string", "country-id", "accepts-in-stream-video-placements", "sort-field", "ids", "max-results", "page-token", "sort-order", "parent-id", "active", "dfp-network-code"].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 _dynamic_targeting_keys_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.dynamic_targeting_keys().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("object-id").unwrap_or(""), opt.value_of("name").unwrap_or(""), opt.value_of("object-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _dynamic_targeting_keys_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 })), + "object-id" => Some(("objectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "object-type" => Some(("objectType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "name", "object-id", "object-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::DynamicTargetingKey = json::value::from_value(object).unwrap(); + let mut call = self.hub.dynamic_targeting_keys().insert(request, opt.value_of("profile-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 _dynamic_targeting_keys_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.dynamic_targeting_keys().list(opt.value_of("profile-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 { + "object-type" => { + call = call.object_type(value.unwrap_or("")); + }, + "object-id" => { + call = call.object_id(value.unwrap_or("")); + }, + "names" => { + call = call.add_names(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["advertiser-id", "names", "object-id", "object-type"].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 _event_tags_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _event_tags_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _event_tags_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 })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().insert(request, opt.value_of("profile-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 _event_tags_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "event-tag-types" => { + call = call.add_event_tag_types(value.unwrap_or("")); + }, + "enabled" => { + call = call.enabled(arg_from_str(value.unwrap_or("false"), err, "enabled", "boolean")); + }, + "definitions-only" => { + call = call.definitions_only(arg_from_str(value.unwrap_or("false"), err, "definitions-only", "boolean")); + }, + "campaign-id" => { + call = call.campaign_id(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "ad-id" => { + call = call.ad_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(["search-string", "campaign-id", "sort-field", "enabled", "ids", "advertiser-id", "ad-id", "sort-order", "event-tag-types", "definitions-only"].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 _event_tags_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _event_tags_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().update(request, opt.value_of("profile-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 _files_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut download_mode = false; + let mut call = self.hub.files().get(opt.value_of("report-id").unwrap_or(""), opt.value_of("file-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 _files_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.files().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "scope" => { + call = call.scope(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "max-results", "sort-order", "page-token", "scope"].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 _floodlight_activities_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _floodlight_activities_generatetag(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().generatetag(opt.value_of("profile-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 { + "floodlight-activity-id" => { + call = call.floodlight_activity_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(["floodlight-activity-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 _floodlight_activities_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().insert(request, opt.value_of("profile-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 _floodlight_activities_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().list(opt.value_of("profile-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 { + "tag-string" => { + call = call.tag_string(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-id" => { + call = call.floodlight_configuration_id(value.unwrap_or("")); + }, + "floodlight-activity-group-type" => { + call = call.floodlight_activity_group_type(value.unwrap_or("")); + }, + "floodlight-activity-group-tag-string" => { + call = call.floodlight_activity_group_tag_string(value.unwrap_or("")); + }, + "floodlight-activity-group-name" => { + call = call.floodlight_activity_group_name(value.unwrap_or("")); + }, + "floodlight-activity-group-ids" => { + call = call.add_floodlight_activity_group_ids(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["floodlight-activity-group-ids", "search-string", "floodlight-activity-group-name", "sort-field", "floodlight-configuration-id", "ids", "max-results", "advertiser-id", "page-token", "sort-order", "tag-string", "floodlight-activity-group-tag-string", "floodlight-activity-group-type"].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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().update(request, opt.value_of("profile-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 _floodlight_activity_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activity_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activity_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().insert(request, opt.value_of("profile-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 _floodlight_activity_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activity_groups().list(opt.value_of("profile-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 { + "type" => { + call = call.type_(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-id" => { + call = call.floodlight_configuration_id(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["search-string", "sort-field", "floodlight-configuration-id", "ids", "max-results", "advertiser-id", "page-token", "sort-order", "type"].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 _floodlight_activity_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activity_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().update(request, opt.value_of("profile-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 _floodlight_configurations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_configurations().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_configurations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_configurations().list(opt.value_of("profile-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 { + "ids" => { + call = call.add_ids(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(["ids"].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 _floodlight_configurations_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()[..] { + "natural-search-conversion-attribution-option" => Some(("naturalSearchConversionAttributionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exposure-to-conversion-enabled" => Some(("exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "analytics-data-sharing-enabled" => Some(("analyticsDataSharingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "first-day-of-week" => Some(("firstDayOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "standard-variable-types" => Some(("standardVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "omniture-settings.omniture-cost-data-enabled" => Some(("omnitureSettings.omnitureCostDataEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "omniture-settings.omniture-integration-enabled" => Some(("omnitureSettings.omnitureIntegrationEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-settings.dynamic-tag-enabled" => Some(("tagSettings.dynamicTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-settings.image-tag-enabled" => Some(("tagSettings.imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "in-app-attribution-tracking-enabled" => Some(("inAppAttributionTrackingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "analytics-data-sharing-enabled", "click-duration", "dimension-name", "dynamic-tag-enabled", "etag", "exposure-to-conversion-enabled", "first-day-of-week", "id", "id-dimension-value", "image-tag-enabled", "in-app-attribution-tracking-enabled", "kind", "lookback-configuration", "match-type", "natural-search-conversion-attribution-option", "omniture-cost-data-enabled", "omniture-integration-enabled", "omniture-settings", "post-impression-activities-duration", "standard-variable-types", "subaccount-id", "tag-settings", "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::FloodlightConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_configurations().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_configurations_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()[..] { + "natural-search-conversion-attribution-option" => Some(("naturalSearchConversionAttributionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exposure-to-conversion-enabled" => Some(("exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "analytics-data-sharing-enabled" => Some(("analyticsDataSharingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "first-day-of-week" => Some(("firstDayOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "standard-variable-types" => Some(("standardVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "omniture-settings.omniture-cost-data-enabled" => Some(("omnitureSettings.omnitureCostDataEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "omniture-settings.omniture-integration-enabled" => Some(("omnitureSettings.omnitureIntegrationEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-settings.dynamic-tag-enabled" => Some(("tagSettings.dynamicTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-settings.image-tag-enabled" => Some(("tagSettings.imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "in-app-attribution-tracking-enabled" => Some(("inAppAttributionTrackingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "analytics-data-sharing-enabled", "click-duration", "dimension-name", "dynamic-tag-enabled", "etag", "exposure-to-conversion-enabled", "first-day-of-week", "id", "id-dimension-value", "image-tag-enabled", "in-app-attribution-tracking-enabled", "kind", "lookback-configuration", "match-type", "natural-search-conversion-attribution-option", "omniture-cost-data-enabled", "omniture-integration-enabled", "omniture-settings", "post-impression-activities-duration", "standard-variable-types", "subaccount-id", "tag-settings", "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::FloodlightConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_configurations().update(request, opt.value_of("profile-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 _inventory_items_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.inventory_items().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _inventory_items_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.inventory_items().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "type" => { + call = call.type_(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "in-plan" => { + call = call.in_plan(arg_from_str(value.unwrap_or("false"), err, "in-plan", "boolean")); + }, + "ids" => { + call = call.add_ids(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(["order-id", "sort-field", "ids", "max-results", "page-token", "in-plan", "site-id", "sort-order", "type"].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 _landing_pages_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _landing_pages_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _landing_pages_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _metros_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.metros().list(opt.value_of("profile-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 _mobile_carriers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.mobile_carriers().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _mobile_carriers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.mobile_carriers().list(opt.value_of("profile-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 _operating_system_versions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_system_versions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _operating_system_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_system_versions().list(opt.value_of("profile-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 _operating_systems_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_systems().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("dart-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 _operating_systems_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_systems().list(opt.value_of("profile-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 _order_documents_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.order_documents().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _order_documents_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.order_documents().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "boolean")); + }, + _ => { + 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(["order-id", "search-string", "sort-field", "ids", "max-results", "page-token", "site-id", "sort-order", "approved"].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 _orders_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.orders().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _orders_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.orders().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "site-id", "sort-order"].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 _placement_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().insert(request, opt.value_of("profile-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 _placement_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-ids" => { + call = call.add_site_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "pricing-types" => { + call = call.add_pricing_types(value.unwrap_or("")); + }, + "placement-strategy-ids" => { + call = call.add_placement_strategy_ids(value.unwrap_or("")); + }, + "placement-group-type" => { + call = call.placement_group_type(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "min-start-date" => { + call = call.min_start_date(value.unwrap_or("")); + }, + "min-end-date" => { + call = call.min_end_date(value.unwrap_or("")); + }, + "max-start-date" => { + call = call.max_start_date(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-end-date" => { + call = call.max_end_date(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "content-category-ids" => { + call = call.add_content_category_ids(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["placement-strategy-ids", "site-ids", "search-string", "min-end-date", "directory-site-ids", "sort-field", "advertiser-ids", "archived", "ids", "max-results", "min-start-date", "page-token", "max-start-date", "sort-order", "placement-group-type", "pricing-types", "content-category-ids", "campaign-ids", "max-end-date"].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 _placement_groups_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_groups_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().update(request, opt.value_of("profile-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 _placement_strategies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _placement_strategies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().insert(request, opt.value_of("profile-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 _placement_strategies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().update(request, opt.value_of("profile-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 _placements_generatetags(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().generatetags(opt.value_of("profile-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 { + "tag-formats" => { + call = call.add_tag_formats(value.unwrap_or("")); + }, + "placement-ids" => { + call = call.add_placement_ids(value.unwrap_or("")); + }, + "campaign-id" => { + call = call.campaign_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(["tag-formats", "placement-ids", "campaign-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 _placements_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().insert(request, opt.value_of("profile-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 _placements_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "site-ids" => { + call = call.add_site_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "pricing-types" => { + call = call.add_pricing_types(value.unwrap_or("")); + }, + "placement-strategy-ids" => { + call = call.add_placement_strategy_ids(value.unwrap_or("")); + }, + "payment-source" => { + call = call.payment_source(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "min-start-date" => { + call = call.min_start_date(value.unwrap_or("")); + }, + "min-end-date" => { + call = call.min_end_date(value.unwrap_or("")); + }, + "max-start-date" => { + call = call.max_start_date(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-end-date" => { + call = call.max_end_date(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "group-ids" => { + call = call.add_group_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "content-category-ids" => { + call = call.add_content_category_ids(value.unwrap_or("")); + }, + "compatibilities" => { + call = call.add_compatibilities(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["site-ids", "payment-source", "pricing-types", "campaign-ids", "archived", "advertiser-ids", "size-ids", "page-token", "max-start-date", "sort-order", "max-end-date", "placement-strategy-ids", "content-category-ids", "max-results", "min-start-date", "compatibilities", "search-string", "min-end-date", "directory-site-ids", "sort-field", "ids", "group-ids"].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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().update(request, opt.value_of("profile-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 _platform_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.platform_types().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _platform_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.platform_types().list(opt.value_of("profile-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 _postal_codes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.postal_codes().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("code").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 _postal_codes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.postal_codes().list(opt.value_of("profile-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_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "page-token", "sort-order"].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("profile-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 _remarketing_list_shares_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_list_shares().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("remarketing-list-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 _remarketing_list_shares_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()[..] { + "shared-advertiser-ids" => Some(("sharedAdvertiserIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-id" => Some(("remarketingListId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "shared-account-ids" => Some(("sharedAccountIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "remarketing-list-id", "shared-account-ids", "shared-advertiser-ids"]); + 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::RemarketingListShare = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_list_shares().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("remarketing-list-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 _remarketing_list_shares_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()[..] { + "shared-advertiser-ids" => Some(("sharedAdvertiserIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-id" => Some(("remarketingListId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "shared-account-ids" => Some(("sharedAccountIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "remarketing-list-id", "shared-account-ids", "shared-advertiser-ids"]); + 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::RemarketingListShare = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_list_shares().update(request, opt.value_of("profile-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 _remarketing_lists_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_lists().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().insert(request, opt.value_of("profile-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 _remarketing_lists_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_lists().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "floodlight-activity-id" => { + call = call.floodlight_activity_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["name", "sort-field", "max-results", "page-token", "sort-order", "active", "floodlight-activity-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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().update(request, opt.value_of("profile-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 _reports_compatible_fields_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().compatible_fields_query(request, opt.value_of("profile-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 _reports_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _reports_files_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut download_mode = false; + let mut call = self.hub.reports().files_get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-id").unwrap_or(""), opt.value_of("file-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 _reports_files_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().files_list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "sort-order", "max-results", "page-token"].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 _reports_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().insert(request, opt.value_of("profile-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 _reports_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "scope" => { + call = call.scope(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "max-results", "sort-order", "page-token", "scope"].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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _reports_run(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().run(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 { + "synchronous" => { + call = call.synchronous(arg_from_str(value.unwrap_or("false"), err, "synchronous", "boolean")); + }, + _ => { + 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(["synchronous"].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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _sites_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sites().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().insert(request, opt.value_of("profile-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 _sites_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sites().list(opt.value_of("profile-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 { + "unmapped-site" => { + call = call.unmapped_site(arg_from_str(value.unwrap_or("false"), err, "unmapped-site", "boolean")); + }, + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "boolean")); + }, + "ad-words-site" => { + call = call.ad_words_site(arg_from_str(value.unwrap_or("false"), err, "ad-words-site", "boolean")); + }, + "accepts-publisher-paid-placements" => { + call = call.accepts_publisher_paid_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-publisher-paid-placements", "boolean")); + }, + "accepts-interstitial-placements" => { + call = call.accepts_interstitial_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-interstitial-placements", "boolean")); + }, + "accepts-in-stream-video-placements" => { + call = call.accepts_in_stream_video_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-in-stream-video-placements", "boolean")); + }, + _ => { + 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(["accepts-interstitial-placements", "accepts-publisher-paid-placements", "search-string", "subaccount-id", "directory-site-ids", "sort-field", "ids", "max-results", "page-token", "unmapped-site", "accepts-in-stream-video-placements", "ad-words-site", "campaign-ids", "approved", "sort-order"].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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().update(request, opt.value_of("profile-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 _sizes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sizes().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sizes_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()[..] { + "width" => Some(("width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "iab" => Some(("iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "height" => Some(("height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["height", "iab", "id", "kind", "width"]); + 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::Size = json::value::from_value(object).unwrap(); + let mut call = self.hub.sizes().insert(request, opt.value_of("profile-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 _sizes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sizes().list(opt.value_of("profile-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 { + "width" => { + call = call.width(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "iab-standard" => { + call = call.iab_standard(arg_from_str(value.unwrap_or("false"), err, "iab-standard", "boolean")); + }, + "height" => { + call = call.height(arg_from_str(value.unwrap_or("-0"), err, "height", "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(["iab-standard", "width", "ids", "height"].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 _subaccounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.subaccounts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().insert(request, opt.value_of("profile-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 _subaccounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.subaccounts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().update(request, opt.value_of("profile-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 _targetable_remarketing_lists_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targetable_remarketing_lists().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _targetable_remarketing_lists_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targetable_remarketing_lists().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["name", "sort-field", "max-results", "page-token", "sort-order", "active"].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 _user_profiles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().get(opt.value_of("profile-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 _user_profiles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().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 { + _ => { + 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 _user_role_permission_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permission_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_role_permission_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permission_groups().list(opt.value_of("profile-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 _user_role_permissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permissions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_role_permissions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permissions().list(opt.value_of("profile-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 { + "ids" => { + call = call.add_ids(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(["ids"].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 _user_roles_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _user_roles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().insert(request, opt.value_of("profile-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 _user_roles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "account-user-role-only" => { + call = call.account_user_role_only(arg_from_str(value.unwrap_or("false"), err, "account-user-role-only", "boolean")); + }, + _ => { + 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(["search-string", "subaccount-id", "sort-field", "ids", "max-results", "page-token", "sort-order", "account-user-role-only"].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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().update(request, opt.value_of("profile-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() { + ("account-active-ad-summaries", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_active_ad_summaries_get(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-active-ad-summaries".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-permission-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_permission_groups_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_permission_groups_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-permission-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-permissions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_permissions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_permissions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-permissions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-user-profiles", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_user_profiles_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._account_user_profiles_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_user_profiles_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._account_user_profiles_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._account_user_profiles_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-user-profiles".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("accounts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._accounts_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._accounts_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._accounts_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._accounts_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("accounts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("ads", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._ads_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._ads_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._ads_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._ads_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._ads_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("ads".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("advertiser-groups", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._advertiser_groups_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._advertiser_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._advertiser_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._advertiser_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._advertiser_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._advertiser_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("advertiser-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("advertisers", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._advertisers_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._advertisers_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._advertisers_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._advertisers_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._advertisers_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("advertisers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("browsers", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._browsers_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("browsers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("campaign-creative-associations", Some(opt)) => { + match opt.subcommand() { + ("insert", Some(opt)) => { + call_result = self._campaign_creative_associations_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._campaign_creative_associations_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("campaign-creative-associations".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("campaigns", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._campaigns_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._campaigns_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._campaigns_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._campaigns_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._campaigns_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("campaigns".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("change-logs", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._change_logs_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._change_logs_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("change-logs".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("cities", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._cities_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("cities".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("connection-types", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._connection_types_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._connection_types_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("connection-types".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("content-categories", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._content_categories_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._content_categories_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._content_categories_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._content_categories_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._content_categories_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._content_categories_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("content-categories".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("conversions", Some(opt)) => { + match opt.subcommand() { + ("batchinsert", Some(opt)) => { + call_result = self._conversions_batchinsert(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("conversions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("countries", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._countries_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._countries_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("countries".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-assets", Some(opt)) => { + match opt.subcommand() { + ("insert", Some(opt)) => { + call_result = self._creative_assets_insert(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-assets".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-field-values", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._creative_field_values_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._creative_field_values_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_field_values_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_field_values_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_field_values_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_field_values_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-field-values".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-fields", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._creative_fields_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._creative_fields_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_fields_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_fields_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_fields_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_fields_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-fields".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._creative_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creatives", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._creatives_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creatives_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creatives_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creatives_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creatives_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creatives".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("dimension-values", Some(opt)) => { + match opt.subcommand() { + ("query", Some(opt)) => { + call_result = self._dimension_values_query(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("dimension-values".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("directory-site-contacts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._directory_site_contacts_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._directory_site_contacts_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("directory-site-contacts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("directory-sites", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._directory_sites_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._directory_sites_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._directory_sites_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("directory-sites".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("dynamic-targeting-keys", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._dynamic_targeting_keys_delete(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._dynamic_targeting_keys_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._dynamic_targeting_keys_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("dynamic-targeting-keys".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("event-tags", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._event_tags_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._event_tags_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._event_tags_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._event_tags_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._event_tags_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._event_tags_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("event-tags".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("files", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._files_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._files_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("files".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-activities", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._floodlight_activities_delete(opt, dry_run, &mut err); + }, + ("generatetag", Some(opt)) => { + call_result = self._floodlight_activities_generatetag(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._floodlight_activities_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._floodlight_activities_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_activities_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_activities_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_activities_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-activities".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-activity-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._floodlight_activity_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._floodlight_activity_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_activity_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_activity_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_activity_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-activity-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-configurations", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._floodlight_configurations_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_configurations_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_configurations_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_configurations_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-configurations".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("inventory-items", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._inventory_items_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._inventory_items_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("inventory-items".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("landing-pages", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._landing_pages_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._landing_pages_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._landing_pages_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._landing_pages_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._landing_pages_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._landing_pages_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("landing-pages".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("metros", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._metros_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("metros".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("mobile-carriers", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._mobile_carriers_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._mobile_carriers_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("mobile-carriers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("operating-system-versions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._operating_system_versions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._operating_system_versions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("operating-system-versions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("operating-systems", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._operating_systems_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._operating_systems_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("operating-systems".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("order-documents", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._order_documents_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._order_documents_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("order-documents".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("orders", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._orders_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._orders_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("orders".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placement-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._placement_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placement_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placement_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placement_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placement_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placement-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placement-strategies", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._placement_strategies_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._placement_strategies_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placement_strategies_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placement_strategies_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placement_strategies_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placement_strategies_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placement-strategies".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placements", Some(opt)) => { + match opt.subcommand() { + ("generatetags", Some(opt)) => { + call_result = self._placements_generatetags(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._placements_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placements_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placements_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placements_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placements_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placements".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("platform-types", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._platform_types_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._platform_types_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("platform-types".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("postal-codes", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._postal_codes_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._postal_codes_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("postal-codes".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); + }, + ("list", Some(opt)) => { + call_result = self._projects_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("projects".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("regions", Some(opt)) => { + match opt.subcommand() { + ("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(); + } + } + }, + ("remarketing-list-shares", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._remarketing_list_shares_get(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._remarketing_list_shares_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._remarketing_list_shares_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("remarketing-list-shares".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("remarketing-lists", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._remarketing_lists_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._remarketing_lists_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._remarketing_lists_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._remarketing_lists_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._remarketing_lists_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("remarketing-lists".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("reports", Some(opt)) => { + match opt.subcommand() { + ("compatible-fields-query", Some(opt)) => { + call_result = self._reports_compatible_fields_query(opt, dry_run, &mut err); + }, + ("delete", Some(opt)) => { + call_result = self._reports_delete(opt, dry_run, &mut err); + }, + ("files-get", Some(opt)) => { + call_result = self._reports_files_get(opt, dry_run, &mut err); + }, + ("files-list", Some(opt)) => { + call_result = self._reports_files_list(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._reports_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._reports_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._reports_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._reports_patch(opt, dry_run, &mut err); + }, + ("run", Some(opt)) => { + call_result = self._reports_run(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._reports_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("reports".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("sites", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._sites_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._sites_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._sites_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._sites_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._sites_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("sites".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("sizes", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._sizes_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._sizes_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._sizes_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("sizes".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("subaccounts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._subaccounts_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._subaccounts_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._subaccounts_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._subaccounts_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._subaccounts_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("subaccounts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("targetable-remarketing-lists", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._targetable_remarketing_lists_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._targetable_remarketing_lists_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("targetable-remarketing-lists".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-profiles", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_profiles_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_profiles_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-profiles".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-role-permission-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_role_permission_groups_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_role_permission_groups_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-role-permission-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-role-permissions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_role_permissions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_role_permissions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-role-permissions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-roles", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._user_roles_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._user_roles_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._user_roles_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_roles_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._user_roles_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._user_roles_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-roles".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, "dfareporting2d5-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: "dfareporting2d5", + 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::Dfareporting::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 upload_value_names = ["mode", "file"]; + let arg_data = [ + ("account-active-ad-summaries", "methods: 'get'", vec![ + ("get", + Some(r##"Gets the account's active ad summary by account ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-active-ad-summaries_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"summary-account-id"##), + None, + Some(r##"Account ID."##), + 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)), + ]), + ]), + + ("account-permission-groups", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one account permission group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-permission-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account permission group ID."##), + 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 account permission groups."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-permission-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("account-permissions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one account permission by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-permissions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account permission ID."##), + 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 account permissions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-permissions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("account-user-profiles", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one account user profile by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-user-profiles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User profile ID."##), + 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##"Inserts a new account user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-user-profiles_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 account user profiles, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-user-profiles_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing account user profile. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-user-profiles_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User profile ID."##), + 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 existing account user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/account-user-profiles_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("accounts", "methods: 'get', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one account by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/accounts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account ID."##), + 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 accounts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/accounts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing account. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/accounts_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account ID."##), + 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 existing account."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/accounts_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("ads", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one ad by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/ads_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Ad ID."##), + 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##"Inserts a new ad."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/ads_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 ads, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/ads_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing ad. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/ads_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Ad ID."##), + 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 existing ad."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/ads_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("advertiser-groups", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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##"Gets one advertiser group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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##"Inserts a new advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 advertiser groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing advertiser group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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 existing advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertiser-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("advertisers", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one advertiser by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertisers_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser ID."##), + 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##"Inserts a new advertiser."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertisers_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 advertisers, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertisers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing advertiser. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertisers_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser ID."##), + 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 existing advertiser."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/advertisers_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("browsers", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of browsers."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/browsers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("campaign-creative-associations", "methods: 'insert' and 'list'", vec![ + ("insert", + Some(r##"Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaign-creative-associations_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Campaign ID in this association."##), + 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 creative IDs associated with the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaign-creative-associations_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Campaign ID in this association."##), + 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)), + ]), + ]), + + ("campaigns", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one campaign by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaigns_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Campaign ID."##), + 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##"Inserts a new campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaigns_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"default-landing-page-name"##), + None, + Some(r##"Default landing page name for this new campaign. Must be less than 256 characters long."##), + Some(true), + Some(false)), + + (Some(r##"default-landing-page-url"##), + None, + Some(r##"Default landing page URL for this new campaign."##), + 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 campaigns, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaigns_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing campaign. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaigns_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Campaign ID."##), + 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 existing campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/campaigns_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("change-logs", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one change log by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/change-logs_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Change log ID."##), + 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 change logs."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/change-logs_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("cities", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of cities, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/cities_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("connection-types", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one connection type by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/connection-types_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Connection type ID."##), + 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 connection types."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/connection-types_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("content-categories", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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##"Gets one content category by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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##"Inserts a new content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 content categories, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing content category. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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 existing content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/content-categories_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("conversions", "methods: 'batchinsert'", vec![ + ("batchinsert", + Some(r##"Inserts conversions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/conversions_batchinsert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("countries", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one country by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/countries_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"dart-id"##), + None, + Some(r##"Country DART ID."##), + 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 countries."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/countries_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creative-assets", "methods: 'insert'", vec![ + ("insert", + Some(r##"Inserts a new creative asset."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-assets_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Advertiser ID of this creative. This is a required field."##), + 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##"mode"##), + Some(r##"u"##), + Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), + 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)), + ]), + ]), + + ("creative-field-values", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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##"Gets one creative field value by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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##"Inserts a new creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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 creative field values, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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 existing creative field value. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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 existing creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-field-values_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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)), + ]), + ]), + + ("creative-fields", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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##"Gets one creative field by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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##"Inserts a new creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creative fields, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative field. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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 existing creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-fields_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creative-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one creative group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative group ID."##), + 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##"Inserts a new creative group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creative groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative group ID."##), + 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 existing creative group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creative-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creatives", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one creative by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creatives_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative ID."##), + 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##"Inserts a new creative."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creatives_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creatives, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creatives_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creatives_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative ID."##), + 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 existing creative."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/creatives_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("dimension-values", "methods: 'query'", vec![ + ("query", + Some(r##"Retrieves list of report dimension values for a list of filters."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/dimension-values_query", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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)), + ]), + ]), + + ("directory-site-contacts", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one directory site contact by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/directory-site-contacts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Directory site contact ID."##), + 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 directory site contacts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/directory-site-contacts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("directory-sites", "methods: 'get', 'insert' and 'list'", vec![ + ("get", + Some(r##"Gets one directory site by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/directory-sites_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Directory site ID."##), + 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##"Inserts a new directory site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/directory-sites_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 directory sites, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/directory-sites_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("dynamic-targeting-keys", "methods: 'delete', 'insert' and 'list'", vec![ + ("delete", + Some(r##"Deletes an existing dynamic targeting key."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/dynamic-targeting-keys_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"object-id"##), + None, + Some(r##"ID of the object of this dynamic targeting key. This is a required field."##), + Some(true), + Some(false)), + + (Some(r##"name"##), + None, + Some(r##"Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase."##), + Some(true), + Some(false)), + + (Some(r##"object-type"##), + None, + Some(r##"Type of the object of this dynamic targeting key. This is a required field."##), + 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)), + ]), + ("insert", + Some(r##"Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/dynamic-targeting-keys_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 dynamic targeting keys."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/dynamic-targeting-keys_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("event-tags", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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##"Gets one event tag by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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##"Inserts a new event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 event tags, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing event tag. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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 existing event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/event-tags_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("files", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Retrieves a report file by its report ID and file ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/files_get", + vec![ + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + Some(true), + Some(false)), + + (Some(r##"file-id"##), + None, + Some(r##"The ID of the report file."##), + 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##"Lists files for a user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/files_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + 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)), + ]), + ]), + + ("floodlight-activities", "methods: 'delete', 'generatetag', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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)), + ]), + ("generatetag", + Some(r##"Generates a tag for a floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_generatetag", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets one floodlight activity by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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##"Inserts a new floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 floodlight activities, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight activity. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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 existing floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activities_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("floodlight-activity-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one floodlight activity group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activity-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity Group ID."##), + 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##"Inserts a new floodlight activity group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activity-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 floodlight activity groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activity-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight activity group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activity-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity Group ID."##), + 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 existing floodlight activity group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-activity-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("floodlight-configurations", "methods: 'get', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one floodlight configuration by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-configurations_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight configuration ID."##), + 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 floodlight configurations, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-configurations_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight configuration. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-configurations_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight configuration ID."##), + 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 existing floodlight configuration."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/floodlight-configurations_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("inventory-items", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one inventory item by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/inventory-items_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Inventory item ID."##), + 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 inventory items, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/inventory-items_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + 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)), + ]), + ]), + + ("landing-pages", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing campaign landing page."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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##"Gets one campaign landing page by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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##"Inserts a new landing page for the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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 landing pages for the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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 existing campaign landing page. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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 existing campaign landing page."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/landing-pages_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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)), + ]), + ]), + + ("metros", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of metros."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/metros_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("mobile-carriers", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one mobile carrier by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/mobile-carriers_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Mobile carrier ID."##), + 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 mobile carriers."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/mobile-carriers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("operating-system-versions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one operating system version by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/operating-system-versions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Operating system version ID."##), + 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 operating system versions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/operating-system-versions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("operating-systems", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one operating system by DART ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/operating-systems_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"dart-id"##), + None, + Some(r##"Operating system DART ID."##), + 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 operating systems."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/operating-systems_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("order-documents", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one order document by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/order-documents_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Order document ID."##), + 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 order documents, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/order-documents_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + 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)), + ]), + ]), + + ("orders", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one order by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/orders_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for orders."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Order ID."##), + 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 orders, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/orders_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for orders."##), + 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)), + ]), + ]), + + ("placement-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one placement group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement group ID."##), + 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##"Inserts a new placement group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placement groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement group ID."##), + 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 existing placement group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("placement-strategies", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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##"Gets one placement strategy by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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##"Inserts a new placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placement strategies, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement strategy. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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 existing placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placement-strategies_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("placements", "methods: 'generatetags', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("generatetags", + Some(r##"Generates tags for a placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_generatetags", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets one placement by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement ID."##), + 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##"Inserts a new placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placements, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement ID."##), + 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 existing placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/placements_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("platform-types", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one platform type by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/platform-types_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Platform type ID."##), + 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 platform types."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/platform-types_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("postal-codes", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one postal code by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/postal-codes_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"code"##), + None, + Some(r##"Postal code ID."##), + 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 postal codes."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/postal-codes_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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' and 'list'", vec![ + ("get", + Some(r##"Gets one project by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/projects_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Project ID."##), + 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 projects, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/projects_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of regions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/regions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("remarketing-list-shares", "methods: 'get', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one remarketing list share by remarketing list ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-list-shares_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-list-id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list share. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-list-shares_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-list-id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list share."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-list-shares_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("remarketing-lists", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one remarketing list by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-lists_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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##"Inserts a new remarketing list."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-lists_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 remarketing lists, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-lists_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Select only remarketing lists owned by this advertiser."##), + 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 existing remarketing list. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-lists_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/remarketing-lists_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("reports", "methods: 'compatible-fields-query', 'delete', 'files-get', 'files-list', 'get', 'insert', 'list', 'patch', 'run' and 'update'", vec![ + ("compatible-fields-query", + Some(r##"Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_compatible-fields-query", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 a report by its ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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)), + ]), + ("files-get", + Some(r##"Retrieves a report file."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_files-get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + Some(true), + Some(false)), + + (Some(r##"file-id"##), + None, + Some(r##"The ID of the report file."##), + 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)), + ]), + ("files-list", + Some(r##"Lists files for a report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_files-list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the parent report."##), + 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##"Retrieves a report by its ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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 report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 list of reports."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 report. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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", + Some(r##"Runs a report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_run", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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 report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/reports_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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)), + ]), + ]), + + ("sites", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one site by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sites_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Site ID."##), + 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##"Inserts a new site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sites_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 sites, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sites_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing site. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sites_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Site ID."##), + 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 existing site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sites_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("sizes", "methods: 'get', 'insert' and 'list'", vec![ + ("get", + Some(r##"Gets one size by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sizes_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Size ID."##), + 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##"Inserts a new size."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sizes_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 sizes, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/sizes_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("subaccounts", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one subaccount by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/subaccounts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Subaccount ID."##), + 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##"Inserts a new subaccount."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/subaccounts_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets a list of subaccounts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/subaccounts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing subaccount. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/subaccounts_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Subaccount ID."##), + 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 existing subaccount."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/subaccounts_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("targetable-remarketing-lists", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one remarketing list by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/targetable-remarketing-lists_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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 targetable remarketing lists, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/targetable-remarketing-lists_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Select only targetable remarketing lists targetable by these advertisers."##), + 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)), + ]), + ]), + + ("user-profiles", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user profile by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-profiles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The user profile ID."##), + 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 list of user profiles for a user."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-profiles_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)), + ]), + ]), + + ("user-role-permission-groups", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user role permission group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-role-permission-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role permission group ID."##), + 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##"Gets a list of all supported user role permission groups."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-role-permission-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("user-role-permissions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user role permission by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-role-permissions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role permission ID."##), + 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##"Gets a list of user role permissions, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-role-permissions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("user-roles", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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##"Gets one user role by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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##"Inserts a new user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 user roles, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing user role. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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 existing user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d5_cli/user-roles_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ]; + + let mut app = App::new("dfareporting2d5") + .author("Sebastian Thiel ") + .version("0.3.6+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") + .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); + } + if arg_name_str == "mode" { + arg = arg.number_of_values(2); + arg = arg.value_names(&upload_value_names); + + scmd = scmd.arg(Arg::with_name("mime") + .short("m") + .requires("mode") + .required(false) + .help("The file's mime time, like 'application/octet-stream'") + .takes_value(true)); + } + 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/dfareporting2d5/Cargo.toml b/gen/dfareporting2d5/Cargo.toml new file mode 100644 index 0000000000..ae3290d145 --- /dev/null +++ b/gen/dfareporting2d5/Cargo.toml @@ -0,0 +1,34 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-dfareporting2d5" +version = "0.1.14+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" +homepage = "https://developers.google.com/doubleclick-advertisers/reporting/" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d5" +license = "MIT" +keywords = ["dfareporting", "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/dfareporting2d5/LICENSE.md b/gen/dfareporting2d5/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/dfareporting2d5/LICENSE.md @@ -0,0 +1,30 @@ + +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/dfareporting2d5/README.md b/gen/dfareporting2d5/README.md new file mode 100644 index 0000000000..e4de5f648c --- /dev/null +++ b/gen/dfareporting2d5/README.md @@ -0,0 +1,308 @@ + +The `google-dfareporting2d5` library allows access to all features of the *Google dfareporting* service. + +This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. + +Everything else about the *dfareporting* *v2d5* API can be found at the +[official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). +# Features + +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Dfareporting.html) ... + +* [account active ad summaries](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountActiveAdSummary.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountActiveAdSummaryGetCall.html) +* [account permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermissionGroupListCall.html) +* [account permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPermissionListCall.html) +* [account user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfileGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfileInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfileListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfilePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUserProfileUpdateCall.html) +* [accounts](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Account.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AccountUpdateCall.html) +* [ads](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Ad.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdUpdateCall.html) +* [advertiser groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroup.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGroupUpdateCall.html) +* [advertisers](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Advertiser.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.AdvertiserUpdateCall.html) +* [browsers](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Browser.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.BrowserListCall.html) +* [campaign creative associations](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignCreativeAssociation.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignCreativeAssociationInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignCreativeAssociationListCall.html) +* [campaigns](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Campaign.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CampaignUpdateCall.html) +* [change logs](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ChangeLog.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ChangeLogGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ChangeLogListCall.html) +* [cities](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.City.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CityListCall.html) +* [connection types](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ConnectionType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ConnectionTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ConnectionTypeListCall.html) +* [content categories](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategory.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ContentCategoryUpdateCall.html) +* [conversions](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Conversion.html) + * [*batchinsert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ConversionBatchinsertCall.html) +* [countries](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Country.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CountryGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CountryListCall.html) +* [creative assets](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeAsset.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeAssetInsertCall.html) +* [creative field values](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValue.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValueDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValueGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValueInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValueListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValuePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldValueUpdateCall.html) +* [creative fields](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeField.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeFieldUpdateCall.html) +* [creative groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGroupUpdateCall.html) +* [creatives](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Creative.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeUpdateCall.html) +* [dimension values](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DimensionValue.html) + * [*query*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DimensionValueQueryCall.html) +* [directory site contacts](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteContact.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteContactGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteContactListCall.html) +* [directory sites](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySite.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DirectorySiteListCall.html) +* [dynamic targeting keys](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DynamicTargetingKey.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DynamicTargetingKeyDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DynamicTargetingKeyInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.DynamicTargetingKeyListCall.html) +* [event tags](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTag.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.EventTagUpdateCall.html) +* [files](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.File.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FileListCall.html) +* [floodlight activities](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivity.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityDeleteCall.html), [*generatetag*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityUpdateCall.html) +* [floodlight activity groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightActivityGroupUpdateCall.html) +* [floodlight configurations](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightConfiguration.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightConfigurationGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightConfigurationListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightConfigurationPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FloodlightConfigurationUpdateCall.html) +* [inventory items](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.InventoryItem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.InventoryItemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.InventoryItemListCall.html) +* [landing pages](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPage.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPageDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPageGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPageInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPageListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPagePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.LandingPageUpdateCall.html) +* [metros](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Metro.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.MetroListCall.html) +* [mobile carriers](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.MobileCarrier.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.MobileCarrierGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.MobileCarrierListCall.html) +* [operating system versions](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystemVersion.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystemVersionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystemVersionListCall.html) +* [operating systems](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OperatingSystemListCall.html) +* [order documents](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OrderDocument.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OrderDocumentGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OrderDocumentListCall.html) +* [orders](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Order.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OrderGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.OrderListCall.html) +* [placement groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGroupUpdateCall.html) +* [placement strategies](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategy.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementStrategyUpdateCall.html) +* [placements](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Placement.html) + * [*generatetags*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlacementUpdateCall.html) +* [platform types](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlatformType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlatformTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PlatformTypeListCall.html) +* [postal codes](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PostalCode.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PostalCodeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.PostalCodeListCall.html) +* [projects](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Project.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ProjectGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ProjectListCall.html) +* [regions](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Region.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RegionListCall.html) +* [remarketing list shares](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListShare.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListShareGetCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListSharePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListShareUpdateCall.html) +* [remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.RemarketingListUpdateCall.html) +* [reports](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Report.html) + * [*compatible fields query*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportCompatibleFieldQueryCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportDeleteCall.html), [*files get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportFileGetCall.html), [*files list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportFileListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportPatchCall.html), [*run*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportRunCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportUpdateCall.html) +* [sites](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Site.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SiteInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SiteListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SitePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SiteUpdateCall.html) +* [sizes](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Size.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SizeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SizeInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SizeListCall.html) +* [subaccounts](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Subaccount.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SubaccountGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SubaccountInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SubaccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SubaccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.SubaccountUpdateCall.html) +* [targetable remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.TargetableRemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.TargetableRemarketingListGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.TargetableRemarketingListListCall.html) +* [user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserProfileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserProfileListCall.html) +* [user role permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermissionGroupListCall.html) +* [user role permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePermissionListCall.html) +* [user roles](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRole.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRoleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRoleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRoleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRoleListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRolePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.UserRoleUpdateCall.html) + + +Upload supported by ... + +* [*insert creative assets*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.CreativeAssetInsertCall.html) + +Download supported by ... + +* [*get files*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.FileGetCall.html) +* [*files get reports*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.ReportFileGetCall.html) + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](http://byron.github.io/google-apis-rs/google_dfareporting2d5/struct.Dfareporting.html)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d5/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_dfareporting2d5/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_dfareporting2d5/trait.Part.html)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](http://byron.github.io/google-apis-rs/google_dfareporting2d5/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.reports().run(...).doit() +let r = hub.reports().get(...).doit() +let r = hub.reports().list(...).doit() +let r = hub.reports().delete(...).doit() +let r = hub.reports().files_list(...).doit() +let r = hub.reports().insert(...).doit() +let r = hub.reports().patch(...).doit() +let r = hub.reports().compatible_fields_query(...).doit() +let r = hub.reports().update(...).doit() +let r = hub.reports().files_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-dfareporting2d5 = "*" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate yup_oauth2 as oauth2; +extern crate google_dfareporting2d5 as dfareporting2d5; +use dfareporting2d5::{Result, Error}; +use std::default::Default; +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +use dfareporting2d5::Dfareporting; + +// 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 = Dfareporting::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.reports().list("profileId") + .sort_order("sit") + .sort_field("Stet") + .scope("sed") + .page_token("et") + .max_results(-18) + .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_dfareporting2d5/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_dfareporting2d5/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2d5/../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_dfareporting2d5/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_dfareporting2d5/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_dfareporting2d5/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_dfareporting2d5/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_dfareporting2d5/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_dfareporting2d5/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_dfareporting2d5/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_dfareporting2d5/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_dfareporting2d5/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_dfareporting2d5/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 **dfareporting2d5** 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/dfareporting2d5/src/build.rs b/gen/dfareporting2d5/src/build.rs new file mode 100644 index 0000000000..0bebaf0bf0 --- /dev/null +++ b/gen/dfareporting2d5/src/build.rs @@ -0,0 +1,25 @@ +#[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/dfareporting2d5/src/cmn.rs b/gen/dfareporting2d5/src/cmn.rs new file mode 100644 index 0000000000..d75063e466 --- /dev/null +++ b/gen/dfareporting2d5/src/cmn.rs @@ -0,0 +1,753 @@ +// 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/dfareporting2d5/src/lib.rs b/gen/dfareporting2d5/src/lib.rs new file mode 100644 index 0000000000..27f771ede5 --- /dev/null +++ b/gen/dfareporting2d5/src/lib.rs @@ -0,0 +1,318 @@ +// DO NOT EDIT ! +// This file was generated automatically from 'src/mako/api/lib.rs.mako' +// DO NOT EDIT ! + +//! This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.5* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! +//! Everything else about the *dfareporting* *v2d5* API can be found at the +//! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d5). +//! # Features +//! +//! Handle the following *Resources* with ease from the central [hub](struct.Dfareporting.html) ... +//! +//! * [account active ad summaries](struct.AccountActiveAdSummary.html) +//! * [*get*](struct.AccountActiveAdSummaryGetCall.html) +//! * [account permission groups](struct.AccountPermissionGroup.html) +//! * [*get*](struct.AccountPermissionGroupGetCall.html) and [*list*](struct.AccountPermissionGroupListCall.html) +//! * [account permissions](struct.AccountPermission.html) +//! * [*get*](struct.AccountPermissionGetCall.html) and [*list*](struct.AccountPermissionListCall.html) +//! * [account user profiles](struct.AccountUserProfile.html) +//! * [*get*](struct.AccountUserProfileGetCall.html), [*insert*](struct.AccountUserProfileInsertCall.html), [*list*](struct.AccountUserProfileListCall.html), [*patch*](struct.AccountUserProfilePatchCall.html) and [*update*](struct.AccountUserProfileUpdateCall.html) +//! * [accounts](struct.Account.html) +//! * [*get*](struct.AccountGetCall.html), [*list*](struct.AccountListCall.html), [*patch*](struct.AccountPatchCall.html) and [*update*](struct.AccountUpdateCall.html) +//! * [ads](struct.Ad.html) +//! * [*get*](struct.AdGetCall.html), [*insert*](struct.AdInsertCall.html), [*list*](struct.AdListCall.html), [*patch*](struct.AdPatchCall.html) and [*update*](struct.AdUpdateCall.html) +//! * [advertiser groups](struct.AdvertiserGroup.html) +//! * [*delete*](struct.AdvertiserGroupDeleteCall.html), [*get*](struct.AdvertiserGroupGetCall.html), [*insert*](struct.AdvertiserGroupInsertCall.html), [*list*](struct.AdvertiserGroupListCall.html), [*patch*](struct.AdvertiserGroupPatchCall.html) and [*update*](struct.AdvertiserGroupUpdateCall.html) +//! * [advertisers](struct.Advertiser.html) +//! * [*get*](struct.AdvertiserGetCall.html), [*insert*](struct.AdvertiserInsertCall.html), [*list*](struct.AdvertiserListCall.html), [*patch*](struct.AdvertiserPatchCall.html) and [*update*](struct.AdvertiserUpdateCall.html) +//! * [browsers](struct.Browser.html) +//! * [*list*](struct.BrowserListCall.html) +//! * [campaign creative associations](struct.CampaignCreativeAssociation.html) +//! * [*insert*](struct.CampaignCreativeAssociationInsertCall.html) and [*list*](struct.CampaignCreativeAssociationListCall.html) +//! * [campaigns](struct.Campaign.html) +//! * [*get*](struct.CampaignGetCall.html), [*insert*](struct.CampaignInsertCall.html), [*list*](struct.CampaignListCall.html), [*patch*](struct.CampaignPatchCall.html) and [*update*](struct.CampaignUpdateCall.html) +//! * [change logs](struct.ChangeLog.html) +//! * [*get*](struct.ChangeLogGetCall.html) and [*list*](struct.ChangeLogListCall.html) +//! * [cities](struct.City.html) +//! * [*list*](struct.CityListCall.html) +//! * [connection types](struct.ConnectionType.html) +//! * [*get*](struct.ConnectionTypeGetCall.html) and [*list*](struct.ConnectionTypeListCall.html) +//! * [content categories](struct.ContentCategory.html) +//! * [*delete*](struct.ContentCategoryDeleteCall.html), [*get*](struct.ContentCategoryGetCall.html), [*insert*](struct.ContentCategoryInsertCall.html), [*list*](struct.ContentCategoryListCall.html), [*patch*](struct.ContentCategoryPatchCall.html) and [*update*](struct.ContentCategoryUpdateCall.html) +//! * [conversions](struct.Conversion.html) +//! * [*batchinsert*](struct.ConversionBatchinsertCall.html) +//! * [countries](struct.Country.html) +//! * [*get*](struct.CountryGetCall.html) and [*list*](struct.CountryListCall.html) +//! * [creative assets](struct.CreativeAsset.html) +//! * [*insert*](struct.CreativeAssetInsertCall.html) +//! * [creative field values](struct.CreativeFieldValue.html) +//! * [*delete*](struct.CreativeFieldValueDeleteCall.html), [*get*](struct.CreativeFieldValueGetCall.html), [*insert*](struct.CreativeFieldValueInsertCall.html), [*list*](struct.CreativeFieldValueListCall.html), [*patch*](struct.CreativeFieldValuePatchCall.html) and [*update*](struct.CreativeFieldValueUpdateCall.html) +//! * [creative fields](struct.CreativeField.html) +//! * [*delete*](struct.CreativeFieldDeleteCall.html), [*get*](struct.CreativeFieldGetCall.html), [*insert*](struct.CreativeFieldInsertCall.html), [*list*](struct.CreativeFieldListCall.html), [*patch*](struct.CreativeFieldPatchCall.html) and [*update*](struct.CreativeFieldUpdateCall.html) +//! * [creative groups](struct.CreativeGroup.html) +//! * [*get*](struct.CreativeGroupGetCall.html), [*insert*](struct.CreativeGroupInsertCall.html), [*list*](struct.CreativeGroupListCall.html), [*patch*](struct.CreativeGroupPatchCall.html) and [*update*](struct.CreativeGroupUpdateCall.html) +//! * [creatives](struct.Creative.html) +//! * [*get*](struct.CreativeGetCall.html), [*insert*](struct.CreativeInsertCall.html), [*list*](struct.CreativeListCall.html), [*patch*](struct.CreativePatchCall.html) and [*update*](struct.CreativeUpdateCall.html) +//! * [dimension values](struct.DimensionValue.html) +//! * [*query*](struct.DimensionValueQueryCall.html) +//! * [directory site contacts](struct.DirectorySiteContact.html) +//! * [*get*](struct.DirectorySiteContactGetCall.html) and [*list*](struct.DirectorySiteContactListCall.html) +//! * [directory sites](struct.DirectorySite.html) +//! * [*get*](struct.DirectorySiteGetCall.html), [*insert*](struct.DirectorySiteInsertCall.html) and [*list*](struct.DirectorySiteListCall.html) +//! * [dynamic targeting keys](struct.DynamicTargetingKey.html) +//! * [*delete*](struct.DynamicTargetingKeyDeleteCall.html), [*insert*](struct.DynamicTargetingKeyInsertCall.html) and [*list*](struct.DynamicTargetingKeyListCall.html) +//! * [event tags](struct.EventTag.html) +//! * [*delete*](struct.EventTagDeleteCall.html), [*get*](struct.EventTagGetCall.html), [*insert*](struct.EventTagInsertCall.html), [*list*](struct.EventTagListCall.html), [*patch*](struct.EventTagPatchCall.html) and [*update*](struct.EventTagUpdateCall.html) +//! * [files](struct.File.html) +//! * [*get*](struct.FileGetCall.html) and [*list*](struct.FileListCall.html) +//! * [floodlight activities](struct.FloodlightActivity.html) +//! * [*delete*](struct.FloodlightActivityDeleteCall.html), [*generatetag*](struct.FloodlightActivityGeneratetagCall.html), [*get*](struct.FloodlightActivityGetCall.html), [*insert*](struct.FloodlightActivityInsertCall.html), [*list*](struct.FloodlightActivityListCall.html), [*patch*](struct.FloodlightActivityPatchCall.html) and [*update*](struct.FloodlightActivityUpdateCall.html) +//! * [floodlight activity groups](struct.FloodlightActivityGroup.html) +//! * [*get*](struct.FloodlightActivityGroupGetCall.html), [*insert*](struct.FloodlightActivityGroupInsertCall.html), [*list*](struct.FloodlightActivityGroupListCall.html), [*patch*](struct.FloodlightActivityGroupPatchCall.html) and [*update*](struct.FloodlightActivityGroupUpdateCall.html) +//! * [floodlight configurations](struct.FloodlightConfiguration.html) +//! * [*get*](struct.FloodlightConfigurationGetCall.html), [*list*](struct.FloodlightConfigurationListCall.html), [*patch*](struct.FloodlightConfigurationPatchCall.html) and [*update*](struct.FloodlightConfigurationUpdateCall.html) +//! * [inventory items](struct.InventoryItem.html) +//! * [*get*](struct.InventoryItemGetCall.html) and [*list*](struct.InventoryItemListCall.html) +//! * [landing pages](struct.LandingPage.html) +//! * [*delete*](struct.LandingPageDeleteCall.html), [*get*](struct.LandingPageGetCall.html), [*insert*](struct.LandingPageInsertCall.html), [*list*](struct.LandingPageListCall.html), [*patch*](struct.LandingPagePatchCall.html) and [*update*](struct.LandingPageUpdateCall.html) +//! * [metros](struct.Metro.html) +//! * [*list*](struct.MetroListCall.html) +//! * [mobile carriers](struct.MobileCarrier.html) +//! * [*get*](struct.MobileCarrierGetCall.html) and [*list*](struct.MobileCarrierListCall.html) +//! * [operating system versions](struct.OperatingSystemVersion.html) +//! * [*get*](struct.OperatingSystemVersionGetCall.html) and [*list*](struct.OperatingSystemVersionListCall.html) +//! * [operating systems](struct.OperatingSystem.html) +//! * [*get*](struct.OperatingSystemGetCall.html) and [*list*](struct.OperatingSystemListCall.html) +//! * [order documents](struct.OrderDocument.html) +//! * [*get*](struct.OrderDocumentGetCall.html) and [*list*](struct.OrderDocumentListCall.html) +//! * [orders](struct.Order.html) +//! * [*get*](struct.OrderGetCall.html) and [*list*](struct.OrderListCall.html) +//! * [placement groups](struct.PlacementGroup.html) +//! * [*get*](struct.PlacementGroupGetCall.html), [*insert*](struct.PlacementGroupInsertCall.html), [*list*](struct.PlacementGroupListCall.html), [*patch*](struct.PlacementGroupPatchCall.html) and [*update*](struct.PlacementGroupUpdateCall.html) +//! * [placement strategies](struct.PlacementStrategy.html) +//! * [*delete*](struct.PlacementStrategyDeleteCall.html), [*get*](struct.PlacementStrategyGetCall.html), [*insert*](struct.PlacementStrategyInsertCall.html), [*list*](struct.PlacementStrategyListCall.html), [*patch*](struct.PlacementStrategyPatchCall.html) and [*update*](struct.PlacementStrategyUpdateCall.html) +//! * [placements](struct.Placement.html) +//! * [*generatetags*](struct.PlacementGeneratetagCall.html), [*get*](struct.PlacementGetCall.html), [*insert*](struct.PlacementInsertCall.html), [*list*](struct.PlacementListCall.html), [*patch*](struct.PlacementPatchCall.html) and [*update*](struct.PlacementUpdateCall.html) +//! * [platform types](struct.PlatformType.html) +//! * [*get*](struct.PlatformTypeGetCall.html) and [*list*](struct.PlatformTypeListCall.html) +//! * [postal codes](struct.PostalCode.html) +//! * [*get*](struct.PostalCodeGetCall.html) and [*list*](struct.PostalCodeListCall.html) +//! * [projects](struct.Project.html) +//! * [*get*](struct.ProjectGetCall.html) and [*list*](struct.ProjectListCall.html) +//! * [regions](struct.Region.html) +//! * [*list*](struct.RegionListCall.html) +//! * [remarketing list shares](struct.RemarketingListShare.html) +//! * [*get*](struct.RemarketingListShareGetCall.html), [*patch*](struct.RemarketingListSharePatchCall.html) and [*update*](struct.RemarketingListShareUpdateCall.html) +//! * [remarketing lists](struct.RemarketingList.html) +//! * [*get*](struct.RemarketingListGetCall.html), [*insert*](struct.RemarketingListInsertCall.html), [*list*](struct.RemarketingListListCall.html), [*patch*](struct.RemarketingListPatchCall.html) and [*update*](struct.RemarketingListUpdateCall.html) +//! * [reports](struct.Report.html) +//! * [*compatible fields query*](struct.ReportCompatibleFieldQueryCall.html), [*delete*](struct.ReportDeleteCall.html), [*files get*](struct.ReportFileGetCall.html), [*files list*](struct.ReportFileListCall.html), [*get*](struct.ReportGetCall.html), [*insert*](struct.ReportInsertCall.html), [*list*](struct.ReportListCall.html), [*patch*](struct.ReportPatchCall.html), [*run*](struct.ReportRunCall.html) and [*update*](struct.ReportUpdateCall.html) +//! * [sites](struct.Site.html) +//! * [*get*](struct.SiteGetCall.html), [*insert*](struct.SiteInsertCall.html), [*list*](struct.SiteListCall.html), [*patch*](struct.SitePatchCall.html) and [*update*](struct.SiteUpdateCall.html) +//! * [sizes](struct.Size.html) +//! * [*get*](struct.SizeGetCall.html), [*insert*](struct.SizeInsertCall.html) and [*list*](struct.SizeListCall.html) +//! * [subaccounts](struct.Subaccount.html) +//! * [*get*](struct.SubaccountGetCall.html), [*insert*](struct.SubaccountInsertCall.html), [*list*](struct.SubaccountListCall.html), [*patch*](struct.SubaccountPatchCall.html) and [*update*](struct.SubaccountUpdateCall.html) +//! * [targetable remarketing lists](struct.TargetableRemarketingList.html) +//! * [*get*](struct.TargetableRemarketingListGetCall.html) and [*list*](struct.TargetableRemarketingListListCall.html) +//! * [user profiles](struct.UserProfile.html) +//! * [*get*](struct.UserProfileGetCall.html) and [*list*](struct.UserProfileListCall.html) +//! * [user role permission groups](struct.UserRolePermissionGroup.html) +//! * [*get*](struct.UserRolePermissionGroupGetCall.html) and [*list*](struct.UserRolePermissionGroupListCall.html) +//! * [user role permissions](struct.UserRolePermission.html) +//! * [*get*](struct.UserRolePermissionGetCall.html) and [*list*](struct.UserRolePermissionListCall.html) +//! * [user roles](struct.UserRole.html) +//! * [*delete*](struct.UserRoleDeleteCall.html), [*get*](struct.UserRoleGetCall.html), [*insert*](struct.UserRoleInsertCall.html), [*list*](struct.UserRoleListCall.html), [*patch*](struct.UserRolePatchCall.html) and [*update*](struct.UserRoleUpdateCall.html) +//! +//! +//! Upload supported by ... +//! +//! * [*insert creative assets*](struct.CreativeAssetInsertCall.html) +//! +//! Download supported by ... +//! +//! * [*get files*](struct.FileGetCall.html) +//! * [*files get reports*](struct.ReportFileGetCall.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.Dfareporting.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.reports().run(...).doit() +//! let r = hub.reports().get(...).doit() +//! let r = hub.reports().list(...).doit() +//! let r = hub.reports().delete(...).doit() +//! let r = hub.reports().files_list(...).doit() +//! let r = hub.reports().insert(...).doit() +//! let r = hub.reports().patch(...).doit() +//! let r = hub.reports().compatible_fields_query(...).doit() +//! let r = hub.reports().update(...).doit() +//! let r = hub.reports().files_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-dfareporting2d5 = "*" +//! ``` +//! +//! ## A complete example +//! +//! ```test_harness,no_run +//! extern crate hyper; +//! extern crate yup_oauth2 as oauth2; +//! extern crate google_dfareporting2d5 as dfareporting2d5; +//! use dfareporting2d5::{Result, Error}; +//! # #[test] fn egal() { +//! use std::default::Default; +//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +//! use dfareporting2d5::Dfareporting; +//! +//! // 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 = Dfareporting::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.reports().list("profileId") +//! .sort_order("kasd") +//! .sort_field("ipsum") +//! .scope("sadipscing") +//! .page_token("sea") +//! .max_results(-75) +//! .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/dfareporting2d5/src/lib.rs.in b/gen/dfareporting2d5/src/lib.rs.in new file mode 100644 index 0000000000..cff8329e89 --- /dev/null +++ b/gen/dfareporting2d5/src/lib.rs.in @@ -0,0 +1,67459 @@ +// 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 DoubleClick Campaign Manager's (DCM) display ad campaigns + Dfatrafficking, + + /// View and manage DoubleClick for Advertisers reports + Full, + + /// Manage DoubleClick Digital Marketing conversions + Ddmconversion, +} + +impl AsRef for Scope { + fn as_ref(&self) -> &str { + match *self { + Scope::Dfatrafficking => "https://www.googleapis.com/auth/dfatrafficking", + Scope::Full => "https://www.googleapis.com/auth/dfareporting", + Scope::Ddmconversion => "https://www.googleapis.com/auth/ddmconversions", + } + } +} + +impl Default for Scope { + fn default() -> Scope { + Scope::Full + } +} + + + +// ######## +// HUB ### +// ###### + +/// Central instance to access all Dfareporting related resource activities +/// +/// # Examples +/// +/// Instantiate a new hub +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::{Result, Error}; +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// // 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 = Dfareporting::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.reports().list("profileId") +/// .sort_order("accusam") +/// .sort_field("takimata") +/// .scope("justo") +/// .page_token("amet.") +/// .max_results(-81) +/// .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 Dfareporting { + client: RefCell, + auth: RefCell, + _user_agent: String, +} + +impl<'a, C, A> Hub for Dfareporting {} + +impl<'a, C, A> Dfareporting + where C: BorrowMut, A: oauth2::GetToken { + + pub fn new(client: C, authenticator: A) -> Dfareporting { + Dfareporting { + client: RefCell::new(client), + auth: RefCell::new(authenticator), + _user_agent: "google-api-rust-client/0.1.14".to_string(), + } + } + + pub fn account_active_ad_summaries(&'a self) -> AccountActiveAdSummaryMethods<'a, C, A> { + AccountActiveAdSummaryMethods { hub: &self } + } + pub fn account_permission_groups(&'a self) -> AccountPermissionGroupMethods<'a, C, A> { + AccountPermissionGroupMethods { hub: &self } + } + pub fn account_permissions(&'a self) -> AccountPermissionMethods<'a, C, A> { + AccountPermissionMethods { hub: &self } + } + pub fn account_user_profiles(&'a self) -> AccountUserProfileMethods<'a, C, A> { + AccountUserProfileMethods { hub: &self } + } + pub fn accounts(&'a self) -> AccountMethods<'a, C, A> { + AccountMethods { hub: &self } + } + pub fn ads(&'a self) -> AdMethods<'a, C, A> { + AdMethods { hub: &self } + } + pub fn advertiser_groups(&'a self) -> AdvertiserGroupMethods<'a, C, A> { + AdvertiserGroupMethods { hub: &self } + } + pub fn advertisers(&'a self) -> AdvertiserMethods<'a, C, A> { + AdvertiserMethods { hub: &self } + } + pub fn browsers(&'a self) -> BrowserMethods<'a, C, A> { + BrowserMethods { hub: &self } + } + pub fn campaign_creative_associations(&'a self) -> CampaignCreativeAssociationMethods<'a, C, A> { + CampaignCreativeAssociationMethods { hub: &self } + } + pub fn campaigns(&'a self) -> CampaignMethods<'a, C, A> { + CampaignMethods { hub: &self } + } + pub fn change_logs(&'a self) -> ChangeLogMethods<'a, C, A> { + ChangeLogMethods { hub: &self } + } + pub fn cities(&'a self) -> CityMethods<'a, C, A> { + CityMethods { hub: &self } + } + pub fn connection_types(&'a self) -> ConnectionTypeMethods<'a, C, A> { + ConnectionTypeMethods { hub: &self } + } + pub fn content_categories(&'a self) -> ContentCategoryMethods<'a, C, A> { + ContentCategoryMethods { hub: &self } + } + pub fn conversions(&'a self) -> ConversionMethods<'a, C, A> { + ConversionMethods { hub: &self } + } + pub fn countries(&'a self) -> CountryMethods<'a, C, A> { + CountryMethods { hub: &self } + } + pub fn creative_assets(&'a self) -> CreativeAssetMethods<'a, C, A> { + CreativeAssetMethods { hub: &self } + } + pub fn creative_field_values(&'a self) -> CreativeFieldValueMethods<'a, C, A> { + CreativeFieldValueMethods { hub: &self } + } + pub fn creative_fields(&'a self) -> CreativeFieldMethods<'a, C, A> { + CreativeFieldMethods { hub: &self } + } + pub fn creative_groups(&'a self) -> CreativeGroupMethods<'a, C, A> { + CreativeGroupMethods { hub: &self } + } + pub fn creatives(&'a self) -> CreativeMethods<'a, C, A> { + CreativeMethods { hub: &self } + } + pub fn dimension_values(&'a self) -> DimensionValueMethods<'a, C, A> { + DimensionValueMethods { hub: &self } + } + pub fn directory_site_contacts(&'a self) -> DirectorySiteContactMethods<'a, C, A> { + DirectorySiteContactMethods { hub: &self } + } + pub fn directory_sites(&'a self) -> DirectorySiteMethods<'a, C, A> { + DirectorySiteMethods { hub: &self } + } + pub fn dynamic_targeting_keys(&'a self) -> DynamicTargetingKeyMethods<'a, C, A> { + DynamicTargetingKeyMethods { hub: &self } + } + pub fn event_tags(&'a self) -> EventTagMethods<'a, C, A> { + EventTagMethods { hub: &self } + } + pub fn files(&'a self) -> FileMethods<'a, C, A> { + FileMethods { hub: &self } + } + pub fn floodlight_activities(&'a self) -> FloodlightActivityMethods<'a, C, A> { + FloodlightActivityMethods { hub: &self } + } + pub fn floodlight_activity_groups(&'a self) -> FloodlightActivityGroupMethods<'a, C, A> { + FloodlightActivityGroupMethods { hub: &self } + } + pub fn floodlight_configurations(&'a self) -> FloodlightConfigurationMethods<'a, C, A> { + FloodlightConfigurationMethods { hub: &self } + } + pub fn inventory_items(&'a self) -> InventoryItemMethods<'a, C, A> { + InventoryItemMethods { hub: &self } + } + pub fn landing_pages(&'a self) -> LandingPageMethods<'a, C, A> { + LandingPageMethods { hub: &self } + } + pub fn metros(&'a self) -> MetroMethods<'a, C, A> { + MetroMethods { hub: &self } + } + pub fn mobile_carriers(&'a self) -> MobileCarrierMethods<'a, C, A> { + MobileCarrierMethods { hub: &self } + } + pub fn operating_system_versions(&'a self) -> OperatingSystemVersionMethods<'a, C, A> { + OperatingSystemVersionMethods { hub: &self } + } + pub fn operating_systems(&'a self) -> OperatingSystemMethods<'a, C, A> { + OperatingSystemMethods { hub: &self } + } + pub fn order_documents(&'a self) -> OrderDocumentMethods<'a, C, A> { + OrderDocumentMethods { hub: &self } + } + pub fn orders(&'a self) -> OrderMethods<'a, C, A> { + OrderMethods { hub: &self } + } + pub fn placement_groups(&'a self) -> PlacementGroupMethods<'a, C, A> { + PlacementGroupMethods { hub: &self } + } + pub fn placement_strategies(&'a self) -> PlacementStrategyMethods<'a, C, A> { + PlacementStrategyMethods { hub: &self } + } + pub fn placements(&'a self) -> PlacementMethods<'a, C, A> { + PlacementMethods { hub: &self } + } + pub fn platform_types(&'a self) -> PlatformTypeMethods<'a, C, A> { + PlatformTypeMethods { hub: &self } + } + pub fn postal_codes(&'a self) -> PostalCodeMethods<'a, C, A> { + PostalCodeMethods { hub: &self } + } + pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { + ProjectMethods { hub: &self } + } + pub fn regions(&'a self) -> RegionMethods<'a, C, A> { + RegionMethods { hub: &self } + } + pub fn remarketing_list_shares(&'a self) -> RemarketingListShareMethods<'a, C, A> { + RemarketingListShareMethods { hub: &self } + } + pub fn remarketing_lists(&'a self) -> RemarketingListMethods<'a, C, A> { + RemarketingListMethods { hub: &self } + } + pub fn reports(&'a self) -> ReportMethods<'a, C, A> { + ReportMethods { hub: &self } + } + pub fn sites(&'a self) -> SiteMethods<'a, C, A> { + SiteMethods { hub: &self } + } + pub fn sizes(&'a self) -> SizeMethods<'a, C, A> { + SizeMethods { hub: &self } + } + pub fn subaccounts(&'a self) -> SubaccountMethods<'a, C, A> { + SubaccountMethods { hub: &self } + } + pub fn targetable_remarketing_lists(&'a self) -> TargetableRemarketingListMethods<'a, C, A> { + TargetableRemarketingListMethods { hub: &self } + } + pub fn user_profiles(&'a self) -> UserProfileMethods<'a, C, A> { + UserProfileMethods { hub: &self } + } + pub fn user_role_permission_groups(&'a self) -> UserRolePermissionGroupMethods<'a, C, A> { + UserRolePermissionGroupMethods { hub: &self } + } + pub fn user_role_permissions(&'a self) -> UserRolePermissionMethods<'a, C, A> { + UserRolePermissionMethods { hub: &self } + } + pub fn user_roles(&'a self) -> UserRoleMethods<'a, C, A> { + UserRoleMethods { 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 ### +// ########## +/// Operating System List Response +/// +/// # 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 operating systems](struct.OperatingSystemListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemsListResponse". + pub kind: Option, + /// Operating system collection. + #[serde(rename="operatingSystems")] + pub operating_systems: Option>, +} + +impl ResponseResult for OperatingSystemsListResponse {} + + +/// A Conversion represents when a user successfully performs a desired action after seeing an ad. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Conversion { + /// The ordinal of the conversion. Use this field to control how conversions of the same user and day are de-duplicated. This is a required field. + pub ordinal: Option, + /// The timestamp of conversion, in Unix epoch micros. This is a required field. + #[serde(rename="timestampMicros")] + pub timestamp_micros: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversion". + pub kind: Option, + /// Whether the conversion was directed toward children. + #[serde(rename="childDirectedTreatment")] + pub child_directed_treatment: Option, + /// The alphanumeric encrypted user ID. When set, encryptionInfo should also be specified. This field is mutually exclusive with encryptedUserIdCandidates[] and mobileDeviceId. This or encryptedUserIdCandidates[] or mobileDeviceId is a required field. + #[serde(rename="encryptedUserId")] + pub encrypted_user_id: Option, + /// Custom floodlight variables. + #[serde(rename="customVariables")] + pub custom_variables: Option>, + /// Floodlight Configuration ID of this conversion. This is a required field. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// The mobile device ID. This field is mutually exclusive with encryptedUserId and encryptedUserIdCandidates[]. This or encryptedUserId or encryptedUserIdCandidates[] is a required field. + #[serde(rename="mobileDeviceId")] + pub mobile_device_id: Option, + /// The value of the conversion. + pub value: Option, + /// Whether the user has Limit Ad Tracking set. + #[serde(rename="limitAdTracking")] + pub limit_ad_tracking: Option, + /// Floodlight Activity ID of this conversion. This is a required field. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// The quantity of the conversion. + pub quantity: Option, +} + +impl Resource for Conversion {} + + +/// Contains information about a mobile carrier that can be targeted by ads. +/// +/// # 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 mobile carriers](struct.MobileCarrierListCall.html) (none) +/// * [get mobile carriers](struct.MobileCarrierGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MobileCarrier { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarrier". + pub kind: Option, + /// DART ID of the country to which this mobile carrier belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// ID of this mobile carrier. + pub id: Option, + /// Country code of the country to which this mobile carrier belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Name of this mobile carrier. + pub name: Option, +} + +impl Resource for MobileCarrier {} +impl ResponseResult for MobileCarrier {} + + +/// Contains properties of a DCM subaccount. +/// +/// # 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 subaccounts](struct.SubaccountGetCall.html) (response) +/// * [update subaccounts](struct.SubaccountUpdateCall.html) (request|response) +/// * [patch subaccounts](struct.SubaccountPatchCall.html) (request|response) +/// * [list subaccounts](struct.SubaccountListCall.html) (none) +/// * [insert subaccounts](struct.SubaccountInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Subaccount { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccount". + pub kind: Option, + /// ID of the account that contains this subaccount. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// IDs of the available user role permissions for this subaccount. + #[serde(rename="availablePermissionIds")] + pub available_permission_ids: Option>, + /// ID of this subaccount. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this subaccount. This is a required field. Must be less than 128 characters long and be unique among subaccounts of the same account. + pub name: Option, +} + +impl RequestValue for Subaccount {} +impl Resource for Subaccount {} +impl ResponseResult for Subaccount {} + + +/// AccountPermissionGroups contains a mapping of permission group IDs to names. A permission group is a grouping of account permissions. +/// +/// # 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 account permission groups](struct.AccountPermissionGroupListCall.html) (none) +/// * [get account permission groups](struct.AccountPermissionGroupGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroup". + pub kind: Option, + /// ID of this account permission group. + pub id: Option, + /// Name of this account permission group. + pub name: Option, +} + +impl Resource for AccountPermissionGroup {} +impl ResponseResult for AccountPermissionGroup {} + + +/// Represents the list of DimensionValue 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValueList { + /// Continuation token used to page through dimension values. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The dimension values returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#dimensionValueList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for DimensionValueList {} + + +/// Campaign Creative Association List Response +/// +/// # 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 campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignCreativeAssociationsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Campaign creative association collection + #[serde(rename="campaignCreativeAssociations")] + pub campaign_creative_associations: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociationsListResponse". + pub kind: Option, +} + +impl ResponseResult for CampaignCreativeAssociationsListResponse {} + + +/// Directory Site Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteSettings { + /// Whether this site accepts interstitial ads. + #[serde(rename="interstitialPlacementAccepted")] + pub interstitial_placement_accepted: Option, + /// Whether this directory site has disabled Nielsen OCR reach ratings. + #[serde(rename="nielsenOcrOptOut")] + pub nielsen_ocr_opt_out: Option, + /// Whether this directory site has disabled active view creatives. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Whether this directory site has disabled active view for in-stream video creatives. + #[serde(rename="videoActiveViewOptOut")] + pub video_active_view_opt_out: Option, + /// Directory site DFP settings. + pub dfp_settings: Option, + /// Whether this directory site has disabled generation of Verification ins tags. + #[serde(rename="verificationTagOptOut")] + pub verification_tag_opt_out: Option, + /// Whether this site accepts in-stream video ads. + pub instream_video_placement_accepted: Option, +} + +impl Part for DirectorySiteSettings {} + + +/// User Role Permission Group List Response +/// +/// # 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 user role permission groups](struct.UserRolePermissionGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionGroupsListResponse { + /// User role permission group collection. + #[serde(rename="userRolePermissionGroups")] + pub user_role_permission_groups: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse". + pub kind: Option, +} + +impl ResponseResult for UserRolePermissionGroupsListResponse {} + + +/// Represents the list of File 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 files](struct.FileListCall.html) (response) +/// * [files list reports](struct.ReportFileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FileList { + /// Continuation token used to page through files. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The files returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#fileList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for FileList {} + + +/// Represents a Custom Rich Media Events group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CustomRichMediaEvents { + /// The kind of resource this is, in this case dfareporting#customRichMediaEvents. + pub kind: Option, + /// List of custom rich media event IDs. Dimension values must be all of type dfa:richMediaEventTypeIdAndName. + #[serde(rename="filteredEventIds")] + pub filtered_event_ids: Option>, +} + +impl Part for CustomRichMediaEvents {} + + +/// Event tag override information. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTagOverride { + /// Whether this override is enabled. + pub enabled: Option, + /// ID of this event tag override. This is a read-only, auto-generated field. + pub id: Option, +} + +impl Part for EventTagOverride {} + + +/// Change Log List Response +/// +/// # 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 change logs](struct.ChangeLogListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChangeLogsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLogsListResponse". + pub kind: Option, + /// Change log collection. + #[serde(rename="changeLogs")] + pub change_logs: Option>, +} + +impl ResponseResult for ChangeLogsListResponse {} + + +/// Gets a summary of active ads in an account. +/// +/// # 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 account active ad summaries](struct.AccountActiveAdSummaryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountActiveAdSummary { + /// Ads that can be activated for the account. + #[serde(rename="availableAds")] + pub available_ads: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountActiveAdSummary". + pub kind: Option, + /// ID of the account. + #[serde(rename="accountId")] + pub account_id: Option, + /// Ads that have been activated for the account + #[serde(rename="activeAds")] + pub active_ads: Option, + /// Maximum number of active ads allowed for the account. + #[serde(rename="activeAdsLimitTier")] + pub active_ads_limit_tier: Option, +} + +impl ResponseResult for AccountActiveAdSummary {} + + +/// Lookback configuration settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LookbackConfiguration { + /// Lookback window, in days, from the last time a given user clicked on one of your ads. If you enter 0, clicks will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. + #[serde(rename="clickDuration")] + pub click_duration: Option, + /// Lookback window, in days, from the last time a given user viewed one of your ads. If you enter 0, impressions will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. + #[serde(rename="postImpressionActivitiesDuration")] + pub post_impression_activities_duration: Option, +} + +impl Part for LookbackConfiguration {} + + +/// Floodlight Activity GenerateTag Response +/// +/// # 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*). +/// +/// * [generatetag floodlight activities](struct.FloodlightActivityGeneratetagCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivitiesGenerateTagResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesGenerateTagResponse". + pub kind: Option, + /// Generated tag for this floodlight activity. + #[serde(rename="floodlightActivityTag")] + pub floodlight_activity_tag: Option, +} + +impl ResponseResult for FloodlightActivitiesGenerateTagResponse {} + + +/// Remarketing List Population Rule Term. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationTerm { + /// ID of the list in question. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option, + /// Will be true if the term should check if the user is in the list and false if the term should check if the user is not in the list. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. False by default. + pub contains: Option, + /// Whether to negate the comparison result of this term during rule evaluation. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub negation: Option, + /// Literal to compare the variable to. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub value: Option, + /// Friendly name of this term's variable. This is a read-only, auto-generated field. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM. + #[serde(rename="variableFriendlyName")] + pub variable_friendly_name: Option, + /// Comparison operator of this term. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub operator: Option, + /// List population term type determines the applicable fields in this object. If left unset or set to CUSTOM_VARIABLE_TERM, then variableName, variableFriendlyName, operator, value, and negation are applicable. If set to LIST_MEMBERSHIP_TERM then remarketingListId and contains are applicable. If set to REFERRER_TERM then operator, value, and negation are applicable. + #[serde(rename="type")] + pub type_: Option, + /// Name of the variable (U1, U2, etc.) being compared in this term. This field is only relevant when type is set to null, CUSTOM_VARIABLE_TERM or REFERRER_TERM. + #[serde(rename="variableName")] + pub variable_name: Option, +} + +impl Part for ListPopulationTerm {} + + +/// Site Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SiteSettings { + /// Whether brand safe ads are disabled for this site. + #[serde(rename="disableBrandSafeAds")] + pub disable_brand_safe_ads: Option, + /// Site-wide creative settings. + #[serde(rename="creativeSettings")] + pub creative_settings: Option, + /// Whether active view creatives are disabled for this site. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Lookback window settings for this site. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Whether new cookies are disabled for this site. + #[serde(rename="disableNewCookie")] + pub disable_new_cookie: Option, + /// Whether Verification and ActiveView are disabled for in-stream video creatives on this site. The same setting videoActiveViewOptOut exists on the directory site level -- the opt out occurs if either of these settings are true. These settings are distinct from DirectorySites.settings.activeViewOptOut or Sites.siteSettings.activeViewOptOut which only apply to display ads. However, Accounts.activeViewOptOut opts out both video traffic, as well as display ads, from Verification and ActiveView. + #[serde(rename="videoActiveViewOptOut")] + pub video_active_view_opt_out: Option, + /// Configuration settings for dynamic and image floodlight tags. + #[serde(rename="tagSetting")] + pub tag_setting: Option, +} + +impl Part for SiteSettings {} + + +/// AccountUserProfiles contains properties of a DCM user profile. This resource is specifically for managing user profiles, whereas UserProfiles is for accessing the API. +/// +/// # 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 account user profiles](struct.AccountUserProfilePatchCall.html) (request|response) +/// * [list account user profiles](struct.AccountUserProfileListCall.html) (none) +/// * [insert account user profiles](struct.AccountUserProfileInsertCall.html) (request|response) +/// * [get account user profiles](struct.AccountUserProfileGetCall.html) (response) +/// * [update account user profiles](struct.AccountUserProfileUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountUserProfile { + /// Locale of the user profile. This is a required field. + /// Acceptable values are: + /// - "cs" (Czech) + /// - "de" (German) + /// - "en" (English) + /// - "en-GB" (English United Kingdom) + /// - "es" (Spanish) + /// - "fr" (French) + /// - "it" (Italian) + /// - "ja" (Japanese) + /// - "ko" (Korean) + /// - "pl" (Polish) + /// - "pt-BR" (Portuguese Brazil) + /// - "ru" (Russian) + /// - "sv" (Swedish) + /// - "tr" (Turkish) + /// - "zh-CN" (Chinese Simplified) + /// - "zh-TW" (Chinese Traditional) + pub locale: Option, + /// Filter that describes which sites are visible to the user profile. + #[serde(rename="siteFilter")] + pub site_filter: Option, + /// Filter that describes which campaigns are visible to the user profile. + #[serde(rename="campaignFilter")] + pub campaign_filter: Option, + /// User role ID of the user profile. This is a required field. + #[serde(rename="userRoleId")] + pub user_role_id: Option, + /// User type of the user profile. This is a read-only field that can be left blank. + #[serde(rename="userAccessType")] + pub user_access_type: Option, + /// Whether this user profile is active. This defaults to false, and must be set true on insert for the user profile to be usable. + pub active: Option, + /// ID of the user profile. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of the user profile. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfile". + pub kind: Option, + /// Subaccount ID of the user profile. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Filter that describes which user roles are visible to the user profile. + #[serde(rename="userRoleFilter")] + pub user_role_filter: Option, + /// Trafficker type of this user profile. + #[serde(rename="traffickerType")] + pub trafficker_type: Option, + /// Comments for this user profile. + pub comments: Option, + /// Name of the user profile. This is a required field. Must be less than 64 characters long, must be globally unique, and cannot contain whitespace or any of the following characters: "&;"#%,". + pub name: Option, + /// Filter that describes which advertisers are visible to the user profile. + #[serde(rename="advertiserFilter")] + pub advertiser_filter: Option, + /// Email of the user profile. The email addresss must be linked to a Google Account. This field is required on insertion and is read-only after insertion. + pub email: Option, +} + +impl RequestValue for AccountUserProfile {} +impl Resource for AccountUserProfile {} +impl ResponseResult for AccountUserProfile {} + + +/// Dynamic and Image Tag Settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagSettings { + /// Whether dynamic floodlight tags are enabled. + #[serde(rename="dynamicTagEnabled")] + pub dynamic_tag_enabled: Option, + /// Whether image tags are enabled. + #[serde(rename="imageTagEnabled")] + pub image_tag_enabled: Option, +} + +impl Part for TagSettings {} + + +/// Contains properties of a targetable remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource is a read-only view of a remarketing list to be used to faciliate targeting ads to specific lists. Remarketing lists that are owned by your advertisers and those that are shared to your advertisers or account are accessible via this resource. To manage remarketing lists that are owned by your advertisers, use the RemarketingLists 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 targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (none) +/// * [get targetable remarketing lists](struct.TargetableRemarketingListGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingList { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingList". + pub kind: Option, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Targetable remarketing list description. + pub description: Option, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option, + /// Number of days that a user should remain in the targetable remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option, + /// Dimension value for the advertiser ID that owns this targetable remarketing list. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Product from which this targetable remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option, + /// Whether this targetable remarketing list is active. + pub active: Option, + /// Dimension value for the ID of the advertiser. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option, + /// Targetable remarketing list ID. + pub id: Option, + /// Name of the targetable remarketing list. Is no greater than 128 characters long. + pub name: Option, +} + +impl Resource for TargetableRemarketingList {} +impl ResponseResult for TargetableRemarketingList {} + + +/// Contains information about a particular version of an operating system that can be targeted by ads. +/// +/// # 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 operating system versions](struct.OperatingSystemVersionGetCall.html) (response) +/// * [list operating system versions](struct.OperatingSystemVersionListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemVersion { + /// Major version (leftmost number) of this operating system version. + #[serde(rename="majorVersion")] + pub major_version: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersion". + pub kind: Option, + /// Minor version (number after the first dot) of this operating system version. + #[serde(rename="minorVersion")] + pub minor_version: Option, + /// Name of this operating system version. + pub name: Option, + /// Operating system of this operating system version. + #[serde(rename="operatingSystem")] + pub operating_system: Option, + /// ID of this operating system version. + pub id: Option, +} + +impl Resource for OperatingSystemVersion {} +impl ResponseResult for OperatingSystemVersion {} + + +/// Remarketing list response +/// +/// # 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 remarketing lists](struct.RemarketingListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Remarketing list collection. + #[serde(rename="remarketingLists")] + pub remarketing_lists: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListsListResponse". + pub kind: Option, +} + +impl ResponseResult for RemarketingListsListResponse {} + + +/// Creative Field Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldAssignment { + /// ID of the creative field. + #[serde(rename="creativeFieldId")] + pub creative_field_id: Option, + /// ID of the creative field value. + #[serde(rename="creativeFieldValueId")] + pub creative_field_value_id: Option, +} + +impl Part for CreativeFieldAssignment {} + + +/// Remarketing List Population Rule. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationRule { + /// Floodlight activity ID associated with this rule. This field can be left blank. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// Name of floodlight activity associated with this rule. This is a read-only, auto-generated field. + #[serde(rename="floodlightActivityName")] + pub floodlight_activity_name: Option, + /// Clauses that make up this list population rule. Clauses are joined by ANDs, and the clauses themselves are made up of list population terms which are joined by ORs. + #[serde(rename="listPopulationClauses")] + pub list_population_clauses: Option>, +} + +impl Part for ListPopulationRule {} + + +/// Contains properties of a DCM account. +/// +/// # 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 accounts](struct.AccountUpdateCall.html) (request|response) +/// * [list accounts](struct.AccountListCall.html) (none) +/// * [get accounts](struct.AccountGetCall.html) (response) +/// * [patch accounts](struct.AccountPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Account { + /// File size limit in kilobytes of Rich Media teaser creatives. Must be between 1 and 10240. + #[serde(rename="teaserSizeLimit")] + pub teaser_size_limit: Option, + /// Whether to serve creatives with Active View tags. If disabled, viewability data will not be available for any impressions. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Description of this account. + pub description: Option, + /// Locale of this account. + /// Acceptable values are: + /// - "cs" (Czech) + /// - "de" (German) + /// - "en" (English) + /// - "en-GB" (English United Kingdom) + /// - "es" (Spanish) + /// - "fr" (French) + /// - "it" (Italian) + /// - "ja" (Japanese) + /// - "ko" (Korean) + /// - "pl" (Polish) + /// - "pt-BR" (Portuguese Brazil) + /// - "ru" (Russian) + /// - "sv" (Swedish) + /// - "tr" (Turkish) + /// - "zh-CN" (Chinese Simplified) + /// - "zh-TW" (Chinese Traditional) + pub locale: Option, + /// Profile for this account. This is a read-only field that can be left blank. + #[serde(rename="accountProfile")] + pub account_profile: Option, + /// Whether this account is active. + pub active: Option, + /// Whether campaigns created in this account will be enabled for comScore vCE by default. + #[serde(rename="comscoreVceEnabled")] + pub comscore_vce_enabled: Option, + /// ID of this account. This is a read-only, auto-generated field. + pub id: Option, + /// User role permissions available to the user roles of this account. + #[serde(rename="availablePermissionIds")] + pub available_permission_ids: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#account". + pub kind: Option, + /// ID of the country associated with this account. + #[serde(rename="countryId")] + pub country_id: Option, + /// Name of this account. This is a required field, and must be less than 128 characters long and be globally unique. + pub name: Option, + /// Maximum image size allowed for this account. + #[serde(rename="maximumImageSize")] + pub maximum_image_size: Option, + /// Whether campaigns created in this account will be enabled for Nielsen OCR reach ratings by default. + #[serde(rename="nielsenOcrEnabled")] + pub nielsen_ocr_enabled: Option, + /// Default placement dimensions for this account. + #[serde(rename="defaultCreativeSizeId")] + pub default_creative_size_id: Option, + /// Account permissions assigned to this account. + #[serde(rename="accountPermissionIds")] + pub account_permission_ids: Option>, + /// ID of currency associated with this account. This is a required field. + /// Acceptable values are: + /// - "1" for USD + /// - "2" for GBP + /// - "3" for ESP + /// - "4" for SEK + /// - "5" for CAD + /// - "6" for JPY + /// - "7" for DEM + /// - "8" for AUD + /// - "9" for FRF + /// - "10" for ITL + /// - "11" for DKK + /// - "12" for NOK + /// - "13" for FIM + /// - "14" for ZAR + /// - "15" for IEP + /// - "16" for NLG + /// - "17" for EUR + /// - "18" for KRW + /// - "19" for TWD + /// - "20" for SGD + /// - "21" for CNY + /// - "22" for HKD + /// - "23" for NZD + /// - "24" for MYR + /// - "25" for BRL + /// - "26" for PTE + /// - "27" for MXP + /// - "28" for CLP + /// - "29" for TRY + /// - "30" for ARS + /// - "31" for PEN + /// - "32" for ILS + /// - "33" for CHF + /// - "34" for VEF + /// - "35" for COP + /// - "36" for GTQ + /// - "37" for PLN + /// - "39" for INR + /// - "40" for THB + /// - "41" for IDR + /// - "42" for CZK + /// - "43" for RON + /// - "44" for HUF + /// - "45" for RUB + /// - "46" for AED + /// - "47" for BGN + /// - "48" for HRK + #[serde(rename="currencyId")] + pub currency_id: Option, + /// Reporting configuration of this account. + #[serde(rename="reportsConfiguration")] + pub reports_configuration: Option, + /// Maximum number of active ads allowed for this account. + #[serde(rename="activeAdsLimitTier")] + pub active_ads_limit_tier: Option, +} + +impl RequestValue for Account {} +impl Resource for Account {} +impl ResponseResult for Account {} + + +/// Day Part Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DayPartTargeting { + /// Days of the week when the ad will serve. + /// + /// Acceptable values are: + /// - "SUNDAY" + /// - "MONDAY" + /// - "TUESDAY" + /// - "WEDNESDAY" + /// - "THURSDAY" + /// - "FRIDAY" + /// - "SATURDAY" + #[serde(rename="daysOfWeek")] + pub days_of_week: Option>, + /// Hours of the day when the ad will serve. Must be an integer between 0 and 23 (inclusive), where 0 is midnight to 1 AM, and 23 is 11 PM to midnight. Can be specified with days of week, in which case the ad would serve during these hours on the specified days. For example, if Monday, Wednesday, Friday are the days of week specified and 9-10am, 3-5pm (hours 9, 15, and 16) is specified, the ad would serve Monday, Wednesdays, and Fridays at 9-10am and 3-5pm. + #[serde(rename="hoursOfDay")] + pub hours_of_day: Option>, + /// Whether or not to use the user's local time. If false, the America/New York time zone applies. + #[serde(rename="userLocalTime")] + pub user_local_time: Option, +} + +impl Part for DayPartTargeting {} + + +/// Represents a response to the queryCompatibleFields method. +/// +/// # 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*). +/// +/// * [compatible fields query reports](struct.ReportCompatibleFieldQueryCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CompatibleFields { + /// The kind of resource this is, in this case dfareporting#compatibleFields. + pub kind: Option, + /// Contains items that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". + #[serde(rename="crossDimensionReachReportCompatibleFields")] + pub cross_dimension_reach_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "REACH". + #[serde(rename="reachReportCompatibleFields")] + pub reach_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "PATH_TO_CONVERSION". + #[serde(rename="pathToConversionReportCompatibleFields")] + pub path_to_conversion_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "FLOODLIGHT". + #[serde(rename="floodlightReportCompatibleFields")] + pub floodlight_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "STANDARD". + #[serde(rename="reportCompatibleFields")] + pub report_compatible_fields: Option, +} + +impl ResponseResult for CompatibleFields {} + + +/// Contains information about a region that can be targeted by ads. +/// +/// # 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) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Region { + /// Region code. + #[serde(rename="regionCode")] + pub region_code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#region". + pub kind: Option, + /// DART ID of the country to which this region belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this region. + pub name: Option, + /// Country code of the country to which this region belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// DART ID of this region. + #[serde(rename="dartId")] + pub dart_id: Option, +} + +impl Resource for Region {} + + +/// The report criteria for a report of type "STANDARD". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCriteria { + /// Activity group. + pub activities: Option, + /// The list of standard dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range for which this report should be run. + #[serde(rename="dateRange")] + pub date_range: Option, + /// Custom Rich Media Events group. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl NestedType for ReportCriteria {} +impl Part for ReportCriteria {} + + +/// Order List Response +/// +/// # 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 orders](struct.OrderListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrdersListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ordersListResponse". + pub kind: Option, + /// Order collection. + pub orders: Option>, +} + +impl ResponseResult for OrdersListResponse {} + + +/// Represents fields that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CrossDimensionReachReportCompatibleFields { + /// Dimensions which are compatible to be selected in the "breakdown" section of the report. + pub breakdown: Option>, + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#crossDimensionReachReportCompatibleFields. + pub kind: Option, + /// Metrics which are compatible to be selected in the "overlapMetricNames" section of the report. + #[serde(rename="overlapMetrics")] + pub overlap_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl Part for CrossDimensionReachReportCompatibleFields {} + + +/// The error code and description for a conversion that failed to insert or update. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionError { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionError". + pub kind: Option, + /// The error code. + pub code: Option, + /// A description of the error. + pub message: Option, +} + +impl Part for ConversionError {} + + +/// Event Tag List Response +/// +/// # 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 event tags](struct.EventTagListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTagsListResponse { + /// Event tag collection. + #[serde(rename="eventTags")] + pub event_tags: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTagsListResponse". + pub kind: Option, +} + +impl ResponseResult for EventTagsListResponse {} + + +/// Contains properties of a Floodlight activity group. +/// +/// # 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 floodlight activity groups](struct.FloodlightActivityGroupListCall.html) (none) +/// * [get floodlight activity groups](struct.FloodlightActivityGroupGetCall.html) (response) +/// * [insert floodlight activity groups](struct.FloodlightActivityGroupInsertCall.html) (request|response) +/// * [patch floodlight activity groups](struct.FloodlightActivityGroupPatchCall.html) (request|response) +/// * [update floodlight activity groups](struct.FloodlightActivityGroupUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroup". + pub kind: Option, + /// Subaccount ID of this floodlight activity group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this floodlight activity group. This is a required field. Must be less than 65 characters long and cannot contain quotes. + pub name: Option, + /// Floodlight configuration ID of this floodlight activity group. This is a required field. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// Advertiser ID of this floodlight activity group. If this field is left blank, the value will be copied over either from the floodlight configuration's advertiser or from the existing activity group's advertiser. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Dimension value for the ID of this floodlight activity group. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Value of the type= parameter in the floodlight tag, which the ad servers use to identify the activity group that the activity belongs to. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activity groups of the same floodlight configuration. This field is read-only after insertion. + #[serde(rename="tagString")] + pub tag_string: Option, + /// Type of the floodlight activity group. This is a required field that is read-only after insertion. + #[serde(rename="type")] + pub type_: Option, + /// ID of this floodlight activity group. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this floodlight activity group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for FloodlightActivityGroup {} +impl Resource for FloodlightActivityGroup {} +impl ResponseResult for FloodlightActivityGroup {} + + +/// Audience Segment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AudienceSegment { + /// Weight allocated to this segment. Must be between 1 and 1000. The weight assigned will be understood in proportion to the weights assigned to other segments in the same segment group. + pub allocation: Option, + /// ID of this audience segment. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this audience segment. This is a required field and must be less than 65 characters long. + pub name: Option, +} + +impl Part for AudienceSegment {} + + +/// Contains properties of a DCM campaign. +/// +/// # 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 campaigns](struct.CampaignInsertCall.html) (request|response) +/// * [update campaigns](struct.CampaignUpdateCall.html) (request|response) +/// * [patch campaigns](struct.CampaignPatchCall.html) (request|response) +/// * [get campaigns](struct.CampaignGetCall.html) (response) +/// * [list campaigns](struct.CampaignListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Campaign { + /// Arbitrary comments about this campaign. Must be less than 256 characters long. + pub comment: Option, + /// Date on which the campaign starts running. The start date can be any date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This is a required field. + #[serde(rename="startDate")] + pub start_date: Option, + /// Date on which the campaign will stop running. On insert, the end date must be today or a future date. The end date must be later than or be the same as the start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective campaign run date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This is a required field. + #[serde(rename="endDate")] + pub end_date: Option, + /// Click-through URL suffix override properties for this campaign. + #[serde(rename="clickThroughUrlSuffixProperties")] + pub click_through_url_suffix_properties: Option, + /// Whether this campaign has been archived. + pub archived: Option, + /// Additional creative optimization configurations for the campaign. + #[serde(rename="additionalCreativeOptimizationConfigurations")] + pub additional_creative_optimization_configurations: Option>, + /// Advertiser ID of this campaign. This is a required field. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Audience segment groups assigned to this campaign. Cannot have more than 300 segment groups. + #[serde(rename="audienceSegmentGroups")] + pub audience_segment_groups: Option>, + /// Information about the creation of this campaign. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Click-through event tag ID override properties for this campaign. + #[serde(rename="defaultClickThroughEventTagProperties")] + pub default_click_through_event_tag_properties: Option, + /// Dimension value for the advertiser ID of this campaign. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Overrides that can be used to activate or deactivate advertiser event tags. + #[serde(rename="eventTagOverrides")] + pub event_tag_overrides: Option>, + /// Creative optimization configuration for the campaign. + #[serde(rename="creativeOptimizationConfiguration")] + pub creative_optimization_configuration: Option, + /// ID of this campaign. This is a read-only auto-generated field. + pub id: Option, + /// Account ID of this campaign. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Campaign trafficker contact emails. + #[serde(rename="traffickerEmails")] + pub trafficker_emails: Option>, + /// List of creative group IDs that are assigned to the campaign. + #[serde(rename="creativeGroupIds")] + pub creative_group_ids: Option>, + /// Subaccount ID of this campaign. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this campaign. This is a required field and must be less than 256 characters long and unique among campaigns of the same advertiser. + pub name: Option, + /// Lookback window settings for the campaign. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Whether Nielsen reports are enabled for this campaign. + #[serde(rename="nielsenOcrEnabled")] + pub nielsen_ocr_enabled: Option, + /// Information about the most recent modification of this campaign. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Whether comScore vCE reports are enabled for this campaign. + #[serde(rename="comscoreVceEnabled")] + pub comscore_vce_enabled: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaign". + pub kind: Option, + /// External ID for this campaign. + #[serde(rename="externalId")] + pub external_id: Option, + /// Advertiser group ID of the associated advertiser. + #[serde(rename="advertiserGroupId")] + pub advertiser_group_id: Option, + /// Dimension value for the ID of this campaign. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Billing invoice code included in the DCM client billing invoices associated with the campaign. + #[serde(rename="billingInvoiceCode")] + pub billing_invoice_code: Option, +} + +impl RequestValue for Campaign {} +impl Resource for Campaign {} +impl ResponseResult for Campaign {} + + +/// Describes a change that a user has made to a 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 change logs](struct.ChangeLogListCall.html) (none) +/// * [get change logs](struct.ChangeLogGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChangeLog { + /// Time when the object was modified. + #[serde(rename="changeTime")] + pub change_time: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLog". + pub kind: Option, + /// Subaccount ID of the modified object. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Old value of the object field. + #[serde(rename="oldValue")] + pub old_value: Option, + /// ID of the object of this change log. The object could be a campaign, placement, ad, or other type. + #[serde(rename="objectId")] + pub object_id: Option, + /// ID of this change log. + pub id: Option, + /// User profile name of the user who modified the object. + #[serde(rename="userProfileName")] + pub user_profile_name: Option, + /// Field name of the object which changed. + #[serde(rename="fieldName")] + pub field_name: Option, + /// ID of the user who modified the object. + #[serde(rename="userProfileId")] + pub user_profile_id: Option, + /// Action which caused the change. + pub action: Option, + /// Transaction ID of this change log. When a single API call results in many changes, each change will have a separate ID in the change log but will share the same transactionId. + #[serde(rename="transactionId")] + pub transaction_id: Option, + /// Account ID of the modified object. + #[serde(rename="accountId")] + pub account_id: Option, + /// New value of the object field. + #[serde(rename="newValue")] + pub new_value: Option, + /// Object type of the change log. + #[serde(rename="objectType")] + pub object_type: Option, +} + +impl Resource for ChangeLog {} +impl ResponseResult for ChangeLog {} + + +/// Represents a File resource. A file contains the metadata for a report run. It shows the status of the run and holds the URLs to the generated report data if the run is finished and the status is "REPORT_AVAILABLE". +/// +/// # 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 files](struct.FileGetCall.html) (response) +/// * [list files](struct.FileListCall.html) (none) +/// * [files get reports](struct.ReportFileGetCall.html) (response) +/// * [run reports](struct.ReportRunCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct File { + /// The status of the report file. + pub status: Option, + /// The kind of resource this is, in this case dfareporting#file. + pub kind: Option, + /// The output format of the report. Only available once the file is available. + pub format: Option, + /// The date range for which the file has report data. The date range will always be the absolute date range for which the report is run. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The filename of the file. + #[serde(rename="fileName")] + pub file_name: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The ID of the report this file was generated from. + #[serde(rename="reportId")] + pub report_id: Option, + /// The URLs where the completed report file can be downloaded. + pub urls: Option, + /// The timestamp in milliseconds since epoch when this file was last modified. + #[serde(rename="lastModifiedTime")] + pub last_modified_time: Option, + /// The unique ID of this report file. + pub id: Option, +} + +impl Resource for File {} +impl ResponseResult for File {} + + +/// Key Value Targeting Expression. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct KeyValueTargetingExpression { + /// Keyword expression being targeted by the ad. + pub expression: Option, +} + +impl Part for KeyValueTargetingExpression {} + + +/// The report criteria for a report of type "CROSS_DIMENSION_REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCrossDimensionReachCriteria { + /// The list of dimensions the report should include. + pub breakdown: Option>, + /// Whether the report is pivoted or not. Defaults to true. + pub pivoted: Option, + /// The list of names of overlap metrics the report should include. + #[serde(rename="overlapMetricNames")] + pub overlap_metric_names: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of filters on which dimensions are filtered. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The dimension option. + pub dimension: Option, +} + +impl NestedType for ReportCrossDimensionReachCriteria {} +impl Part for ReportCrossDimensionReachCriteria {} + + +/// Contains properties of a placement. +/// +/// # 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*). +/// +/// * [generatetags placements](struct.PlacementGeneratetagCall.html) (none) +/// * [insert placements](struct.PlacementInsertCall.html) (request|response) +/// * [update placements](struct.PlacementUpdateCall.html) (request|response) +/// * [list placements](struct.PlacementListCall.html) (none) +/// * [get placements](struct.PlacementGetCall.html) (response) +/// * [patch placements](struct.PlacementPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Placement { + /// Comments for this placement. + pub comment: Option, + /// Campaign ID of this placement. This field is a required field on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Payment source for this placement. This is a required field that is read-only after insertion. + #[serde(rename="paymentSource")] + pub payment_source: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Advertiser ID of this placement. This field can be left blank. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Key name of this placement. This is a read-only, auto-generated field. + #[serde(rename="keyName")] + pub key_name: Option, + /// Directory site ID of this placement. On insert, you must set either this field or the siteId field to specify the site associated with this placement. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of the content category assigned to this placement. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// Size associated with this placement. When inserting or updating a placement, only the size ID field is used. This field is required on insertion. + pub size: Option, + /// Whether this placement is archived. + pub archived: Option, + /// Information about the last publisher update. This is a read-only field. + #[serde(rename="publisherUpdateInfo")] + pub publisher_update_info: Option, + /// Tag formats to generate for this placement. This field is required on insertion. + /// Acceptable values are: + /// - "PLACEMENT_TAG_STANDARD" + /// - "PLACEMENT_TAG_IFRAME_JAVASCRIPT" + /// - "PLACEMENT_TAG_IFRAME_ILAYER" + /// - "PLACEMENT_TAG_INTERNAL_REDIRECT" + /// - "PLACEMENT_TAG_JAVASCRIPT" + /// - "PLACEMENT_TAG_INTERSTITIAL_IFRAME_JAVASCRIPT" + /// - "PLACEMENT_TAG_INTERSTITIAL_INTERNAL_REDIRECT" + /// - "PLACEMENT_TAG_INTERSTITIAL_JAVASCRIPT" + /// - "PLACEMENT_TAG_CLICK_COMMANDS" + /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH" + /// - "PLACEMENT_TAG_TRACKING" + /// - "PLACEMENT_TAG_TRACKING_IFRAME" + /// - "PLACEMENT_TAG_TRACKING_JAVASCRIPT" + #[serde(rename="tagFormats")] + pub tag_formats: Option>, + /// Whether payment was approved for this placement. This is a read-only field relevant only to publisher-paid placements. + #[serde(rename="paymentApproved")] + pub payment_approved: Option, + /// Tag settings for this placement. + #[serde(rename="tagSetting")] + pub tag_setting: Option, + /// ID of this placement. This is a read-only, auto-generated field. + pub id: Option, + /// External ID for this placement. + #[serde(rename="externalId")] + pub external_id: Option, + /// Dimension value for the ID of this placement. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Account ID of this placement. This field can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Whether creatives assigned to this placement must be SSL-compliant. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Third-party placement status. + pub status: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Whether this placement is the primary placement of a roadblock (placement group). You cannot change this field from true to false. Setting this field to true will automatically set the primary field on the original primary placement of the roadblock to false, and it will automatically set the roadblock's primaryPlacementId field to the ID of this placement. + pub primary: Option, + /// ID of this placement's group, if applicable. + #[serde(rename="placementGroupId")] + pub placement_group_id: Option, + /// Information about the creation of this placement. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Site ID associated with this placement. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement. This is a required field that is read-only after insertion. + #[serde(rename="siteId")] + pub site_id: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Placement compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering on desktop, on mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are no longer allowed for new placement insertions. Instead, use DISPLAY or DISPLAY_INTERSTITIAL. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. This field is required on insertion. + pub compatibility: Option, + /// ID of the placement strategy assigned to this placement. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Dimension value for the ID of the placement group. This is a read-only, auto-generated field. + #[serde(rename="placementGroupIdDimensionValue")] + pub placement_group_id_dimension_value: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placement". + pub kind: Option, + /// Subaccount ID of this placement. This field can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this placement.This is a required field and must be less than 256 characters long. + pub name: Option, + /// Lookback window settings for this placement. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Information about the most recent modification of this placement. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Pricing schedule of this placement. This field is required on insertion, specifically subfields startDate, endDate and pricingType. + #[serde(rename="pricingSchedule")] + pub pricing_schedule: Option, +} + +impl RequestValue for Placement {} +impl Resource for Placement {} +impl ResponseResult for Placement {} + + +/// Inventory item List Response +/// +/// # 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 inventory items](struct.InventoryItemListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItemsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItemsListResponse". + pub kind: Option, + /// Inventory item collection + #[serde(rename="inventoryItems")] + pub inventory_items: Option>, +} + +impl ResponseResult for InventoryItemsListResponse {} + + +/// Audience Segment Group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AudienceSegmentGroup { + /// Audience segments assigned to this group. The number of segments must be between 2 and 100. + #[serde(rename="audienceSegments")] + pub audience_segments: Option>, + /// ID of this audience segment group. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this audience segment group. This is a required field and must be less than 65 characters long. + pub name: Option, +} + +impl Part for AudienceSegmentGroup {} + + +/// Contains properties of a placement strategy. +/// +/// # 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 placement strategies](struct.PlacementStrategyPatchCall.html) (request|response) +/// * [insert placement strategies](struct.PlacementStrategyInsertCall.html) (request|response) +/// * [get placement strategies](struct.PlacementStrategyGetCall.html) (response) +/// * [update placement strategies](struct.PlacementStrategyUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementStrategy { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy". + pub kind: Option, + /// Account ID of this placement strategy.This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this placement strategy. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this placement strategy. This is a required field. It must be less than 256 characters long and unique among placement strategies of the same account. + pub name: Option, +} + +impl RequestValue for PlacementStrategy {} +impl ResponseResult for PlacementStrategy {} + + +/// Creative optimization activity. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OptimizationActivity { + /// Floodlight activity ID of this optimization activity. This is a required field. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// Dimension value for the ID of the floodlight activity. This is a read-only, auto-generated field. + #[serde(rename="floodlightActivityIdDimensionValue")] + pub floodlight_activity_id_dimension_value: Option, + /// Weight associated with this optimization. Must be greater than 1. The weight assigned will be understood in proportion to the weights assigned to the other optimization activities. + pub weight: Option, +} + +impl Part for OptimizationActivity {} + + +/// Placement Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementTag { + /// Tags generated for this placement. + #[serde(rename="tagDatas")] + pub tag_datas: Option>, + /// Placement ID + #[serde(rename="placementId")] + pub placement_id: Option, +} + +impl Part for PlacementTag {} + + +/// Country List Response +/// +/// # 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 countries](struct.CountryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CountriesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse". + pub kind: Option, + /// Country collection. + pub countries: Option>, +} + +impl ResponseResult for CountriesListResponse {} + + +/// Click-through 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 ClickThroughUrl { + /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows: + /// - If defaultLandingPage is enabled then the campaign's default landing page URL is assigned to this field. + /// - If defaultLandingPage is not enabled and a landingPageId is specified then that landing page's URL is assigned to this field. + /// - If neither of the above cases apply, then the customClickThroughUrl is assigned to this field. + #[serde(rename="computedClickThroughUrl")] + pub computed_click_through_url: Option, + /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset. + #[serde(rename="customClickThroughUrl")] + pub custom_click_through_url: Option, + /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false. + #[serde(rename="landingPageId")] + pub landing_page_id: Option, + /// Whether the campaign default landing page is used. + #[serde(rename="defaultLandingPage")] + pub default_landing_page: Option, +} + +impl Part for ClickThroughUrl {} + + +/// Companion Click-through override. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CompanionClickThroughOverride { + /// Click-through URL of this companion click-through override. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// ID of the creative for this companion click-through override. + #[serde(rename="creativeId")] + pub creative_id: Option, +} + +impl Part for CompanionClickThroughOverride {} + + +/// Frequency Cap. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FrequencyCap { + /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days in seconds, or 7,776,000. + pub duration: Option, + /// Number of times an individual user can be served the ad within the specified duration. The maximum allowed is 15. + pub impressions: Option, +} + +impl Part for FrequencyCap {} + + +/// Identifies a creative which has been associated with a given campaign. +/// +/// # 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 campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (none) +/// * [insert campaign creative associations](struct.CampaignCreativeAssociationInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignCreativeAssociation { + /// ID of the creative associated with the campaign. This is a required field. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation". + pub kind: Option, +} + +impl RequestValue for CampaignCreativeAssociation {} +impl Resource for CampaignCreativeAssociation {} +impl ResponseResult for CampaignCreativeAssociation {} + + +/// Contains properties of a remarketing list's sharing information. Sharing allows other accounts or advertisers to target to your remarketing lists. This resource can be used to manage remarketing list sharing to other accounts and advertisers. +/// +/// # 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 remarketing list shares](struct.RemarketingListShareGetCall.html) (response) +/// * [patch remarketing list shares](struct.RemarketingListSharePatchCall.html) (request|response) +/// * [update remarketing list shares](struct.RemarketingListShareUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingListShare { + /// Advertisers that the remarketing list is shared with. + #[serde(rename="sharedAdvertiserIds")] + pub shared_advertiser_ids: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListShare". + pub kind: Option, + /// Remarketing list ID. This is a read-only, auto-generated field. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option, + /// Accounts that the remarketing list is shared with. + #[serde(rename="sharedAccountIds")] + pub shared_account_ids: Option>, +} + +impl RequestValue for RemarketingListShare {} +impl Resource for RemarketingListShare {} +impl ResponseResult for RemarketingListShare {} + + +/// Operating System Version List Response +/// +/// # 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 operating system versions](struct.OperatingSystemVersionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemVersionsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse". + pub kind: Option, + /// Operating system version collection. + #[serde(rename="operatingSystemVersions")] + pub operating_system_versions: Option>, +} + +impl ResponseResult for OperatingSystemVersionsListResponse {} + + +/// Organizes placements according to the contents of their associated webpages. +/// +/// # 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 content categories](struct.ContentCategoryPatchCall.html) (request|response) +/// * [insert content categories](struct.ContentCategoryInsertCall.html) (request|response) +/// * [update content categories](struct.ContentCategoryUpdateCall.html) (request|response) +/// * [get content categories](struct.ContentCategoryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentCategory { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory". + pub kind: Option, + /// Account ID of this content category. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this content category. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this content category. This is a required field and must be less than 256 characters long and unique among content categories of the same account. + pub name: Option, +} + +impl RequestValue for ContentCategory {} +impl ResponseResult for ContentCategory {} + + +/// Targetable remarketing list response +/// +/// # 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 targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingListsListResponse". + pub kind: Option, + /// Targetable remarketing list collection. + #[serde(rename="targetableRemarketingLists")] + pub targetable_remarketing_lists: Option>, +} + +impl ResponseResult for TargetableRemarketingListsListResponse {} + + +/// Represents a buy from the DoubleClick Planning inventory store. +/// +/// # 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 inventory items](struct.InventoryItemGetCall.html) (response) +/// * [list inventory items](struct.InventoryItemListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItem { + /// Order ID of this inventory item. + #[serde(rename="orderId")] + pub order_id: Option, + /// Advertiser ID of this inventory item. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// ID of the site this inventory item is associated with. + #[serde(rename="siteId")] + pub site_id: Option, + /// Ad slots of this inventory item. If this inventory item represents a standalone placement, there will be exactly one ad slot. If this inventory item represents a placement group, there will be more than one ad slot, each representing one child placement in that placement group. + #[serde(rename="adSlots")] + pub ad_slots: Option>, + /// RFP ID of this inventory item. + #[serde(rename="rfpId")] + pub rfp_id: Option, + /// Content category ID of this inventory item. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// Placement strategy ID of this inventory item. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Account ID of this inventory item. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItem". + pub kind: Option, + /// Negotiation channel ID of this inventory item. + #[serde(rename="negotiationChannelId")] + pub negotiation_channel_id: Option, + /// Subaccount ID of this inventory item. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this inventory item. For standalone inventory items, this is the same name as that of its only ad slot. For group inventory items, this can differ from the name of any of its ad slots. + pub name: Option, + /// Estimated click-through rate of this inventory item. + #[serde(rename="estimatedClickThroughRate")] + pub estimated_click_through_rate: Option, + /// Information about the most recent modification of this inventory item. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Estimated conversion rate of this inventory item. + #[serde(rename="estimatedConversionRate")] + pub estimated_conversion_rate: Option, + /// Whether this inventory item is in plan. + #[serde(rename="inPlan")] + pub in_plan: Option, + /// ID of this inventory item. + pub id: Option, + /// Project ID of this inventory item. + #[serde(rename="projectId")] + pub project_id: Option, + /// Type of inventory item. + #[serde(rename="type")] + pub type_: Option, + /// Pricing of this inventory item. + pub pricing: Option, +} + +impl Resource for InventoryItem {} +impl ResponseResult for InventoryItem {} + + +/// Represents fields that are compatible to be selected for a report of type "FlOODLIGHT". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#floodlightReportCompatibleFields. + pub kind: Option, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, +} + +impl Part for FloodlightReportCompatibleFields {} + + +/// Creative Asset ID. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssetId { + /// Type of asset to upload. This is a required field. IMAGE is solely used for IMAGE creatives. Other image assets should use HTML_IMAGE. + #[serde(rename="type")] + pub type_: Option, + /// Name of the creative asset. This is a required field while inserting an asset. After insertion, this assetIdentifier is used to identify the uploaded asset. Characters in the name must be alphanumeric or one of the following: ".-_ ". Spaces are allowed. + pub name: Option, +} + +impl Part for CreativeAssetId {} + + +/// Directory Site Contact Assignment +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContactAssignment { + /// ID of this directory site contact. This is a read-only, auto-generated field. + #[serde(rename="contactId")] + pub contact_id: Option, + /// Visibility of this directory site contact assignment. When set to PUBLIC this contact assignment is visible to all account and agency users; when set to PRIVATE it is visible only to the site. + pub visibility: Option, +} + +impl Part for DirectorySiteContactAssignment {} + + +/// Creative Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssignment { + /// Weight of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_RANDOM. + pub weight: Option, + /// Sequence number of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_SEQUENTIAL. + pub sequence: Option, + /// Click-through URL of the creative assignment. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// Rich media exit overrides for this creative assignment. + /// Applicable when the creative type is any of the following: + /// - RICH_MEDIA_INPAGE + /// - RICH_MEDIA_INPAGE_FLOATING + /// - RICH_MEDIA_IM_EXPAND + /// - RICH_MEDIA_EXPANDING + /// - RICH_MEDIA_INTERSTITIAL_FLOAT + /// - RICH_MEDIA_MOBILE_IN_APP + /// - RICH_MEDIA_MULTI_FLOATING + /// - RICH_MEDIA_PEEL_DOWN + /// - ADVANCED_BANNER + /// - VPAID_LINEAR + /// - VPAID_NON_LINEAR + #[serde(rename="richMediaExitOverrides")] + pub rich_media_exit_overrides: Option>, + /// Whether applicable event tags should fire when this creative assignment is rendered. If this value is unset when the ad is inserted or updated, it will default to true for all creative types EXCEPT for INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO. + #[serde(rename="applyEventTags")] + pub apply_event_tags: Option, + /// Creative group assignments for this creative assignment. Only one assignment per creative group number is allowed for a maximum of two assignments. + #[serde(rename="creativeGroupAssignments")] + pub creative_group_assignments: Option>, + /// Companion creative overrides for this creative assignment. Applicable to video ads. + #[serde(rename="companionCreativeOverrides")] + pub companion_creative_overrides: Option>, + /// Date and time that the assigned creative should start serving. + #[serde(rename="startTime")] + pub start_time: Option, + /// Whether the creative to be assigned is SSL-compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Whether this creative assignment is active. When true, the creative will be included in the ad's rotation. + pub active: Option, + /// ID of the creative to be assigned. This is a required field. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Date and time that the assigned creative should stop serving. Must be later than the start time. + #[serde(rename="endTime")] + pub end_time: Option, + /// Dimension value for the ID of the creative. This is a read-only, auto-generated field. + #[serde(rename="creativeIdDimensionValue")] + pub creative_id_dimension_value: Option, +} + +impl Part for CreativeAssignment {} + + +/// Represents a DimensionValuesRequest. +/// +/// # 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValueRequest { + /// The name of the dimension for which values should be requested. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The start date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". + #[serde(rename="startDate")] + pub start_date: Option, + /// The kind of request this is, in this case dfareporting#dimensionValueRequest. + pub kind: Option, + /// The end date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". + #[serde(rename="endDate")] + pub end_date: Option, + /// The list of filters by which to filter values. The filters are ANDed. + pub filters: Option>, +} + +impl RequestValue for DimensionValueRequest {} + + +/// Ad Slot +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdSlot { + /// Comment for this ad slot. + pub comment: Option, + /// ID of the placement from an external platform that is linked to this ad slot. + #[serde(rename="linkedPlacementId")] + pub linked_placement_id: Option, + /// Name of this ad slot. + pub name: Option, + /// Primary ad slot of a roadblock inventory item. + pub primary: Option, + /// Height of this ad slot. + pub height: Option, + /// Width of this ad slot. + pub width: Option, + /// Payment source type of this ad slot. + #[serde(rename="paymentSourceType")] + pub payment_source_type: Option, + /// Ad slot compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop, mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. + pub compatibility: Option, +} + +impl Part for AdSlot {} + + +/// Properties of inheriting and overriding the default click-through event tag. A campaign may override the event tag defined at the advertiser level, and an ad may also override the campaign's setting further. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DefaultClickThroughEventTagProperties { + /// Whether this entity should override the inherited default click-through event tag with its own defined value. + #[serde(rename="overrideInheritedEventTag")] + pub override_inherited_event_tag: Option, + /// ID of the click-through event tag to apply to all ads in this entity's scope. + #[serde(rename="defaultClickThroughEventTagId")] + pub default_click_through_event_tag_id: Option, +} + +impl Part for DefaultClickThroughEventTagProperties {} + + +/// Represents the list of user profiles. +/// +/// # 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 user profiles](struct.UserProfileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserProfileList { + /// The user profiles returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#userProfileList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for UserProfileList {} + + +/// Subaccount List Response +/// +/// # 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 subaccounts](struct.SubaccountListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SubaccountsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccountsListResponse". + pub kind: Option, + /// Subaccount collection. + pub subaccounts: Option>, +} + +impl ResponseResult for SubaccountsListResponse {} + + +/// Contains properties of a DoubleClick Planning order document. +/// +/// # 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 order documents](struct.OrderDocumentGetCall.html) (response) +/// * [list order documents](struct.OrderDocumentListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocument { + /// ID of the order from which this order document is created. + #[serde(rename="orderId")] + pub order_id: Option, + /// Timestamp of the last email sent with this order document. + #[serde(rename="lastSentTime")] + pub last_sent_time: Option, + /// The amended order document ID of this order document. An order document can be created by optionally amending another order document so that the change history can be preserved. + #[serde(rename="amendedOrderDocumentId")] + pub amended_order_document_id: Option, + /// List of email addresses that received the last sent document. + #[serde(rename="lastSentRecipients")] + pub last_sent_recipients: Option>, + /// IDs of users who have approved this order document. + #[serde(rename="approvedByUserProfileIds")] + pub approved_by_user_profile_ids: Option>, + /// ID of this order document. + pub id: Option, + /// Account ID of this order document. + #[serde(rename="accountId")] + pub account_id: Option, + /// Advertiser ID of this order document. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocument". + pub kind: Option, + /// Subaccount ID of this order document. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Effective date of this order document. + #[serde(rename="effectiveDate")] + pub effective_date: Option, + /// Title of this order document. + pub title: Option, + /// Project ID of this order document. + #[serde(rename="projectId")] + pub project_id: Option, + /// Whether this order document has been signed. + pub signed: Option, + /// Information about the creation of this order document. + #[serde(rename="createdInfo")] + pub created_info: Option, + /// Whether this order document is cancelled. + pub cancelled: Option, + /// Type of this order document + #[serde(rename="type")] + pub type_: Option, +} + +impl Resource for OrderDocument {} +impl ResponseResult for OrderDocument {} + + +/// Represents a Report 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*). +/// +/// * [run reports](struct.ReportRunCall.html) (none) +/// * [get reports](struct.ReportGetCall.html) (response) +/// * [list reports](struct.ReportListCall.html) (none) +/// * [delete reports](struct.ReportDeleteCall.html) (none) +/// * [files list reports](struct.ReportFileListCall.html) (none) +/// * [insert reports](struct.ReportInsertCall.html) (request|response) +/// * [patch reports](struct.ReportPatchCall.html) (request|response) +/// * [compatible fields query reports](struct.ReportCompatibleFieldQueryCall.html) (request) +/// * [update reports](struct.ReportUpdateCall.html) (request|response) +/// * [files get reports](struct.ReportFileGetCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Report { + /// The user profile id of the owner of this report. + #[serde(rename="ownerProfileId")] + pub owner_profile_id: Option, + /// The subaccount ID to which this report belongs if applicable. + #[serde(rename="subAccountId")] + pub sub_account_id: Option, + /// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY". + pub schedule: Option, + /// The report criteria for a report of type "PATH_TO_CONVERSION". + #[serde(rename="pathToConversionCriteria")] + pub path_to_conversion_criteria: Option, + /// The report criteria for a report of type "REACH". + #[serde(rename="reachCriteria")] + pub reach_criteria: Option, + /// The report criteria for a report of type "FLOODLIGHT". + #[serde(rename="floodlightCriteria")] + pub floodlight_criteria: Option, + /// The filename used when generating report files for this report. + #[serde(rename="fileName")] + pub file_name: Option, + /// The report's email delivery settings. + pub delivery: Option, + /// The timestamp (in milliseconds since epoch) of when this report was last modified. + #[serde(rename="lastModifiedTime")] + pub last_modified_time: Option, + /// The report criteria for a report of type "CROSS_DIMENSION_REACH". + #[serde(rename="crossDimensionReachCriteria")] + pub cross_dimension_reach_criteria: Option, + /// The account ID to which this report belongs. + #[serde(rename="accountId")] + pub account_id: Option, + /// The kind of resource this is, in this case dfareporting#report. + pub kind: Option, + /// The name of the report. + pub name: Option, + /// The output format of the report. If not specified, default format is "CSV". Note that the actual format in the completed report file might differ if for instance the report's size exceeds the format's capabilities. "CSV" will then be the fallback format. + pub format: Option, + /// The unique ID identifying this report resource. + pub id: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The report criteria for a report of type "STANDARD". + pub criteria: Option, + /// The type of the report. + #[serde(rename="type")] + pub type_: Option, +} + +impl RequestValue for Report {} +impl Resource for Report {} +impl ResponseResult for Report {} + + +/// Contains information about a platform type that can be targeted by ads. +/// +/// # 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 platform types](struct.PlatformTypeGetCall.html) (response) +/// * [list platform types](struct.PlatformTypeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlatformType { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformType". + pub kind: Option, + /// ID of this platform type. + pub id: Option, + /// Name of this platform type. + pub name: Option, +} + +impl Resource for PlatformType {} +impl ResponseResult for PlatformType {} + + +/// Advertiser List Response +/// +/// # 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 advertisers](struct.AdvertiserListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertisersListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Advertiser collection. + pub advertisers: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertisersListResponse". + pub kind: Option, +} + +impl ResponseResult for AdvertisersListResponse {} + + +/// Creative Asset. +/// +/// # 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 creative assets](struct.CreativeAssetInsertCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAsset { + /// Detected MIME type for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// Artwork type of rich media creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Offset left unit for an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="positionLeftUnit")] + pub position_left_unit: Option, + /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. + #[serde(rename="collapsedSize")] + pub collapsed_size: Option, + /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="flashVersion")] + pub flash_version: Option, + /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. + pub pushdown: Option, + /// Whether to hide Flash objects flag for an asset. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="hideFlashObjects")] + pub hide_flash_objects: Option, + /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="detectedFeatures")] + pub detected_features: Option>, + /// Duration in seconds for which an asset will be displayed. Applicable to the following creative types: INSTREAM_VIDEO and VPAID_LINEAR_VIDEO. + pub duration: Option, + /// Offset top unit for an asset. This is a read-only field if the asset displayType is ASSET_DISPLAY_TYPE_OVERLAY. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="positionTopUnit")] + pub position_top_unit: Option, + /// Numeric ID of this creative asset. This is a required field and should not be modified. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + pub id: Option, + /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_DISPLAY_MULTI_FLOATING_INTERSTITIAL. + pub alignment: Option, + /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE, creatives if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + pub size: Option, + /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="horizontallyLocked")] + pub horizontally_locked: Option, + /// Initial wait time type before making the asset visible. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="startTimeType")] + pub start_time_type: Option, + /// Type of rich media asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="displayType")] + pub display_type: Option, + /// Detected expanded dimension for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="expandedDimension")] + pub expanded_dimension: Option, + /// Whether the asset is vertically locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="verticallyLocked")] + pub vertically_locked: Option, + /// Role of the asset in relation to creative. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. This is a required field. + /// PRIMARY applies to DISPLAY, FLASH_INPAGE, HTML5_BANNER, IMAGE, DISPLAY_IMAGE_GALLERY, all RICH_MEDIA (which may contain multiple primary assets), and all VPAID creatives. + /// BACKUP_IMAGE applies to FLASH_INPAGE, HTML5_BANNER, all RICH_MEDIA, and all VPAID creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + /// ADDITIONAL_IMAGE and ADDITIONAL_FLASH apply to FLASH_INPAGE creatives. + /// OTHER refers to assets from sources other than DCM, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. + /// PARENT_VIDEO refers to videos uploaded by the user in DCM and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. + /// TRANSCODED_VIDEO refers to videos transcoded by DCM from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. + /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within DCM. + /// For VPAID_LINEAR_VIDEO creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR_VIDEO creative. + pub role: Option, + /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="zipFilesize")] + pub zip_filesize: Option, + /// Detected bit-rate for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="bitRate")] + pub bit_rate: Option, + /// Window mode options for flash assets. Applicable to the following creative types: FLASH_INPAGE, RICH_MEDIA_DISPLAY_EXPANDING, RICH_MEDIA_IM_EXPAND, RICH_MEDIA_DISPLAY_BANNER, and RICH_MEDIA_INPAGE_FLOATING. + #[serde(rename="windowMode")] + pub window_mode: Option, + /// Progressive URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="progressiveServingUrl")] + pub progressive_serving_url: Option, + /// Duration type for which an asset will be displayed. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="durationType")] + pub duration_type: Option, + /// Detected video duration for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="videoDuration")] + pub video_duration: Option, + /// File size associated with this creative asset. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="fileSize")] + pub file_size: Option, + /// Offset position for an asset in collapsed mode. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, only applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. + pub offset: Option, + /// Whether the video asset is active. This is a read-only field for VPAID_NON_LINEAR_VIDEO assets. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + pub active: Option, + /// Whether the backup asset is original or changed by the user in DCM. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="originalBackup")] + pub original_backup: Option, + /// Whether to hide selection boxes flag for an asset. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="hideSelectionBoxes")] + pub hide_selection_boxes: Option, + /// Streaming URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="streamingServingUrl")] + pub streaming_serving_url: Option, + /// zIndex value of an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable to assets whose displayType is NOT one of the following types: ASSET_DISPLAY_TYPE_INPAGE or ASSET_DISPLAY_TYPE_OVERLAY. + #[serde(rename="zIndex")] + pub z_index: Option, + /// Rich media child asset type. This is a read-only field. Applicable to the following creative types: all VPAID. + #[serde(rename="childAssetType")] + pub child_asset_type: Option, + /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="backupImageExit")] + pub backup_image_exit: Option, + /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="actionScript3")] + pub action_script3: Option, + /// Pushdown duration in seconds for an asset. Must be between 0 and 9.99. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. + #[serde(rename="pushdownDuration")] + pub pushdown_duration: Option, + /// Identifier of this asset. This is the same identifier returned during creative asset insert operation. This is a required field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="assetIdentifier")] + pub asset_identifier: Option, + /// Whether the asset is transparent. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable to HTML5 assets. + pub transparency: Option, + /// Whether the asset is SSL-compliant. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Offset position for an asset. Applicable to the following creative types: all RICH_MEDIA. + pub position: Option, + /// Custom start time in seconds for making the asset visible. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="customStartTimeValue")] + pub custom_start_time_value: Option, + /// File name of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="zipFilename")] + pub zip_filename: Option, +} + +impl Resource for CreativeAsset {} + + +/// Directory Site List Response +/// +/// # 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 directory sites](struct.DirectorySiteListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySitesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySitesListResponse". + pub kind: Option, + /// Directory site collection. + #[serde(rename="directorySites")] + pub directory_sites: Option>, +} + +impl ResponseResult for DirectorySitesListResponse {} + + +/// Modification timestamp. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LastModifiedInfo { + /// Timestamp of the last change in milliseconds since epoch. + pub time: Option, +} + +impl Part for LastModifiedInfo {} + + +/// Region List Response +/// +/// # 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 RegionsListResponse { + /// Region collection. + pub regions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#regionsListResponse". + pub kind: Option, +} + +impl ResponseResult for RegionsListResponse {} + + +/// Represents a grouping of related user role permissions. +/// +/// # 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 user role permission groups](struct.UserRolePermissionGroupListCall.html) (none) +/// * [get user role permission groups](struct.UserRolePermissionGroupGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroup". + pub kind: Option, + /// ID of this user role permission. + pub id: Option, + /// Name of this user role permission group. + pub name: Option, +} + +impl Resource for UserRolePermissionGroup {} +impl ResponseResult for UserRolePermissionGroup {} + + +/// Creative Click Tag. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClickTag { + /// Advertiser event name associated with the click tag. This field is used by DISPLAY_IMAGE_GALLERY and HTML5_BANNER creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="eventName")] + pub event_name: Option, + /// Parameter name for the specified click tag. For DISPLAY_IMAGE_GALLERY creative assets, this field must match the value of the creative asset's creativeAssetId.name field. + pub name: Option, + /// Parameter value for the specified click tag. This field contains a click-through url. + pub value: Option, +} + +impl Part for ClickTag {} + + +/// Contains information about an internet connection type that can be targeted by ads. Clients can use the connection type to target mobile vs. broadband users. +/// +/// # 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 connection types](struct.ConnectionTypeGetCall.html) (response) +/// * [list connection types](struct.ConnectionTypeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConnectionType { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionType". + pub kind: Option, + /// ID of this connection type. + pub id: Option, + /// Name of this connection type. + pub name: Option, +} + +impl Resource for ConnectionType {} +impl ResponseResult for ConnectionType {} + + +/// Browser List Response +/// +/// # 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 browsers](struct.BrowserListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct BrowsersListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browsersListResponse". + pub kind: Option, + /// Browser collection. + pub browsers: Option>, +} + +impl ResponseResult for BrowsersListResponse {} + + +/// Object Filter. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ObjectFilter { + /// Applicable when status is ASSIGNED. The user has access to objects with these object IDs. + #[serde(rename="objectIds")] + pub object_ids: Option>, + /// Status of the filter. NONE means the user has access to none of the objects. ALL means the user has access to all objects. ASSIGNED means the user has access to the objects with IDs in the objectIds list. + pub status: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#objectFilter". + pub kind: Option, +} + +impl Part for ObjectFilter {} + + +/// Creative Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeSettings { + /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. + #[serde(rename="iFrameHeader")] + pub i_frame_header: Option, + /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. + #[serde(rename="iFrameFooter")] + pub i_frame_footer: Option, +} + +impl Part for CreativeSettings {} + + +/// Represents a dimension. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Dimension { + /// The kind of resource this is, in this case dfareporting#dimension. + pub kind: Option, + /// The dimension name, e.g. dfa:advertiser + pub name: Option, +} + +impl Part for Dimension {} + + +/// Contact of an order. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderContact { + /// Type of this contact. + #[serde(rename="contactType")] + pub contact_type: Option, + /// Title of this contact. + #[serde(rename="contactTitle")] + pub contact_title: Option, + /// Free-form information about this contact. It could be any information related to this contact in addition to type, title, name, and signature user profile ID. + #[serde(rename="contactInfo")] + pub contact_info: Option, + /// Name of this contact. + #[serde(rename="contactName")] + pub contact_name: Option, + /// ID of the user profile containing the signature that will be embedded into order documents. + #[serde(rename="signatureUserProfileId")] + pub signature_user_profile_id: Option, +} + +impl Part for OrderContact {} + + +/// DirectorySites contains properties of a website from the Site Directory. Sites need to be added to an account via the Sites resource before they can be assigned to a placement. +/// +/// # 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 directory sites](struct.DirectorySiteGetCall.html) (response) +/// * [list directory sites](struct.DirectorySiteListCall.html) (none) +/// * [insert directory sites](struct.DirectorySiteInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySite { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySite". + pub kind: Option, + /// Country ID of this directory site. + #[serde(rename="countryId")] + pub country_id: Option, + /// Description of this directory site. + pub description: Option, + /// Directory site settings. + pub settings: Option, + /// Currency ID of this directory site. + /// Possible values are: + /// - "1" for USD + /// - "2" for GBP + /// - "3" for ESP + /// - "4" for SEK + /// - "5" for CAD + /// - "6" for JPY + /// - "7" for DEM + /// - "8" for AUD + /// - "9" for FRF + /// - "10" for ITL + /// - "11" for DKK + /// - "12" for NOK + /// - "13" for FIM + /// - "14" for ZAR + /// - "15" for IEP + /// - "16" for NLG + /// - "17" for EUR + /// - "18" for KRW + /// - "19" for TWD + /// - "20" for SGD + /// - "21" for CNY + /// - "22" for HKD + /// - "23" for NZD + /// - "24" for MYR + /// - "25" for BRL + /// - "26" for PTE + /// - "27" for MXP + /// - "28" for CLP + /// - "29" for TRY + /// - "30" for ARS + /// - "31" for PEN + /// - "32" for ILS + /// - "33" for CHF + /// - "34" for VEF + /// - "35" for COP + /// - "36" for GTQ + /// - "37" for PLN + /// - "39" for INR + /// - "40" for THB + /// - "41" for IDR + /// - "42" for CZK + /// - "43" for RON + /// - "44" for HUF + /// - "45" for RUB + /// - "46" for AED + /// - "47" for BGN + /// - "48" for HRK + #[serde(rename="currencyId")] + pub currency_id: Option, + /// Tag types for regular placements. + /// + /// Acceptable values are: + /// - "STANDARD" + /// - "IFRAME_JAVASCRIPT_INPAGE" + /// - "INTERNAL_REDIRECT_INPAGE" + /// - "JAVASCRIPT_INPAGE" + #[serde(rename="inpageTagFormats")] + pub inpage_tag_formats: Option>, + /// URL of this directory site. + pub url: Option, + /// Directory site contacts. + #[serde(rename="contactAssignments")] + pub contact_assignments: Option>, + /// Parent directory site ID. + #[serde(rename="parentId")] + pub parent_id: Option, + /// Tag types for interstitial placements. + /// + /// Acceptable values are: + /// - "IFRAME_JAVASCRIPT_INTERSTITIAL" + /// - "INTERNAL_REDIRECT_INTERSTITIAL" + /// - "JAVASCRIPT_INTERSTITIAL" + #[serde(rename="interstitialTagFormats")] + pub interstitial_tag_formats: Option>, + /// Dimension value for the ID of this directory site. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether this directory site is active. + pub active: Option, + /// ID of this directory site. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this directory site. + pub name: Option, +} + +impl RequestValue for DirectorySite {} +impl Resource for DirectorySite {} +impl ResponseResult for DirectorySite {} + + +/// City List Response +/// +/// # 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 cities](struct.CityListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CitiesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#citiesListResponse". + pub kind: Option, + /// City collection. + pub cities: Option>, +} + +impl ResponseResult for CitiesListResponse {} + + +/// Contains properties of a creative group. +/// +/// # 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 creative groups](struct.CreativeGroupGetCall.html) (response) +/// * [update creative groups](struct.CreativeGroupUpdateCall.html) (request|response) +/// * [patch creative groups](struct.CreativeGroupPatchCall.html) (request|response) +/// * [list creative groups](struct.CreativeGroupListCall.html) (none) +/// * [insert creative groups](struct.CreativeGroupInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroup". + pub kind: Option, + /// Subaccount ID of this creative group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this creative group. This is a required field and must be less than 256 characters long and unique among creative groups of the same advertiser. + pub name: Option, + /// Subgroup of the creative group. Assign your creative groups to one of the following subgroups in order to filter or manage them more easily. This field is required on insertion and is read-only after insertion. + /// Acceptable values are: + /// - 1 + /// - 2 + #[serde(rename="groupNumber")] + pub group_number: Option, + /// Advertiser ID of this creative group. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this creative group. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this creative group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for CreativeGroup {} +impl Resource for CreativeGroup {} +impl ResponseResult for CreativeGroup {} + + +/// Represents a metric. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Metric { + /// The kind of resource this is, in this case dfareporting#metric. + pub kind: Option, + /// The metric name, e.g. dfa:impressions + pub name: Option, +} + +impl Part for Metric {} + + +/// Rich Media Exit Override. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RichMediaExitOverride { + /// Click-through URL to override the default exit URL. Applicable if the useCustomExitUrl field is set to true. + #[serde(rename="customExitUrl")] + pub custom_exit_url: Option, + /// Whether to use the custom exit URL. + #[serde(rename="useCustomExitUrl")] + pub use_custom_exit_url: Option, + /// ID for the override to refer to a specific exit in the creative. + #[serde(rename="exitId")] + pub exit_id: Option, +} + +impl Part for RichMediaExitOverride {} + + +/// Account Permission List Response +/// +/// # 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 account permissions](struct.AccountPermissionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionsListResponse { + /// Account permission collection. + #[serde(rename="accountPermissions")] + pub account_permissions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionsListResponse". + pub kind: Option, +} + +impl ResponseResult for AccountPermissionsListResponse {} + + +/// Placement GenerateTags Response +/// +/// # 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*). +/// +/// * [generatetags placements](struct.PlacementGeneratetagCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementsGenerateTagsResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsGenerateTagsResponse". + pub kind: Option, + /// Set of generated tags for the specified placements. + #[serde(rename="placementTags")] + pub placement_tags: Option>, +} + +impl ResponseResult for PlacementsGenerateTagsResponse {} + + +/// Contains properties of a creative field value. +/// +/// # 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 creative field values](struct.CreativeFieldValueInsertCall.html) (request|response) +/// * [get creative field values](struct.CreativeFieldValueGetCall.html) (response) +/// * [update creative field values](struct.CreativeFieldValueUpdateCall.html) (request|response) +/// * [patch creative field values](struct.CreativeFieldValuePatchCall.html) (request|response) +/// * [list creative field values](struct.CreativeFieldValueListCall.html) (none) +/// * [delete creative field values](struct.CreativeFieldValueDeleteCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldValue { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValue". + pub kind: Option, + /// ID of this creative field value. This is a read-only, auto-generated field. + pub id: Option, + /// Value of this creative field value. It needs to be less than 256 characters in length and unique per creative field. + pub value: Option, +} + +impl RequestValue for CreativeFieldValue {} +impl Resource for CreativeFieldValue {} +impl ResponseResult for CreativeFieldValue {} + + +/// Floodlight Activity Group List Response +/// +/// # 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 floodlight activity groups](struct.FloodlightActivityGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroupsListResponse". + pub kind: Option, + /// Floodlight activity group collection. + #[serde(rename="floodlightActivityGroups")] + pub floodlight_activity_groups: Option>, +} + +impl ResponseResult for FloodlightActivityGroupsListResponse {} + + +/// Directory Site Contact List Response +/// +/// # 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 directory site contacts](struct.DirectorySiteContactListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContactsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Directory site contact collection + #[serde(rename="directorySiteContacts")] + pub directory_site_contacts: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContactsListResponse". + pub kind: Option, +} + +impl ResponseResult for DirectorySiteContactsListResponse {} + + +/// Creative Custom Event. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeCustomEvent { + /// Target type used by the event. + #[serde(rename="targetType")] + pub target_type: Option, + /// Artwork type used by the creative.This is a read-only field. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Video reporting ID, used to differentiate multiple videos in a single creative. This is a read-only field. + #[serde(rename="videoReportingId")] + pub video_reporting_id: Option, + /// Properties for rich media popup windows. This field is used only for exit events. + #[serde(rename="popupWindowProperties")] + pub popup_window_properties: Option, + /// Unique ID of this event used by DDM Reporting and Data Transfer. This is a read-only field. + #[serde(rename="advertiserCustomEventId")] + pub advertiser_custom_event_id: Option, + /// Artwork label column, used to link events in DCM back to events in Studio. This is a required field and should not be modified after insertion. + #[serde(rename="artworkLabel")] + pub artwork_label: Option, + /// Type of the event. This is a read-only field. + #[serde(rename="advertiserCustomEventType")] + pub advertiser_custom_event_type: Option, + /// Exit URL of the event. This field is used only for exit events. + #[serde(rename="exitUrl")] + pub exit_url: Option, + /// ID of this event. This is a required field and should not be modified after insertion. + pub id: Option, + /// User-entered name for the event. + #[serde(rename="advertiserCustomEventName")] + pub advertiser_custom_event_name: Option, +} + +impl Part for CreativeCustomEvent {} + + +/// Creative List Response +/// +/// # 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 creatives](struct.CreativeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativesListResponse". + pub kind: Option, + /// Creative collection. + pub creatives: Option>, +} + +impl ResponseResult for CreativesListResponse {} + + +/// Omniture Integration Settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OmnitureSettings { + /// Whether placement cost data will be sent to Omniture. This property can be enabled only if omnitureIntegrationEnabled is true. + #[serde(rename="omnitureCostDataEnabled")] + pub omniture_cost_data_enabled: Option, + /// Whether Omniture integration is enabled. This property can be enabled only when the "Advanced Ad Serving" account setting is enabled. + #[serde(rename="omnitureIntegrationEnabled")] + pub omniture_integration_enabled: Option, +} + +impl Part for OmnitureSettings {} + + +/// Represents fields that are compatible to be selected for a report of type "PATH_TO_CONVERSION". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PathToConversionReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// Per-interaction dimensions which are compatible to be selected in the "perInteractionDimensions" section of the report. + #[serde(rename="perInteractionDimensions")] + pub per_interaction_dimensions: Option>, + /// The kind of resource this is, in this case dfareporting#pathToConversionReportCompatibleFields. + pub kind: Option, + /// Conversion dimensions which are compatible to be selected in the "conversionDimensions" section of the report. + #[serde(rename="conversionDimensions")] + pub conversion_dimensions: Option>, + /// Custom floodlight variables which are compatible to be selected in the "customFloodlightVariables" section of the report. + #[serde(rename="customFloodlightVariables")] + pub custom_floodlight_variables: Option>, +} + +impl Part for PathToConversionReportCompatibleFields {} + + +/// Mobile Carrier List Response +/// +/// # 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 mobile carriers](struct.MobileCarrierListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MobileCarriersListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarriersListResponse". + pub kind: Option, + /// Mobile carrier collection. + #[serde(rename="mobileCarriers")] + pub mobile_carriers: Option>, +} + +impl ResponseResult for MobileCarriersListResponse {} + + +/// Dynamic Targeting Key List Response +/// +/// # 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 dynamic targeting keys](struct.DynamicTargetingKeyListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DynamicTargetingKeysListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKeysListResponse". + pub kind: Option, + /// Dynamic targeting key collection. + #[serde(rename="dynamicTargetingKeys")] + pub dynamic_targeting_keys: Option>, +} + +impl ResponseResult for DynamicTargetingKeysListResponse {} + + +/// Dynamic Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityDynamicTag { + /// Tag code. + pub tag: Option, + /// ID of this dynamic tag. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this tag. + pub name: Option, +} + +impl Part for FloodlightActivityDynamicTag {} + + +/// Contains properties of a Creative. +/// +/// # 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 creatives](struct.CreativeInsertCall.html) (request|response) +/// * [get creatives](struct.CreativeGetCall.html) (response) +/// * [list creatives](struct.CreativeListCall.html) (none) +/// * [update creatives](struct.CreativeUpdateCall.html) (request|response) +/// * [patch creatives](struct.CreativePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Creative { + /// Type of artwork used for the creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Latest Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="latestTraffickedCreativeId")] + pub latest_trafficked_creative_id: Option, + /// List of counter events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. + #[serde(rename="counterCustomEvents")] + pub counter_custom_events: Option>, + /// Advertiser ID of this creative. This is a required field. Applicable to all creative types. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Whether the creative is active. Applicable to all creative types. + pub active: Option, + /// List of timer events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset is not HTML_IMAGE. + #[serde(rename="timerCustomEvents")] + pub timer_custom_events: Option>, + /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. + #[serde(rename="renderingIdDimensionValue")] + pub rendering_id_dimension_value: Option, + /// OpenWindow FSCommand of this creative. This lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. This is only triggered if allowScriptAccess field is true. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="fsCommand")] + pub fs_command: Option, + /// ID of this creative. This is a read-only, auto-generated field. Applicable to all creative types. + pub id: Option, + /// Account ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types. + #[serde(rename="accountId")] + pub account_id: Option, + /// Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioTraffickedCreativeId")] + pub studio_trafficked_creative_id: Option, + /// Whether the creative is archived. Applicable to all creative types. + pub archived: Option, + /// Override CSS value for rich media creatives. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="overrideCss")] + pub override_css: Option, + /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types. + #[serde(rename="authoringSource")] + pub authoring_source: Option, + /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="requiredFlashVersion")] + pub required_flash_version: Option, + /// List of exit events configured for the creative. For DISPLAY and DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags, For DISPLAY, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="exitCustomEvents")] + pub exit_custom_events: Option>, + /// ID of current rendering version. This is a read-only field. Applicable to all creative types. + #[serde(rename="renderingId")] + pub rendering_id: Option, + /// Description of the video ad. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="videoDescription")] + pub video_description: Option, + /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="thirdPartyBackupImageImpressionsUrl")] + pub third_party_backup_image_impressions_url: Option, + /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types. + pub version: Option, + /// Creative field assignments for this creative. Applicable to all creative types. + #[serde(rename="creativeFieldAssignments")] + pub creative_field_assignments: Option>, + /// The 6-character HTML color code, beginning with #, for the background of the window area where the Flash file is displayed. Default is white. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="backgroundColor")] + pub background_color: Option, + /// Custom key-values for a Rich Media creative. Key-values let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use key-values to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="customKeyValues")] + pub custom_key_values: Option>, + /// Dimension value for the ID of this creative. This is a read-only field. Applicable to all creative types. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether images are automatically advanced for image gallery creatives. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY. + pub auto_advance_images: Option, + /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE, FLASH_INPAGE creatives, and for DISPLAY creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: DISPLAY, DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + pub size: Option, + /// Type of this creative.This is a required field. Applicable to all creative types. + #[serde(rename="type")] + pub type_: Option, + /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="totalFileSize")] + pub total_file_size: Option, + /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="thirdPartyRichMediaImpressionsUrl")] + pub third_party_rich_media_impressions_url: Option, + /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioAdvertiserId")] + pub studio_advertiser_id: Option, + /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT + #[serde(rename="creativeAssets")] + pub creative_assets: Option>, + /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageFeatures")] + pub backup_image_features: Option>, + /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. + #[serde(rename="videoDuration")] + pub video_duration: Option, + /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: DISPLAY_REDIRECT, INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO_REDIRECT + #[serde(rename="redirectUrl")] + pub redirect_url: Option, + /// Click tags of the creative. For DISPLAY, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For DISPLAY_IMAGE_GALLERY creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="clickTags")] + pub click_tags: Option>, + /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageTargetWindow")] + pub backup_image_target_window: Option, + /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="requiredFlashPluginVersion")] + pub required_flash_plugin_version: Option, + /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageReportingLabel")] + pub backup_image_reporting_label: Option, + /// Compatibilities associated with this creative. This is a read-only field. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. Only pre-existing creatives may have these compatibilities since new creatives will either be assigned DISPLAY or DISPLAY_INTERSTITIAL instead. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. + /// + /// Acceptable values are: + /// - "APP" + /// - "APP_INTERSTITIAL" + /// - "IN_STREAM_VIDEO" + /// - "DISPLAY" + /// - "DISPLAY_INTERSTITIAL" + pub compatibility: Option>, + /// Ad parameters user for VPAID creative. This is a read-only field. Applicable to the following creative types: all VPAID. + #[serde(rename="adParameters")] + pub ad_parameters: Option, + /// Whether HTML code is DCM-generated or manually entered. Set to true to ignore changes to htmlCode. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. + #[serde(rename="htmlCodeLocked")] + pub html_code_locked: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creative". + pub kind: Option, + /// Subaccount ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of the creative. This is a required field and must be less than 256 characters long. Applicable to all creative types. + pub name: Option, + /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="adTagKeys")] + pub ad_tag_keys: Option>, + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="convertFlashToHtml5")] + pub convert_flash_to_html5: Option, + /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. + #[serde(rename="sslOverride")] + pub ssl_override: Option, + /// Creative last modification information. This is a read-only field. Applicable to all creative types. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Click-through URL for backup image. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageClickThroughUrl")] + pub backup_image_click_through_url: Option, + /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioCreativeId")] + pub studio_creative_id: Option, + /// Authoring tool for HTML5 banner creatives. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="authoringTool")] + pub authoring_tool: Option, + /// Third-party URLs for tracking in-stream video creative events. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="thirdPartyUrls")] + pub third_party_urls: Option>, + /// List of companion creatives assigned to an in-Stream videocreative. Acceptable values include IDs of existing flash and image creatives. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="companionCreatives")] + pub companion_creatives: Option>, + /// HTML code for the creative. This is a required field when applicable. This field is ignored if htmlCodeLocked is false. Applicable to the following creative types: all CUSTOM, FLASH_INPAGE, and HTML5_BANNER, and all RICH_MEDIA. + #[serde(rename="htmlCode")] + pub html_code: Option, + /// Whether the creative is SSL-compliant. This is a read-only field. Applicable to all creative types. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Industry standard ID assigned to creative for reach and frequency. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="commercialId")] + pub commercial_id: Option, + /// Whether the user can choose to skip the creative. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + pub skippable: Option, + /// Whether script access is allowed for this creative. This is a read-only and deprecated field which will automatically be set to true on update. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="allowScriptAccess")] + pub allow_script_access: Option, +} + +impl RequestValue for Creative {} +impl Resource for Creative {} +impl ResponseResult for Creative {} + + +/// Reporting 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 ReportsConfiguration { + /// Whether the exposure to conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting. + #[serde(rename="exposureToConversionEnabled")] + pub exposure_to_conversion_enabled: Option, + /// Report generation time zone ID of this account. This is a required field that can only be changed by a superuser. + /// Acceptable values are: + /// + /// - "1" for "America/New_York" + /// - "2" for "Europe/London" + /// - "3" for "Europe/Paris" + /// - "4" for "Africa/Johannesburg" + /// - "5" for "Asia/Jerusalem" + /// - "6" for "Asia/Shanghai" + /// - "7" for "Asia/Hong_Kong" + /// - "8" for "Asia/Tokyo" + /// - "9" for "Australia/Sydney" + /// - "10" for "Asia/Dubai" + /// - "11" for "America/Los_Angeles" + /// - "12" for "Pacific/Auckland" + /// - "13" for "America/Sao_Paulo" + #[serde(rename="reportGenerationTimeZoneId")] + pub report_generation_time_zone_id: Option, + /// Default lookback windows for new advertisers in this account. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, +} + +impl Part for ReportsConfiguration {} + + +/// Campaign List Response +/// +/// # 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 campaigns](struct.CampaignListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignsListResponse { + /// Campaign collection. + pub campaigns: Option>, + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignsListResponse". + pub kind: Option, +} + +impl ResponseResult for CampaignsListResponse {} + + +/// User Role Permission List Response +/// +/// # 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 user role permissions](struct.UserRolePermissionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionsListResponse { + /// User role permission collection. + #[serde(rename="userRolePermissions")] + pub user_role_permissions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionsListResponse". + pub kind: Option, +} + +impl ResponseResult for UserRolePermissionsListResponse {} + + +/// Represents a UserProfile 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 user profiles](struct.UserProfileListCall.html) (none) +/// * [get user profiles](struct.UserProfileGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserProfile { + /// The user name. + #[serde(rename="userName")] + pub user_name: Option, + /// The kind of resource this is, in this case dfareporting#userProfile. + pub kind: Option, + /// The sub account ID this profile belongs to if applicable. + #[serde(rename="subAccountId")] + pub sub_account_id: Option, + /// The account name this profile belongs to. + #[serde(rename="accountName")] + pub account_name: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The sub account name this profile belongs to if applicable. + #[serde(rename="subAccountName")] + pub sub_account_name: Option, + /// The unique ID of the user profile. + #[serde(rename="profileId")] + pub profile_id: Option, + /// The account ID to which this profile belongs. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl Resource for UserProfile {} +impl ResponseResult for UserProfile {} + + +/// Creative Group Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroupAssignment { + /// ID of the creative group to be assigned. + #[serde(rename="creativeGroupId")] + pub creative_group_id: Option, + /// Creative group number of the creative group assignment. + #[serde(rename="creativeGroupNumber")] + pub creative_group_number: Option, +} + +impl Part for CreativeGroupAssignment {} + + +/// The report criteria for a report of type "PATH_TO_CONVERSION". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportPathToConversionCriteria { + /// The list of conversion dimensions the report should include. + #[serde(rename="conversionDimensions")] + pub conversion_dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of custom floodlight variables the report should include. + #[serde(rename="customFloodlightVariables")] + pub custom_floodlight_variables: Option>, + /// The list of 'dfa:activity' values to filter on. + #[serde(rename="activityFilters")] + pub activity_filters: Option>, + /// The list of custom rich media events to include. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option>, + /// The list of per interaction dimensions the report should include. + #[serde(rename="perInteractionDimensions")] + pub per_interaction_dimensions: Option>, + /// The properties of the report. + #[serde(rename="reportProperties")] + pub report_properties: Option, + /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. + #[serde(rename="floodlightConfigId")] + pub floodlight_config_id: Option, +} + +impl NestedType for ReportPathToConversionCriteria {} +impl Part for ReportPathToConversionCriteria {} + + +/// Creative Field List Response +/// +/// # 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 creative fields](struct.CreativeFieldListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Creative field collection. + #[serde(rename="creativeFields")] + pub creative_fields: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse". + pub kind: Option, +} + +impl ResponseResult for CreativeFieldsListResponse {} + + +/// The report's email delivery settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportDelivery { + /// The message to be sent with each email. + pub message: Option, + /// The type of delivery for the owner to receive, if enabled. + #[serde(rename="emailOwnerDeliveryType")] + pub email_owner_delivery_type: Option, + /// The list of recipients to which to email the report. + pub recipients: Option>, + /// Whether the report should be emailed to the report owner. + #[serde(rename="emailOwner")] + pub email_owner: Option, +} + +impl NestedType for ReportDelivery {} +impl Part for ReportDelivery {} + + +/// Project List Response +/// +/// # 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 projects](struct.ProjectListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProjectsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#projectsListResponse". + pub kind: Option, + /// Project collection. + pub projects: Option>, +} + +impl ResponseResult for ProjectsListResponse {} + + +/// Contains properties of a dynamic targeting key. Dynamic targeting keys are unique, user-friendly labels, created at the advertiser level in DCM, that can be assigned to ads, creatives, and placements and used for targeting with DoubleClick Studio dynamic creatives. Use these labels instead of numeric DCM IDs (such as placement IDs) to save time and avoid errors in your dynamic feeds. +/// +/// # 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 dynamic targeting keys](struct.DynamicTargetingKeyListCall.html) (none) +/// * [delete dynamic targeting keys](struct.DynamicTargetingKeyDeleteCall.html) (none) +/// * [insert dynamic targeting keys](struct.DynamicTargetingKeyInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DynamicTargetingKey { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKey". + pub kind: Option, + /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + pub name: Option, + /// ID of the object of this dynamic targeting key. This is a required field. + #[serde(rename="objectId")] + pub object_id: Option, + /// Type of the object of this dynamic targeting key. This is a required field. + #[serde(rename="objectType")] + pub object_type: Option, +} + +impl RequestValue for DynamicTargetingKey {} +impl Resource for DynamicTargetingKey {} +impl ResponseResult for DynamicTargetingKey {} + + +/// Geographical Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GeoTargeting { + /// Regions to be targeted. For each region only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a region, do not target or exclude the country of the region. + pub regions: Option>, + /// Countries to be targeted or excluded from targeting, depending on the setting of the excludeCountries field. For each country only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting or excluding a country, do not target regions, cities, metros, or postal codes in the same country. + pub countries: Option>, + /// Metros to be targeted. For each metro only dmaId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a metro, do not target or exclude the country of the metro. + pub metros: Option>, + /// Cities to be targeted. For each city only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a city, do not target or exclude the country of the city, and do not target the metro or region of the city. + pub cities: Option>, + /// Whether or not to exclude the countries in the countries field from targeting. If false, the countries field refers to countries which will be targeted by the ad. + #[serde(rename="excludeCountries")] + pub exclude_countries: Option, + /// Postal codes to be targeted. For each postal code only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a postal code, do not target or exclude the country of the postal code. + #[serde(rename="postalCodes")] + pub postal_codes: Option>, +} + +impl Part for GeoTargeting {} + + +/// Delivery Schedule. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DeliverySchedule { + /// Serving priority of an ad, with respect to other ads. The lower the priority number, the greater the priority with which it is served. + pub priority: Option, + /// Whether or not hard cutoff is enabled. If true, the ad will not serve after the end date and time. Otherwise the ad will continue to be served until it has reached its delivery goals. + #[serde(rename="hardCutoff")] + pub hard_cutoff: Option, + /// Limit on the number of times an individual user can be served the ad within a specified period of time. + #[serde(rename="frequencyCap")] + pub frequency_cap: Option, + /// Impression ratio for this ad. This ratio determines how often each ad is served relative to the others. For example, if ad A has an impression ratio of 1 and ad B has an impression ratio of 3, then DCM will serve ad B three times as often as ad A. Must be between 1 and 10. + #[serde(rename="impressionRatio")] + pub impression_ratio: Option, +} + +impl Part for DeliverySchedule {} + + +/// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportSchedule { + /// Start date of date range for which scheduled reports should be run. + #[serde(rename="startDate")] + pub start_date: Option, + /// Enum to define for "MONTHLY" scheduled reports whether reports should be repeated on the same day of the month as "startDate" or the same day of the week of the month. + /// Example: If 'startDate' is Monday, April 2nd 2012 (2012-04-02), "DAY_OF_MONTH" would run subsequent reports on the 2nd of every Month, and "WEEK_OF_MONTH" would run subsequent reports on the first Monday of the month. + #[serde(rename="runsOnDayOfMonth")] + pub runs_on_day_of_month: Option, + /// The expiration date when the scheduled report stops running. + #[serde(rename="expirationDate")] + pub expiration_date: Option, + /// Whether the schedule is active or not. Must be set to either true or false. + pub active: Option, + /// Defines every how many days, weeks or months the report should be run. Needs to be set when "repeats" is either "DAILY", "WEEKLY" or "MONTHLY". + pub every: Option, + /// The interval for which the report is repeated. Note: + /// - "DAILY" also requires field "every" to be set. + /// - "WEEKLY" also requires fields "every" and "repeatsOnWeekDays" to be set. + /// - "MONTHLY" also requires fields "every" and "runsOnDayOfMonth" to be set. + pub repeats: Option, + /// List of week days "WEEKLY" on which scheduled reports should run. + #[serde(rename="repeatsOnWeekDays")] + pub repeats_on_week_days: Option>, +} + +impl NestedType for ReportSchedule {} +impl Part for ReportSchedule {} + + +/// Represents a recipient. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Recipient { + /// The kind of resource this is, in this case dfareporting#recipient. + pub kind: Option, + /// The delivery type for the recipient. + #[serde(rename="deliveryType")] + pub delivery_type: Option, + /// The email address of the recipient. + pub email: Option, +} + +impl Part for Recipient {} + + +/// Represents fields that are compatible to be selected for a report of type "STANDARD". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#reportCompatibleFields. + pub kind: Option, + /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. + #[serde(rename="pivotedActivityMetrics")] + pub pivoted_activity_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl Part for ReportCompatibleFields {} + + +/// Advertiser Group List Response +/// +/// # 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 advertiser groups](struct.AdvertiserGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertiserGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroupsListResponse". + pub kind: Option, + /// Advertiser group collection. + #[serde(rename="advertiserGroups")] + pub advertiser_groups: Option>, +} + +impl ResponseResult for AdvertiserGroupsListResponse {} + + +/// Placement Group List Response +/// +/// # 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 placement groups](struct.PlacementGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse". + pub kind: Option, + /// Placement group collection. + #[serde(rename="placementGroups")] + pub placement_groups: Option>, +} + +impl ResponseResult for PlacementGroupsListResponse {} + + +/// The properties of the report. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportPathToConversionCriteriaReportProperties { + /// DFA checks to see if a click interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. + #[serde(rename="clicksLookbackWindow")] + pub clicks_lookback_window: Option, + /// Enable pivoting on interaction path. + #[serde(rename="pivotOnInteractionPath")] + pub pivot_on_interaction_path: Option, + /// DFA checks to see if an impression interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. + #[serde(rename="impressionsLookbackWindow")] + pub impressions_lookback_window: Option, + /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. + #[serde(rename="includeUnattributedIPConversions")] + pub include_unattributed_ip_conversions: Option, + /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. + #[serde(rename="includeUnattributedCookieConversions")] + pub include_unattributed_cookie_conversions: Option, + /// The maximum amount of time that can take place between interactions (clicks or impressions) by the same user. Valid values: 1-90. + #[serde(rename="maximumInteractionGap")] + pub maximum_interaction_gap: Option, + /// Deprecated: has no effect. + #[serde(rename="includeAttributedIPConversions")] + pub include_attributed_ip_conversions: Option, + /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. + #[serde(rename="maximumClickInteractions")] + pub maximum_click_interactions: Option, + /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. + #[serde(rename="maximumImpressionInteractions")] + pub maximum_impression_interactions: Option, +} + +impl NestedType for ReportPathToConversionCriteriaReportProperties {} +impl Part for ReportPathToConversionCriteriaReportProperties {} + + +/// Technology Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TechnologyTargeting { + /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated. + pub browsers: Option>, + /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. + #[serde(rename="operatingSystems")] + pub operating_systems: Option>, + /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. + #[serde(rename="mobileCarriers")] + pub mobile_carriers: Option>, + /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated. + #[serde(rename="connectionTypes")] + pub connection_types: Option>, + /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. + #[serde(rename="platformTypes")] + pub platform_types: Option>, + /// Operating system versions that this ad targets. To target all versions, use operatingSystems. For each operating system version, only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system version, do not set targeting for the corresponding operating system in operatingSystems. + #[serde(rename="operatingSystemVersions")] + pub operating_system_versions: Option>, +} + +impl Part for TechnologyTargeting {} + + +/// Represents the list of reports. +/// +/// # 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 reports](struct.ReportListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportList { + /// Continuation token used to page through reports. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The reports returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#reportList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for ReportList {} + + +/// Remarketing List Targeting Expression. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListTargetingExpression { + /// Expression describing which lists are being targeted by the ad. + pub expression: Option, +} + +impl Part for ListTargetingExpression {} + + +/// CreativeAssets contains properties of a creative asset file which will be uploaded or has already been uploaded. Refer to the creative sample code for how to upload assets and insert a creative. +/// +/// # 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 creative assets](struct.CreativeAssetInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssetMetadata { + /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. + /// + /// Possible values are: + /// - "ADMOB_REFERENCED" + /// - "ASSET_FORMAT_UNSUPPORTED_DCM" + /// - "ASSET_INVALID" + /// - "CLICK_TAG_HARD_CODED" + /// - "CLICK_TAG_INVALID" + /// - "CLICK_TAG_IN_GWD" + /// - "CLICK_TAG_MISSING" + /// - "CLICK_TAG_MORE_THAN_ONE" + /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "COMPONENT_UNSUPPORTED_DCM" + /// - "ENABLER_UNSUPPORTED_METHOD_DCM" + /// - "EXTERNAL_FILE_REFERENCED" + /// - "FILE_DETAIL_EMPTY" + /// - "FILE_TYPE_INVALID" + /// - "GWD_PROPERTIES_INVALID" + /// - "HTML5_FEATURE_UNSUPPORTED" + /// - "LINKED_FILE_NOT_FOUND" + /// - "MAX_FLASH_VERSION_11" + /// - "MRAID_REFERENCED" + /// - "NOT_SSL_COMPLIANT" + /// - "ORPHANED_ASSET" + /// - "PRIMARY_HTML_MISSING" + /// - "SVG_INVALID" + /// - "ZIP_INVALID" + #[serde(rename="warnedValidationRules")] + pub warned_validation_rules: Option>, + /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. + #[serde(rename="detectedFeatures")] + pub detected_features: Option>, + /// List of detected click tags for assets. This is a read-only auto-generated field. + #[serde(rename="clickTags")] + pub click_tags: Option>, + /// ID of the creative asset. This is a required field. + #[serde(rename="assetIdentifier")] + pub asset_identifier: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeAssetMetadata". + pub kind: Option, +} + +impl RequestValue for CreativeAssetMetadata {} +impl ResponseResult for CreativeAssetMetadata {} + + +/// Placement Tag Data +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagData { + /// Tag string to record a click. + #[serde(rename="clickTag")] + pub click_tag: Option, + /// Tag string for serving an ad. + #[serde(rename="impressionTag")] + pub impression_tag: Option, + /// Creative associated with this placement tag. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Ad associated with this placement tag. + #[serde(rename="adId")] + pub ad_id: Option, + /// TagData tag format of this tag. + pub format: Option, +} + +impl Part for TagData {} + + +/// The report criteria for a report of type "FLOODLIGHT". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportFloodlightCriteria { + /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. + #[serde(rename="floodlightConfigId")] + pub floodlight_config_id: Option, + /// The list of dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of custom rich media events to include. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option>, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The properties of the report. + #[serde(rename="reportProperties")] + pub report_properties: Option, +} + +impl NestedType for ReportFloodlightCriteria {} +impl Part for ReportFloodlightCriteria {} + + +/// Landing Page List Response +/// +/// # 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 landing pages](struct.LandingPageListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LandingPagesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPagesListResponse". + pub kind: Option, + /// Landing page collection + #[serde(rename="landingPages")] + pub landing_pages: Option>, +} + +impl ResponseResult for LandingPagesListResponse {} + + +/// Site List Response +/// +/// # 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 sites](struct.SiteListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SitesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sitesListResponse". + pub kind: Option, + /// Site collection. + pub sites: Option>, +} + +impl ResponseResult for SitesListResponse {} + + +/// Represents a dimension filter. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionFilter { + /// The name of the dimension to filter. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The kind of resource this is, in this case dfareporting#dimensionFilter. + pub kind: Option, + /// The value of the dimension to filter. + pub value: Option, +} + +impl Part for DimensionFilter {} + + +/// Contains information about a postal code that can be targeted by ads. +/// +/// # 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 postal codes](struct.PostalCodeGetCall.html) (response) +/// * [list postal codes](struct.PostalCodeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PostalCode { + /// Postal code. This is equivalent to the id field. + pub code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCode". + pub kind: Option, + /// DART ID of the country to which this postal code belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// ID of this postal code. + pub id: Option, + /// Country code of the country to which this postal code belongs. + #[serde(rename="countryCode")] + pub country_code: Option, +} + +impl Resource for PostalCode {} +impl ResponseResult for PostalCode {} + + +/// Contains properties of a remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource can be used to manage remarketing lists that are owned by your advertisers. To see all remarketing lists that are visible to your advertisers, including those that are shared to your advertiser or account, use the TargetableRemarketingLists 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 remarketing lists](struct.RemarketingListInsertCall.html) (request|response) +/// * [get remarketing lists](struct.RemarketingListGetCall.html) (response) +/// * [update remarketing lists](struct.RemarketingListUpdateCall.html) (request|response) +/// * [list remarketing lists](struct.RemarketingListListCall.html) (none) +/// * [patch remarketing lists](struct.RemarketingListPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingList { + /// Rule used to populate the remarketing list with users. + #[serde(rename="listPopulationRule")] + pub list_population_rule: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingList". + pub kind: Option, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Remarketing list description. + pub description: Option, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option, + /// Number of days that a user should remain in the remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option, + /// Dimension value for the advertiser ID that owns this remarketing list. This is a required field. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Product from which this remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option, + /// Whether this remarketing list is active. + pub active: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option, + /// Remarketing list ID. This is a read-only, auto-generated field. + pub id: Option, + /// Name of the remarketing list. This is a required field. Must be no greater than 128 characters long. + pub name: Option, +} + +impl RequestValue for RemarketingList {} +impl Resource for RemarketingList {} +impl ResponseResult for RemarketingList {} + + +/// Contains properties of a Floodlight activity. +/// +/// # 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 floodlight activities](struct.FloodlightActivityGetCall.html) (response) +/// * [insert floodlight activities](struct.FloodlightActivityInsertCall.html) (request|response) +/// * [patch floodlight activities](struct.FloodlightActivityPatchCall.html) (request|response) +/// * [update floodlight activities](struct.FloodlightActivityUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivity { + /// Whether this tag should use SSL. + pub secure: Option, + /// Dimension value for the ID of this floodlight activity. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Name of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupName")] + pub floodlight_activity_group_name: Option, + /// Whether the image tag is enabled for this activity. + #[serde(rename="imageTagEnabled")] + pub image_tag_enabled: Option, + /// Advertiser ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's advertiser or the existing activity's advertiser. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Code type used for cache busting in the generated tag. + #[serde(rename="cacheBustingType")] + pub cache_busting_type: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Floodlight activity group ID of this floodlight activity. This is a required field. + #[serde(rename="floodlightActivityGroupId")] + pub floodlight_activity_group_id: Option, + /// List of the user-defined variables used by this conversion tag. These map to the "u[1-20]=" in the tags. Each of these can have a user defined type. + /// Acceptable values are: + /// - "U1" + /// - "U2" + /// - "U3" + /// - "U4" + /// - "U5" + /// - "U6" + /// - "U7" + /// - "U8" + /// - "U9" + /// - "U10" + /// - "U11" + /// - "U12" + /// - "U13" + /// - "U14" + /// - "U15" + /// - "U16" + /// - "U17" + /// - "U18" + /// - "U19" + /// - "U20" + #[serde(rename="userDefinedVariableTypes")] + pub user_defined_variable_types: Option>, + /// Value of the cat= paramter in the floodlight tag, which the ad servers use to identify the activity. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activities of the same activity group. This field is read-only after insertion. + #[serde(rename="tagString")] + pub tag_string: Option, + /// Tag string of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupTagString")] + pub floodlight_activity_group_tag_string: Option, + /// URL where this tag will be deployed. If specified, must be less than 256 characters long. + #[serde(rename="expectedUrl")] + pub expected_url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivity". + pub kind: Option, + /// Subaccount ID of this floodlight activity. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this floodlight activity. This is a required field. Must be less than 129 characters long and cannot contain quotes. + pub name: Option, + /// Publisher dynamic floodlight tags. + #[serde(rename="publisherTags")] + pub publisher_tags: Option>, + /// Whether the floodlight activity is SSL-compliant. This is a read-only field, its value detected by the system from the floodlight tags. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// General notes or implementation instructions for the tag. + pub notes: Option, + /// Floodlight configuration ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's floodlight configuration or from the existing activity's floodlight configuration. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// ID of this floodlight activity. This is a read-only, auto-generated field. + pub id: Option, + /// Counting method for conversions for this floodlight activity. This is a required field. + #[serde(rename="countingMethod")] + pub counting_method: Option, + /// Dynamic floodlight tags. + #[serde(rename="defaultTags")] + pub default_tags: Option>, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Tag format type for the floodlight activity. If left blank, the tag format will default to HTML. + #[serde(rename="tagFormat")] + pub tag_format: Option, + /// Whether this activity is archived. + pub hidden: Option, + /// Account ID of this floodlight activity. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Whether this floodlight activity must be SSL-compliant. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Type of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupType")] + pub floodlight_activity_group_type: Option, +} + +impl RequestValue for FloodlightActivity {} +impl ResponseResult for FloodlightActivity {} + + +/// Contains information about a browser that can be targeted by ads. +/// +/// # 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 browsers](struct.BrowserListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Browser { + /// Major version number (leftmost number) of this browser. For example, for Chrome 5.0.376.86 beta, this field should be set to 5. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is. + #[serde(rename="majorVersion")] + pub major_version: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browser". + pub kind: Option, + /// ID referring to this grouping of browser and version numbers. This is the ID used for targeting. + #[serde(rename="browserVersionId")] + pub browser_version_id: Option, + /// Name of this browser. + pub name: Option, + /// DART ID of this browser. This is the ID used when generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Minor version number (number after first dot on left) of this browser. For example, for Chrome 5.0.375.86 beta, this field should be set to 0. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is. + #[serde(rename="minorVersion")] + pub minor_version: Option, +} + +impl Resource for Browser {} + + +/// Account User Profile List Response +/// +/// # 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 account user profiles](struct.AccountUserProfileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountUserProfilesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Account user profile collection. + #[serde(rename="accountUserProfiles")] + pub account_user_profiles: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfilesListResponse". + pub kind: Option, +} + +impl ResponseResult for AccountUserProfilesListResponse {} + + +/// Contains properties of a DCM advertiser. +/// +/// # 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 advertisers](struct.AdvertiserGetCall.html) (response) +/// * [update advertisers](struct.AdvertiserUpdateCall.html) (request|response) +/// * [patch advertisers](struct.AdvertiserPatchCall.html) (request|response) +/// * [list advertisers](struct.AdvertiserListCall.html) (none) +/// * [insert advertisers](struct.AdvertiserInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Advertiser { + /// Status of this advertiser. + pub status: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiser". + pub kind: Option, + /// Subaccount ID of this advertiser.This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this advertiser. This is a required field and must be less than 256 characters long and unique among advertisers of the same account. + pub name: Option, + /// ID of the click-through event tag to apply by default to the landing pages of this advertiser's campaigns. + #[serde(rename="defaultClickThroughEventTagId")] + pub default_click_through_event_tag_id: Option, + /// Original floodlight configuration before any sharing occurred. Set the floodlightConfigurationId of this advertiser to originalFloodlightConfigurationId to unshare the advertiser's current floodlight configuration. You cannot unshare an advertiser's floodlight configuration if the shared configuration has activities associated with any campaign or placement. + #[serde(rename="originalFloodlightConfigurationId")] + pub original_floodlight_configuration_id: Option, + /// Suffix added to click-through URL of ad creative associations under this advertiser. Must be less than 129 characters long. + #[serde(rename="clickThroughUrlSuffix")] + pub click_through_url_suffix: Option, + /// Floodlight configuration ID of this advertiser. The floodlight configuration ID will be created automatically, so on insert this field should be left blank. This field can be set to another advertiser's floodlight configuration ID in order to share that advertiser's floodlight configuration with this advertiser, so long as: + /// - This advertiser's original floodlight configuration is not already associated with floodlight activities or floodlight activity groups. + /// - This advertiser's original floodlight configuration is not already shared with another advertiser. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// ID of the advertiser group this advertiser belongs to. You can group advertisers for reporting purposes, allowing you to see aggregated information for all advertisers in each group. + #[serde(rename="advertiserGroupId")] + pub advertiser_group_id: Option, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Suspension status of this advertiser. + pub suspended: Option, + /// Dimension value for the ID of this advertiser. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Default email address used in sender field for tag emails. + #[serde(rename="defaultEmail")] + pub default_email: Option, + /// ID of this advertiser. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this advertiser.This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for Advertiser {} +impl Resource for Advertiser {} +impl ResponseResult for Advertiser {} + + +/// Platform Type List Response +/// +/// # 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 platform types](struct.PlatformTypeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlatformTypesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformTypesListResponse". + pub kind: Option, + /// Platform type collection. + #[serde(rename="platformTypes")] + pub platform_types: Option>, +} + +impl ResponseResult for PlatformTypesListResponse {} + + +/// A description of how user IDs are encrypted. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EncryptionInfo { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#encryptionInfo". + pub kind: Option, + /// The encryption entity ID. This should match the encryption configuration for ad serving or Data Transfer. + #[serde(rename="encryptionEntityId")] + pub encryption_entity_id: Option, + /// Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer. + #[serde(rename="encryptionSource")] + pub encryption_source: Option, + /// The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. + #[serde(rename="encryptionEntityType")] + pub encryption_entity_type: Option, +} + +impl Part for EncryptionInfo {} + + +/// Placement List Response +/// +/// # 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 placements](struct.PlacementListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsListResponse". + pub kind: Option, + /// Placement collection. + pub placements: Option>, +} + +impl ResponseResult for PlacementsListResponse {} + + +/// Ad List Response +/// +/// # 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 ads](struct.AdListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#adsListResponse". + pub kind: Option, + /// Ad collection. + pub ads: Option>, +} + +impl ResponseResult for AdsListResponse {} + + +/// The report criteria for a report of type "REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportReachCriteria { + /// Activity group. + pub activities: Option, + /// The list of dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The list of names of Reach By Frequency metrics the report should include. + #[serde(rename="reachByFrequencyMetricNames")] + pub reach_by_frequency_metric_names: Option>, + /// Custom Rich Media Events group. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option, + /// Whether to enable all reach dimension combinations in the report. Defaults to false. If enabled, the date range of the report should be within the last three months. + #[serde(rename="enableAllDimensionCombinations")] + pub enable_all_dimension_combinations: Option, +} + +impl NestedType for ReportReachCriteria {} +impl Part for ReportReachCriteria {} + + +/// The URLs where the completed report file can be downloaded. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FileUrls { + /// The URL for downloading the report data through a browser. + #[serde(rename="browserUrl")] + pub browser_url: Option, + /// The URL for downloading the report data through the API. + #[serde(rename="apiUrl")] + pub api_url: Option, +} + +impl NestedType for FileUrls {} +impl Part for FileUrls {} + + +/// Order document List Response +/// +/// # 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 order documents](struct.OrderDocumentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocumentsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocumentsListResponse". + pub kind: Option, + /// Order document collection + #[serde(rename="orderDocuments")] + pub order_documents: Option>, +} + +impl ResponseResult for OrderDocumentsListResponse {} + + +/// User Defined Variable 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 UserDefinedVariableConfiguration { + /// Data type for the variable. This is a required field. + #[serde(rename="dataType")] + pub data_type: Option, + /// User-friendly name for the variable which will appear in reports. This is a required field, must be less than 64 characters long, and cannot contain the following characters: ""<>". + #[serde(rename="reportName")] + pub report_name: Option, + /// Variable name in the tag. This is a required field. + #[serde(rename="variableType")] + pub variable_type: Option, +} + +impl Part for UserDefinedVariableConfiguration {} + + +/// Pricing Information +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Pricing { + /// Group type of this inventory item if it represents a placement group. Is null otherwise. There are two type of placement groups: PLANNING_PLACEMENT_GROUP_TYPE_PACKAGE is a simple group of inventory items that acts as a single pricing point for a group of tags. PLANNING_PLACEMENT_GROUP_TYPE_ROADBLOCK is a group of inventory items that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned inventory items to be marked as primary. + #[serde(rename="groupType")] + pub group_type: Option, + /// Start date of this inventory item. + #[serde(rename="startDate")] + pub start_date: Option, + /// Flights of this inventory item. A flight (a.k.a. pricing period) represents the inventory item pricing information for a specific period of time. + pub flights: Option>, + /// End date of this inventory item. + #[serde(rename="endDate")] + pub end_date: Option, + /// Pricing type of this inventory item. + #[serde(rename="pricingType")] + pub pricing_type: Option, + /// Cap cost type of this inventory item. + #[serde(rename="capCostType")] + pub cap_cost_type: Option, +} + +impl Part for Pricing {} + + +/// Publisher Dynamic Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityPublisherDynamicTag { + /// Whether this tag is applicable only for view-throughs. + #[serde(rename="viewThrough")] + pub view_through: Option, + /// Site ID of this dynamic tag. + #[serde(rename="siteId")] + pub site_id: Option, + /// Whether this tag is applicable only for click-throughs. + #[serde(rename="clickThrough")] + pub click_through: Option, + /// Directory site ID of this dynamic tag. This is a write-only field that can be used as an alternative to the siteId field. When this resource is retrieved, only the siteId field will be populated. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Dynamic floodlight tag. + #[serde(rename="dynamicTag")] + pub dynamic_tag: Option, +} + +impl Part for FloodlightActivityPublisherDynamicTag {} + + +/// Contains information about where a user's browser is taken after the user clicks an ad. +/// +/// # 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 landing pages](struct.LandingPageUpdateCall.html) (request|response) +/// * [list landing pages](struct.LandingPageListCall.html) (none) +/// * [patch landing pages](struct.LandingPagePatchCall.html) (request|response) +/// * [insert landing pages](struct.LandingPageInsertCall.html) (request|response) +/// * [delete landing pages](struct.LandingPageDeleteCall.html) (none) +/// * [get landing pages](struct.LandingPageGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LandingPage { + /// Whether or not this landing page will be assigned to any ads or creatives that do not have a landing page assigned explicitly. Only one default landing page is allowed per campaign. + pub default: Option, + /// URL of this landing page. This is a required field. + pub url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPage". + pub kind: Option, + /// ID of this landing page. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this landing page. This is a required field. It must be less than 256 characters long, and must be unique among landing pages of the same campaign. + pub name: Option, +} + +impl RequestValue for LandingPage {} +impl Resource for LandingPage {} +impl ResponseResult for LandingPage {} + + +/// Represents the dimensions of ads, placements, creatives, or creative assets. +/// +/// # 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 sizes](struct.SizeInsertCall.html) (request|response) +/// * [get sizes](struct.SizeGetCall.html) (response) +/// * [list sizes](struct.SizeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Size { + /// Width of this size. + pub width: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#size". + pub kind: Option, + /// Height of this size. + pub height: Option, + /// ID of this size. This is a read-only, auto-generated field. + pub id: Option, + /// IAB standard size. This is a read-only, auto-generated field. + pub iab: Option, +} + +impl RequestValue for Size {} +impl Resource for Size {} +impl ResponseResult for Size {} + + +/// Contains information about a city that can be targeted by ads. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct City { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#city". + pub kind: Option, + /// DART ID of the country to which this city belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this city. + pub name: Option, + /// Country code of the country to which this city belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Metro region code of the metro region (DMA) to which this city belongs. + #[serde(rename="metroCode")] + pub metro_code: Option, + /// Region code of the region to which this city belongs. + #[serde(rename="regionCode")] + pub region_code: Option, + /// ID of the metro region (DMA) to which this city belongs. + #[serde(rename="metroDmaId")] + pub metro_dma_id: Option, + /// DART ID of this city. This is the ID used for targeting and generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// DART ID of the region to which this city belongs. + #[serde(rename="regionDartId")] + pub region_dart_id: Option, +} + +impl Part for City {} + + +/// Click Through URL Suffix settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClickThroughUrlSuffixProperties { + /// Click-through URL suffix to apply to all ads in this entity's scope. Must be less than 128 characters long. + #[serde(rename="clickThroughUrlSuffix")] + pub click_through_url_suffix: Option, + /// Whether this entity should override the inherited click-through URL suffix with its own defined value. + #[serde(rename="overrideInheritedSuffix")] + pub override_inherited_suffix: Option, +} + +impl Part for ClickThroughUrlSuffixProperties {} + + +/// Contains properties of a package or roadblock. +/// +/// # 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 placement groups](struct.PlacementGroupUpdateCall.html) (request|response) +/// * [patch placement groups](struct.PlacementGroupPatchCall.html) (request|response) +/// * [get placement groups](struct.PlacementGroupGetCall.html) (response) +/// * [insert placement groups](struct.PlacementGroupInsertCall.html) (request|response) +/// * [list placement groups](struct.PlacementGroupListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementGroup { + /// Comments for this placement group. + pub comment: Option, + /// ID of the primary placement, used to calculate the media cost of a roadblock (placement group). Modifying this field will automatically modify the primary field on all affected roadblock child placements. + #[serde(rename="primaryPlacementId")] + pub primary_placement_id: Option, + /// Campaign ID of this placement group. This field is required on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Dimension value for the ID of the primary placement. This is a read-only, auto-generated field. + #[serde(rename="primaryPlacementIdDimensionValue")] + pub primary_placement_id_dimension_value: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Advertiser ID of this placement group. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Directory site ID associated with this placement group. On insert, you must set either this field or the site_id field to specify the site associated with this placement group. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Information about the creation of this placement group. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Site ID associated with this placement group. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement group. This is a required field that is read-only after insertion. + #[serde(rename="siteId")] + pub site_id: Option, + /// Pricing schedule of this placement group. This field is required on insertion. + #[serde(rename="pricingSchedule")] + pub pricing_schedule: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Type of this placement group. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting. This field is required on insertion. + #[serde(rename="placementGroupType")] + pub placement_group_type: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Whether this placement group is archived. + pub archived: Option, + /// ID of this placement group. This is a read-only, auto-generated field. + pub id: Option, + /// ID of the placement strategy assigned to this placement group. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Account ID of this placement group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Subaccount ID of this placement group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this placement group. This is a required field and must be less than 256 characters long. + pub name: Option, + /// IDs of placements which are assigned to this placement group. This is a read-only, auto-generated field. + #[serde(rename="childPlacementIds")] + pub child_placement_ids: Option>, + /// Information about the most recent modification of this placement group. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroup". + pub kind: Option, + /// ID of the content category assigned to this placement group. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// External ID for this placement. + #[serde(rename="externalId")] + pub external_id: Option, + /// Dimension value for the ID of this placement group. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, +} + +impl RequestValue for PlacementGroup {} +impl Resource for PlacementGroup {} +impl ResponseResult for PlacementGroup {} + + +/// Third-party Tracking 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 ThirdPartyTrackingUrl { + /// URL for the specified third-party URL type. + pub url: Option, + /// Third-party URL type for in-stream video creatives. + #[serde(rename="thirdPartyUrlType")] + pub third_party_url_type: Option, +} + +impl Part for ThirdPartyTrackingUrl {} + + +/// Contains properties of a user role permission. +/// +/// # 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 user role permissions](struct.UserRolePermissionGetCall.html) (response) +/// * [list user role permissions](struct.UserRolePermissionListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermission { + /// ID of the permission group that this user role permission belongs to. + #[serde(rename="permissionGroupId")] + pub permission_group_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermission". + pub kind: Option, + /// Levels of availability for a user role permission. + pub availability: Option, + /// ID of this user role permission. + pub id: Option, + /// Name of this user role permission. + pub name: Option, +} + +impl Resource for UserRolePermission {} +impl ResponseResult for UserRolePermission {} + + +/// Metro List Response +/// +/// # 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 metros](struct.MetroListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MetrosListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metrosListResponse". + pub kind: Option, + /// Metro collection. + pub metros: Option>, +} + +impl ResponseResult for MetrosListResponse {} + + +/// Pricing Schedule +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PricingSchedule { + /// Placement start date. This date must be later than, or the same day as, the campaign start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This field is required on insertion. + #[serde(rename="startDate")] + pub start_date: Option, + /// Placement end date. This date must be later than, or the same day as, the placement start date, but not later than the campaign end date. If, for example, you set 6/25/2015 as both the start and end dates, the effective placement date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This field is required on insertion. + #[serde(rename="endDate")] + pub end_date: Option, + /// Whether this placement is flighted. If true, pricing periods will be computed automatically. + pub flighted: Option, + /// Whether cap costs are ignored by ad serving. + #[serde(rename="disregardOverdelivery")] + pub disregard_overdelivery: Option, + /// Placement cap cost option. + #[serde(rename="capCostOption")] + pub cap_cost_option: Option, + /// Pricing periods for this placement. + #[serde(rename="pricingPeriods")] + pub pricing_periods: Option>, + /// Placement pricing type. This field is required on insertion. + #[serde(rename="pricingType")] + pub pricing_type: Option, + /// Testing start date of this placement. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. + #[serde(rename="testingStartDate")] + pub testing_start_date: Option, + /// Floodlight activity ID associated with this placement. This field should be set when placement pricing type is set to PRICING_TYPE_CPA. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, +} + +impl Part for PricingSchedule {} + + +/// Account List Response +/// +/// # 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 accounts](struct.AccountListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountsListResponse". + pub kind: Option, + /// Account collection. + pub accounts: Option>, +} + +impl ResponseResult for AccountsListResponse {} + + +/// Contains information about an operating system that can be targeted by ads. +/// +/// # 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 operating systems](struct.OperatingSystemGetCall.html) (response) +/// * [list operating systems](struct.OperatingSystemListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystem { + /// Whether this operating system is for mobile. + pub mobile: Option, + /// DART ID of this operating system. This is the ID used for targeting. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Whether this operating system is for desktop. + pub desktop: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystem". + pub kind: Option, + /// Name of this operating system. + pub name: Option, +} + +impl Resource for OperatingSystem {} +impl ResponseResult for OperatingSystem {} + + +/// The original conversion that was inserted or updated and whether there were any errors. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionStatus { + /// The original conversion that was inserted or updated. + pub conversion: Option, + /// A list of errors related to this conversion. + pub errors: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionStatus". + pub kind: Option, +} + +impl Part for ConversionStatus {} + + +/// Represents an activity group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Activities { + /// The kind of resource this is, in this case dfareporting#activities. + pub kind: Option, + /// List of activity filters. The dimension values need to be all either of type "dfa:activity" or "dfa:activityGroup". + pub filters: Option>, + /// List of names of floodlight activity metrics. + #[serde(rename="metricNames")] + pub metric_names: Option>, +} + +impl Part for Activities {} + + +/// A group clause made up of list population terms representing constraints joined by ORs. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationClause { + /// Terms of this list population clause. Each clause is made up of list population terms representing constraints and are joined by ORs. + pub terms: Option>, +} + +impl Part for ListPopulationClause {} + + +/// Flight +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Flight { + /// Rate or cost of this flight. + #[serde(rename="rateOrCost")] + pub rate_or_cost: Option, + /// Inventory item flight start date. + #[serde(rename="startDate")] + pub start_date: Option, + /// Units of this flight. + pub units: Option, + /// Inventory item flight end date. + #[serde(rename="endDate")] + pub end_date: Option, +} + +impl Part for Flight {} + + +/// Represents a sorted dimension. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SortedDimension { + /// The kind of resource this is, in this case dfareporting#sortedDimension. + pub kind: Option, + /// The name of the dimension. + pub name: Option, + /// An optional sort order for the dimension column. + #[serde(rename="sortOrder")] + pub sort_order: Option, +} + +impl Part for SortedDimension {} + + +/// Placement Strategy List Response +/// +/// # 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 placement strategies](struct.PlacementStrategyListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementStrategiesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategiesListResponse". + pub kind: Option, + /// Placement strategy collection. + #[serde(rename="placementStrategies")] + pub placement_strategies: Option>, +} + +impl ResponseResult for PlacementStrategiesListResponse {} + + +/// Third Party Authentication Token +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThirdPartyAuthenticationToken { + /// Name of the third-party authentication token. + pub name: Option, + /// Value of the third-party authentication token. This is a read-only, auto-generated field. + pub value: Option, +} + +impl Part for ThirdPartyAuthenticationToken {} + + +/// Groups advertisers together so that reports can be generated for the entire group at once. +/// +/// # 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 advertiser groups](struct.AdvertiserGroupDeleteCall.html) (none) +/// * [get advertiser groups](struct.AdvertiserGroupGetCall.html) (response) +/// * [update advertiser groups](struct.AdvertiserGroupUpdateCall.html) (request|response) +/// * [list advertiser groups](struct.AdvertiserGroupListCall.html) (none) +/// * [patch advertiser groups](struct.AdvertiserGroupPatchCall.html) (request|response) +/// * [insert advertiser groups](struct.AdvertiserGroupInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertiserGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroup". + pub kind: Option, + /// Account ID of this advertiser group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this advertiser group. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this advertiser group. This is a required field and must be less than 256 characters long and unique among advertiser groups of the same account. + pub name: Option, +} + +impl RequestValue for AdvertiserGroup {} +impl Resource for AdvertiserGroup {} +impl ResponseResult for AdvertiserGroup {} + + +/// FsCommand. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FsCommand { + /// Height of the window. + #[serde(rename="windowHeight")] + pub window_height: Option, + /// Distance from the top of the browser. Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. + pub top: Option, + /// Width of the window. + #[serde(rename="windowWidth")] + pub window_width: Option, + /// Position in the browser where the window will open. + #[serde(rename="positionOption")] + pub position_option: Option, + /// Distance from the left of the browser.Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. + pub left: Option, +} + +impl Part for FsCommand {} + + +/// Creative optimization settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeOptimizationConfiguration { + /// List of optimization activities associated with this configuration. + #[serde(rename="optimizationActivitys")] + pub optimization_activitys: Option>, + /// ID of this creative optimization config. This field is auto-generated when the campaign is inserted or updated. It can be null for existing campaigns. + pub id: Option, + /// Name of this creative optimization config. This is a required field and must be less than 129 characters long. + pub name: Option, + /// Optimization model for this configuration. + #[serde(rename="optimizationModel")] + pub optimization_model: Option, +} + +impl Part for CreativeOptimizationConfiguration {} + + +/// Creative Group List Response +/// +/// # 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 creative groups](struct.CreativeGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Creative group collection. + #[serde(rename="creativeGroups")] + pub creative_groups: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroupsListResponse". + pub kind: Option, +} + +impl ResponseResult for CreativeGroupsListResponse {} + + +/// Offset Position. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OffsetPosition { + /// Offset distance from top side of an asset or a window. + pub top: Option, + /// Offset distance from left side of an asset or a window. + pub left: Option, +} + +impl Part for OffsetPosition {} + + +/// Target Window. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetWindow { + /// User-entered value. + #[serde(rename="customHtml")] + pub custom_html: Option, + /// Type of browser window for which the backup image of the flash creative can be displayed. + #[serde(rename="targetWindowOption")] + pub target_window_option: Option, +} + +impl Part for TargetWindow {} + + +/// Site Contact +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SiteContact { + /// First name of this site contact. + #[serde(rename="firstName")] + pub first_name: Option, + /// Title or designation of this site contact. + pub title: Option, + /// Last name of this site contact. + #[serde(rename="lastName")] + pub last_name: Option, + /// Site contact type. + #[serde(rename="contactType")] + pub contact_type: Option, + /// ID of this site contact. This is a read-only, auto-generated field. + pub id: Option, + /// Primary phone number of this site contact. + pub phone: Option, + /// Address of this site contact. + pub address: Option, + /// Email address of this site contact. This is a required field. + pub email: Option, +} + +impl Part for SiteContact {} + + +/// Creative Rotation. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeRotation { + /// Creative assignments in this creative rotation. + #[serde(rename="creativeAssignments")] + pub creative_assignments: Option>, + /// Strategy for calculating weights. Used with CREATIVE_ROTATION_TYPE_RANDOM. + #[serde(rename="weightCalculationStrategy")] + pub weight_calculation_strategy: Option, + /// Creative optimization configuration that is used by this ad. It should refer to one of the existing optimization configurations in the ad's campaign. If it is unset or set to 0, then the campaign's default optimization configuration will be used for this ad. + #[serde(rename="creativeOptimizationConfigurationId")] + pub creative_optimization_configuration_id: Option, + /// Type of creative rotation. Can be used to specify whether to use sequential or random rotation. + #[serde(rename="type")] + pub type_: Option, +} + +impl Part for CreativeRotation {} + + +/// Contains information about a metro region that can be targeted by ads. +/// +/// # 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 metros](struct.MetroListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Metro { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metro". + pub kind: Option, + /// DART ID of the country to which this metro region belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this metro region. + pub name: Option, + /// Country code of the country to which this metro region belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Metro code of this metro region. This is equivalent to dma_id. + #[serde(rename="metroCode")] + pub metro_code: Option, + /// DART ID of this metro region. + #[serde(rename="dartId")] + pub dart_id: Option, + /// DMA ID of this metro region. This is the ID used for targeting and generating reports, and is equivalent to metro_code. + #[serde(rename="dmaId")] + pub dma_id: Option, +} + +impl Resource for Metro {} + + +/// Contains information about a country that can be targeted by ads. +/// +/// # 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 countries](struct.CountryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Country { + /// DART ID of this country. This is the ID used for targeting and generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Whether ad serving supports secure servers in this country. + #[serde(rename="sslEnabled")] + pub ssl_enabled: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#country". + pub kind: Option, + /// Country code. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Name of this country. + pub name: Option, +} + +impl ResponseResult for Country {} + + +/// Postal Code List Response +/// +/// # 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 postal codes](struct.PostalCodeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PostalCodesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCodesListResponse". + pub kind: Option, + /// Postal code collection. + #[serde(rename="postalCodes")] + pub postal_codes: Option>, +} + +impl ResponseResult for PostalCodesListResponse {} + + +/// Tag Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagSetting { + /// Whether static landing page URLs should be included in the tags. This setting applies only to placements. + #[serde(rename="includeClickThroughUrls")] + pub include_click_through_urls: Option, + /// Whether click-tracking string should be included in the tags. + #[serde(rename="includeClickTracking")] + pub include_click_tracking: Option, + /// Additional key-values to be included in tags. Each key-value pair must be of the form key=value, and pairs must be separated by a semicolon (;). Keys and values must not contain commas. For example, id=2;color=red is a valid value for this field. + #[serde(rename="additionalKeyValues")] + pub additional_key_values: Option, + /// Option specifying how keywords are embedded in ad tags. This setting can be used to specify whether keyword placeholders are inserted in placement tags for this site. Publishers can then add keywords to those placeholders. + #[serde(rename="keywordOption")] + pub keyword_option: Option, +} + +impl Part for TagSetting {} + + +/// Contains properties of a creative field. +/// +/// # 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 creative fields](struct.CreativeFieldListCall.html) (none) +/// * [update creative fields](struct.CreativeFieldUpdateCall.html) (request|response) +/// * [get creative fields](struct.CreativeFieldGetCall.html) (response) +/// * [insert creative fields](struct.CreativeFieldInsertCall.html) (request|response) +/// * [delete creative fields](struct.CreativeFieldDeleteCall.html) (none) +/// * [patch creative fields](struct.CreativeFieldPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeField { + /// Advertiser ID of this creative field. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField". + pub kind: Option, + /// Subaccount ID of this creative field. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this creative field. This is a required field and must be less than 256 characters long and unique among creative fields of the same advertiser. + pub name: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this creative field. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this creative field. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for CreativeField {} +impl Resource for CreativeField {} +impl ResponseResult for CreativeField {} + + +/// Creative Field Value List Response +/// +/// # 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 creative field values](struct.CreativeFieldValueListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldValuesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValuesListResponse". + pub kind: Option, + /// Creative field value collection. + #[serde(rename="creativeFieldValues")] + pub creative_field_values: Option>, +} + +impl ResponseResult for CreativeFieldValuesListResponse {} + + +/// The properties of the report. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportFloodlightCriteriaReportProperties { + /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. + #[serde(rename="includeUnattributedIPConversions")] + pub include_unattributed_ip_conversions: Option, + /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. + #[serde(rename="includeUnattributedCookieConversions")] + pub include_unattributed_cookie_conversions: Option, + /// Include conversions that have no cookie, but do have an exposure path. + #[serde(rename="includeAttributedIPConversions")] + pub include_attributed_ip_conversions: Option, +} + +impl NestedType for ReportFloodlightCriteriaReportProperties {} +impl Part for ReportFloodlightCriteriaReportProperties {} + + +/// Insert Conversions Response. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionsBatchInsertResponse { + /// The status of each conversion's insertion status. The status is returned in the same order that conversions are inserted. + pub status: Option>, + /// Indicates that some or all conversions failed to insert. + #[serde(rename="hasFailures")] + pub has_failures: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertResponse". + pub kind: Option, +} + +impl ResponseResult for ConversionsBatchInsertResponse {} + + +/// Contains properties of a Site Directory contact. +/// +/// # 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 directory site contacts](struct.DirectorySiteContactGetCall.html) (response) +/// * [list directory site contacts](struct.DirectorySiteContactListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContact { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContact". + pub kind: Option, + /// First name of this directory site contact. + #[serde(rename="firstName")] + pub first_name: Option, + /// Title or designation of this directory site contact. + pub title: Option, + /// Last name of this directory site contact. + #[serde(rename="lastName")] + pub last_name: Option, + /// ID of this directory site contact. This is a read-only, auto-generated field. + pub id: Option, + /// Phone number of this directory site contact. + pub phone: Option, + /// Directory site contact role. + pub role: Option, + /// Address of this directory site contact. + pub address: Option, + /// Directory site contact type. + #[serde(rename="type")] + pub type_: Option, + /// Email address of this directory site contact. + pub email: Option, +} + +impl Resource for DirectorySiteContact {} +impl ResponseResult for DirectorySiteContact {} + + +/// Represents a DimensionValue 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValue { + /// The name of the dimension. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The kind of resource this is, in this case dfareporting#dimensionValue. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// Determines how the 'value' field is matched when filtering. If not specified, defaults to EXACT. If set to WILDCARD_EXPRESSION, '*' is allowed as a placeholder for variable length character sequences, and it can be escaped with a backslash. Note, only paid search dimensions ('dfa:paidSearch*') allow a matchType other than EXACT. + #[serde(rename="matchType")] + pub match_type: Option, + /// The ID associated with the value if available. + pub id: Option, + /// The value of the dimension. + pub value: Option, +} + +impl Resource for DimensionValue {} + + +/// Content Category List Response +/// +/// # 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 content categories](struct.ContentCategoryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentCategoriesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategoriesListResponse". + pub kind: Option, + /// Content category collection. + #[serde(rename="contentCategories")] + pub content_categories: Option>, +} + +impl ResponseResult for ContentCategoriesListResponse {} + + +/// Floodlight Configuration List Response +/// +/// # 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 floodlight configurations](struct.FloodlightConfigurationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightConfigurationsListResponse { + /// Floodlight configuration collection. + #[serde(rename="floodlightConfigurations")] + pub floodlight_configurations: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfigurationsListResponse". + pub kind: Option, +} + +impl ResponseResult for FloodlightConfigurationsListResponse {} + + +/// Describes properties of a DoubleClick Planning order. +/// +/// # 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 orders](struct.OrderListCall.html) (none) +/// * [get orders](struct.OrderGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Order { + /// Terms and conditions of this order. + #[serde(rename="termsAndConditions")] + pub terms_and_conditions: Option, + /// Name of the buyer organization. + #[serde(rename="buyerOrganizationName")] + pub buyer_organization_name: Option, + /// Advertiser ID of this order. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Site IDs this order is associated with. + #[serde(rename="siteId")] + pub site_id: Option>, + /// Buyer invoice ID associated with this order. + #[serde(rename="buyerInvoiceId")] + pub buyer_invoice_id: Option, + /// ID of the terms and conditions template used in this order. + #[serde(rename="planningTermId")] + pub planning_term_id: Option, + /// ID of this order. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this order. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#order". + pub kind: Option, + /// Subaccount ID of this order. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this order. + pub name: Option, + /// Contacts for this order. + pub contacts: Option>, + /// Information about the most recent modification of this order. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Notes of this order. + pub notes: Option, + /// Name of the seller organization. + #[serde(rename="sellerOrganizationName")] + pub seller_organization_name: Option, + /// Comments in this order. + pub comments: Option, + /// IDs for users that have to approve documents created for this order. + #[serde(rename="approverUserProfileIds")] + pub approver_user_profile_ids: Option>, + /// Seller order ID associated with this order. + #[serde(rename="sellerOrderId")] + pub seller_order_id: Option, + /// Project ID of this order. + #[serde(rename="projectId")] + pub project_id: Option, + /// Free-form site names this order is associated with. + #[serde(rename="siteNames")] + pub site_names: Option>, +} + +impl Resource for Order {} +impl ResponseResult for Order {} + + +/// A custom floodlight variable. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CustomFloodlightVariable { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#customFloodlightVariable". + pub kind: Option, + /// The type of custom floodlight variable to supply a value for. These map to the "u[1-20]=" in the tags. + #[serde(rename="type")] + pub type_: Option, + /// The value of the custom floodlight variable. The length of string must not exceed 50 characters. + pub value: Option, +} + +impl Part for CustomFloodlightVariable {} + + +/// AccountPermissions contains information about a particular account permission. Some features of DCM require an account permission to be present in the account. +/// +/// # 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 account permissions](struct.AccountPermissionListCall.html) (none) +/// * [get account permissions](struct.AccountPermissionGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermission { + /// Permission group of this account permission. + #[serde(rename="permissionGroupId")] + pub permission_group_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermission". + pub kind: Option, + /// Name of this account permission. + pub name: Option, + /// Administrative level required to enable this account permission. + pub level: Option, + /// Account profiles associated with this account permission. + /// + /// Possible values are: + /// - "ACCOUNT_PROFILE_BASIC" + /// - "ACCOUNT_PROFILE_STANDARD" + #[serde(rename="accountProfiles")] + pub account_profiles: Option>, + /// ID of this account permission. + pub id: Option, +} + +impl Resource for AccountPermission {} +impl ResponseResult for AccountPermission {} + + +/// Contains properties of a DoubleClick Planning project. +/// +/// # 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 projects](struct.ProjectGetCall.html) (response) +/// * [list projects](struct.ProjectListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Project { + /// Start date of the project. + #[serde(rename="startDate")] + pub start_date: Option, + /// CPM that the advertiser is targeting. + #[serde(rename="targetCpmNanos")] + pub target_cpm_nanos: Option, + /// End date of the project. + #[serde(rename="endDate")] + pub end_date: Option, + /// Client billing code of this project. + #[serde(rename="clientBillingCode")] + pub client_billing_code: Option, + /// Overview of this project. + pub overview: Option, + /// Number of clicks that the advertiser is targeting. + #[serde(rename="targetClicks")] + pub target_clicks: Option, + /// CPA that the advertiser is targeting. + #[serde(rename="targetCpaNanos")] + pub target_cpa_nanos: Option, + /// Advertiser ID of this project. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Number of impressions that the advertiser is targeting. + #[serde(rename="targetImpressions")] + pub target_impressions: Option, + /// Subaccount ID of this project. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Audience gender of this project. + #[serde(rename="audienceGender")] + pub audience_gender: Option, + /// ID of this project. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this project. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#project". + pub kind: Option, + /// CPC that the advertiser is targeting. + #[serde(rename="targetCpcNanos")] + pub target_cpc_nanos: Option, + /// Name of this project. + pub name: Option, + /// Information about the most recent modification of this project. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Budget of this project in the currency specified by the current account. The value stored in this field represents only the non-fractional amount. For example, for USD, the smallest value that can be represented by this field is 1 US dollar. + pub budget: Option, + /// Audience age group of this project. + #[serde(rename="audienceAgeGroup")] + pub audience_age_group: Option, + /// Number of conversions that the advertiser is targeting. + #[serde(rename="targetConversions")] + pub target_conversions: Option, + /// Name of the project client. + #[serde(rename="clientName")] + pub client_name: Option, +} + +impl Resource for Project {} +impl ResponseResult for Project {} + + +/// Popup Window Properties. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PopupWindowProperties { + /// Whether to display the browser status bar. + #[serde(rename="showStatusBar")] + pub show_status_bar: Option, + /// Whether to display the browser scroll bar. + #[serde(rename="showScrollBar")] + pub show_scroll_bar: Option, + /// Whether to display the browser address bar. + #[serde(rename="showAddressBar")] + pub show_address_bar: Option, + /// Whether to display the browser menu bar. + #[serde(rename="showMenuBar")] + pub show_menu_bar: Option, + /// Title of popup window. + pub title: Option, + /// Upper-left corner coordinates of the popup window. Applicable if positionType is COORDINATES. + pub offset: Option, + /// Popup window position either centered or at specific coordinate. + #[serde(rename="positionType")] + pub position_type: Option, + /// Whether to display the browser tool bar. + #[serde(rename="showToolBar")] + pub show_tool_bar: Option, + /// Popup dimension for a creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID + pub dimension: Option, +} + +impl Part for PopupWindowProperties {} + + +/// Contains properties of a DCM ad. +/// +/// # 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 ads](struct.AdPatchCall.html) (request|response) +/// * [list ads](struct.AdListCall.html) (none) +/// * [insert ads](struct.AdInsertCall.html) (request|response) +/// * [get ads](struct.AdGetCall.html) (response) +/// * [update ads](struct.AdUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Ad { + /// Click-through URL suffix properties for this ad. Applies to the URL in the ad or (if overriding ad properties) the URL in the creative. + #[serde(rename="clickThroughUrlSuffixProperties")] + pub click_through_url_suffix_properties: Option, + /// Campaign ID of this ad. This is a required field on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Advertiser ID of this ad. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="geoTargeting")] + pub geo_targeting: Option, + /// Comments for this ad. + pub comments: Option, + /// Delivery schedule information for this ad. Applicable when type is AD_SERVING_STANDARD_AD or AD_SERVING_TRACKING. This field along with subfields priority and impressionRatio are required on insertion when type is AD_SERVING_STANDARD_AD. + #[serde(rename="deliverySchedule")] + pub delivery_schedule: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Event tag overrides for this ad. + #[serde(rename="eventTagOverrides")] + pub event_tag_overrides: Option>, + /// ID of this ad. This is a read-only, auto-generated field. + pub id: Option, + /// Size of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. + pub size: Option, + /// Whether this ad is archived. + pub archived: Option, + /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="technologyTargeting")] + pub technology_targeting: Option, + /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment. + #[serde(rename="creativeRotation")] + pub creative_rotation: Option, + /// Click-through URL for this ad. This is a required field on insertion. Applicable when type is AD_SERVING_CLICK_TRACKER. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments. + #[serde(rename="creativeGroupAssignments")] + pub creative_group_assignments: Option>, + /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="remarketingListExpression")] + pub remarketing_list_expression: Option, + /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Account ID of this ad. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Type of ad. This is a required field on insertion. Note that default ads (AD_SERVING_DEFAULT_AD) cannot be created directly (see Creative resource). + #[serde(rename="type")] + pub type_: Option, + /// Whether this ad requires ssl. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="audienceSegmentId")] + pub audience_segment_id: Option, + /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="keyValueTargetingExpression")] + pub key_value_targeting_expression: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Default click-through event tag properties for this ad. + #[serde(rename="defaultClickThroughEventTagProperties")] + pub default_click_through_event_tag_properties: Option, + /// Information about the creation of this ad. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion. + #[serde(rename="startTime")] + pub start_time: Option, + /// Whether this ad is active. + pub active: Option, + /// Compatibility of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to either rendering on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are only used for existing default ads. New mobile placements must be assigned DISPLAY or DISPLAY_INTERSTITIAL and default ads created for those placements will be limited to those compatibility types. IN_STREAM_VIDEO refers to rendering in-stream video ads developed with the VAST standard. + pub compatibility: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ad". + pub kind: Option, + /// Subaccount ID of this ad. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this ad. This is a required field and must be less than 256 characters long. + pub name: Option, + /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="dayPartTargeting")] + pub day_part_targeting: Option, + /// Information about the most recent modification of this ad. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Whether this ad is ssl compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Date and time that this ad should stop serving. Must be later than the start time. This is a required field on insertion. + #[serde(rename="endTime")] + pub end_time: Option, + /// Whether this ad is a dynamic click tracker. Applicable when type is AD_SERVING_CLICK_TRACKER. This is a required field on insert, and is read-only after insert. + #[serde(rename="dynamicClickTracker")] + pub dynamic_click_tracker: Option, + /// Placement assignments for this ad. + #[serde(rename="placementAssignments")] + pub placement_assignments: Option>, +} + +impl RequestValue for Ad {} +impl Resource for Ad {} +impl ResponseResult for Ad {} + + +/// Pricing Period +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PricingSchedulePricingPeriod { + /// Units of this pricing period. + pub units: Option, + /// Pricing period start date. This date must be later than, or the same day as, the placement start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. + #[serde(rename="startDate")] + pub start_date: Option, + /// Rate or cost of this pricing period. + #[serde(rename="rateOrCostNanos")] + pub rate_or_cost_nanos: Option, + /// Pricing period end date. This date must be later than, or the same day as, the pricing period start date, but not later than the placement end date. The period end date can be the same date as the period start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective pricing period date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. + #[serde(rename="endDate")] + pub end_date: Option, + /// Comments for this pricing period. + #[serde(rename="pricingComment")] + pub pricing_comment: Option, +} + +impl Part for PricingSchedulePricingPeriod {} + + +/// Contains properties of an event tag. +/// +/// # 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 event tags](struct.EventTagDeleteCall.html) (none) +/// * [patch event tags](struct.EventTagPatchCall.html) (request|response) +/// * [list event tags](struct.EventTagListCall.html) (none) +/// * [update event tags](struct.EventTagUpdateCall.html) (request|response) +/// * [insert event tags](struct.EventTagInsertCall.html) (request|response) +/// * [get event tags](struct.EventTagGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTag { + /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field. + pub status: Option, + /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter. + #[serde(rename="siteIds")] + pub site_ids: Option>, + /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads. + #[serde(rename="enabledByDefault")] + pub enabled_by_default: Option, + /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites. + #[serde(rename="siteFilterType")] + pub site_filter_type: Option, + /// Event tag type. Can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. This is a required field. + #[serde(rename="type")] + pub type_: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this event tag. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag". + pub kind: Option, + /// Subaccount ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this event tag. This is a required field and must be less than 256 characters long. + pub name: Option, + /// Payload URL for this event tag. The URL on a click-through event tag should have a landing page URL appended to the end of it. This field is required on insertion. + pub url: Option, + /// Whether this tag is SSL-compliant or not. This is a read-only field. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Whether to remove this event tag from ads that are trafficked through DoubleClick Bid Manager to Ad Exchange. This may be useful if the event tag uses a pixel that is unapproved for Ad Exchange bids on one or more networks, such as the Google Display Network. + #[serde(rename="excludeFromAdxRequests")] + pub exclude_from_adx_requests: Option, + /// Number of times the landing page URL should be URL-escaped before being appended to the click-through event tag URL. Only applies to click-through event tags as specified by the event tag type. + #[serde(rename="urlEscapeLevels")] + pub url_escape_levels: Option, +} + +impl RequestValue for EventTag {} +impl Resource for EventTag {} +impl ResponseResult for EventTag {} + + +/// Placement Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementAssignment { + /// Whether this placement assignment is active. When true, the placement will be included in the ad's rotation. + pub active: Option, + /// Dimension value for the ID of the placement. This is a read-only, auto-generated field. + #[serde(rename="placementIdDimensionValue")] + pub placement_id_dimension_value: Option, + /// ID of the placement to be assigned. This is a required field. + #[serde(rename="placementId")] + pub placement_id: Option, + /// Whether the placement to be assigned requires SSL. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslRequired")] + pub ssl_required: Option, +} + +impl Part for PlacementAssignment {} + + +/// Represents fields that are compatible to be selected for a report of type "REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReachReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#reachReportCompatibleFields. + pub kind: Option, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, + /// Metrics which are compatible to be selected in the "reachByFrequencyMetricNames" section of the report. + #[serde(rename="reachByFrequencyMetrics")] + pub reach_by_frequency_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. + #[serde(rename="pivotedActivityMetrics")] + pub pivoted_activity_metrics: Option>, +} + +impl Part for ReachReportCompatibleFields {} + + +/// Insert Conversions Request. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionsBatchInsertRequest { + /// The set of conversions to insert. + pub conversions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertRequest". + pub kind: Option, + /// Describes how encryptedUserId is encrypted. This is a required field if encryptedUserId is used. + #[serde(rename="encryptionInfo")] + pub encryption_info: Option, +} + +impl RequestValue for ConversionsBatchInsertRequest {} + + +/// Contains properties of a site. +/// +/// # 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 sites](struct.SiteUpdateCall.html) (request|response) +/// * [list sites](struct.SiteListCall.html) (none) +/// * [insert sites](struct.SiteInsertCall.html) (request|response) +/// * [get sites](struct.SiteGetCall.html) (response) +/// * [patch sites](struct.SitePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Site { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#site". + pub kind: Option, + /// Subaccount ID of this site. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this site.This is a required field. Must be less than 128 characters long. If this site is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this site is a top-level site, and the name must be unique among top-level sites of the same account. + pub name: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Site-wide settings. + #[serde(rename="siteSettings")] + pub site_settings: Option, + /// ID of this site. This is a read-only, auto-generated field. + pub id: Option, + /// Directory site associated with this site. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Site contacts. + #[serde(rename="siteContacts")] + pub site_contacts: Option>, + /// Key name of this site. This is a read-only, auto-generated field. + #[serde(rename="keyName")] + pub key_name: Option, + /// Dimension value for the ID of this site. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether this site is approved. + pub approved: Option, + /// Account ID of this site. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for Site {} +impl Resource for Site {} +impl ResponseResult for Site {} + + +/// DFP Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DfpSettings { + /// DFP network name for this directory site. + pub dfp_network_name: Option, + /// DFP network code for this directory site. + pub dfp_network_code: Option, + /// Whether this directory site is available only via DoubleClick Publisher Portal. + #[serde(rename="publisherPortalOnly")] + pub publisher_portal_only: Option, + /// Whether this directory site accepts programmatic placements. + #[serde(rename="programmaticPlacementAccepted")] + pub programmatic_placement_accepted: Option, + /// Whether this directory site accepts publisher-paid tags. + #[serde(rename="pubPaidPlacementAccepted")] + pub pub_paid_placement_accepted: Option, +} + +impl Part for DfpSettings {} + + +/// Connection Type List Response +/// +/// # 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 connection types](struct.ConnectionTypeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConnectionTypesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionTypesListResponse". + pub kind: Option, + /// Collection of connection types such as broadband and mobile. + #[serde(rename="connectionTypes")] + pub connection_types: Option>, +} + +impl ResponseResult for ConnectionTypesListResponse {} + + +/// Contains properties of a Floodlight configuration. +/// +/// # 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 floodlight configurations](struct.FloodlightConfigurationGetCall.html) (response) +/// * [update floodlight configurations](struct.FloodlightConfigurationUpdateCall.html) (request|response) +/// * [patch floodlight configurations](struct.FloodlightConfigurationPatchCall.html) (request|response) +/// * [list floodlight configurations](struct.FloodlightConfigurationListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightConfiguration { + /// List of user defined variables enabled for this configuration. + #[serde(rename="userDefinedVariableConfigurations")] + pub user_defined_variable_configurations: Option>, + /// List of third-party authentication tokens enabled for this configuration. + #[serde(rename="thirdPartyAuthenticationTokens")] + pub third_party_authentication_tokens: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfiguration". + pub kind: Option, + /// Advertiser ID of the parent advertiser of this floodlight configuration. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Configuration settings for dynamic and image floodlight tags. + #[serde(rename="tagSettings")] + pub tag_settings: Option, + /// Whether in-app attribution tracking is enabled. + #[serde(rename="inAppAttributionTrackingEnabled")] + pub in_app_attribution_tracking_enabled: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Subaccount ID of this floodlight configuration. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// ID of this floodlight configuration. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this floodlight configuration. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Types of attribution options for natural search conversions. + #[serde(rename="naturalSearchConversionAttributionOption")] + pub natural_search_conversion_attribution_option: Option, + /// Settings for DCM Omniture integration. + #[serde(rename="omnitureSettings")] + pub omniture_settings: Option, + /// Whether the exposure-to-conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting. + #[serde(rename="exposureToConversionEnabled")] + pub exposure_to_conversion_enabled: Option, + /// Lookback window settings for this floodlight configuration. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Day that will be counted as the first day of the week in reports. This is a required field. + #[serde(rename="firstDayOfWeek")] + pub first_day_of_week: Option, + /// List of standard variables enabled for this configuration. + /// + /// Acceptable values are: + /// - "ORD" + /// - "NUM" + #[serde(rename="standardVariableTypes")] + pub standard_variable_types: Option>, + /// Whether advertiser data is shared with Google Analytics. + #[serde(rename="analyticsDataSharingEnabled")] + pub analytics_data_sharing_enabled: Option, + /// Dimension value for the ID of this floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, +} + +impl RequestValue for FloodlightConfiguration {} +impl Resource for FloodlightConfiguration {} +impl ResponseResult for FloodlightConfiguration {} + + +/// Represents a date range. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DateRange { + /// The start date of the date range, inclusive. A string of the format: "yyyy-MM-dd". + #[serde(rename="startDate")] + pub start_date: Option, + /// The kind of resource this is, in this case dfareporting#dateRange. + pub kind: Option, + /// The end date of the date range, inclusive. A string of the format: "yyyy-MM-dd". + #[serde(rename="endDate")] + pub end_date: Option, + /// The date range relative to the date of when the report is run. + #[serde(rename="relativeDateRange")] + pub relative_date_range: Option, +} + +impl Part for DateRange {} + + +/// Account Permission Group List Response +/// +/// # 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 account permission groups](struct.AccountPermissionGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionGroupsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroupsListResponse". + pub kind: Option, + /// Account permission group collection. + #[serde(rename="accountPermissionGroups")] + pub account_permission_groups: Option>, +} + +impl ResponseResult for AccountPermissionGroupsListResponse {} + + +/// Size List Response +/// +/// # 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 sizes](struct.SizeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SizesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sizesListResponse". + pub kind: Option, + /// Size collection. + pub sizes: Option>, +} + +impl ResponseResult for SizesListResponse {} + + +/// User Role List Response +/// +/// # 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 user roles](struct.UserRoleListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolesListResponse". + pub kind: Option, + /// User role collection. + #[serde(rename="userRoles")] + pub user_roles: Option>, +} + +impl ResponseResult for UserRolesListResponse {} + + +/// Floodlight Activity List Response +/// +/// # 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 floodlight activities](struct.FloodlightActivityListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivitiesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesListResponse". + pub kind: Option, + /// Floodlight activity collection. + #[serde(rename="floodlightActivities")] + pub floodlight_activities: Option>, +} + +impl ResponseResult for FloodlightActivitiesListResponse {} + + +/// Contains properties of auser role, which is used to manage user access. +/// +/// # 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 user roles](struct.UserRoleInsertCall.html) (request|response) +/// * [update user roles](struct.UserRoleUpdateCall.html) (request|response) +/// * [delete user roles](struct.UserRoleDeleteCall.html) (none) +/// * [patch user roles](struct.UserRolePatchCall.html) (request|response) +/// * [list user roles](struct.UserRoleListCall.html) (none) +/// * [get user roles](struct.UserRoleGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRole { + /// Whether this is a default user role. Default user roles are created by the system for the account/subaccount and cannot be modified or deleted. Each default user role comes with a basic set of preassigned permissions. + #[serde(rename="defaultUserRole")] + pub default_user_role: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRole". + pub kind: Option, + /// Subaccount ID of this user role. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this user role. This is a required field. Must be less than 256 characters long. If this user role is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this user role is a top-level user role, and the name must be unique among top-level user roles of the same account. + pub name: Option, + /// ID of the user role that this user role is based on or copied from. This is a required field. + #[serde(rename="parentUserRoleId")] + pub parent_user_role_id: Option, + /// Account ID of this user role. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this user role. This is a read-only, auto-generated field. + pub id: Option, + /// List of permissions associated with this user role. + pub permissions: Option>, +} + +impl RequestValue for UserRole {} +impl Resource for UserRole {} +impl ResponseResult for UserRole {} + + + +// ################### +// MethodBuilders ### +// ################# + +/// A builder providing access to all methods supported on *conversion* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `batchinsert(...)` +/// // to build up your call. +/// let rb = hub.conversions(); +/// # } +/// ``` +pub struct ConversionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ConversionMethods<'a, C, A> {} + +impl<'a, C, A> ConversionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts conversions. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn batchinsert(&self, request: ConversionsBatchInsertRequest, profile_id: &str) -> ConversionBatchinsertCall<'a, C, A> { + ConversionBatchinsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRolePermissionGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_role_permission_groups(); +/// # } +/// ``` +pub struct UserRolePermissionGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRolePermissionGroupMethods<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role permission group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role permission group ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + UserRolePermissionGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 list of all supported user role permission groups. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRolePermissionGroupListCall<'a, C, A> { + UserRolePermissionGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *platformType* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.platform_types(); +/// # } +/// ``` +pub struct PlatformTypeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlatformTypeMethods<'a, C, A> {} + +impl<'a, C, A> PlatformTypeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one platform type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Platform type ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlatformTypeGetCall<'a, C, A> { + PlatformTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 platform types. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlatformTypeListCall<'a, C, A> { + PlatformTypeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeFieldValue* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.creative_field_values(); +/// # } +/// ``` +pub struct CreativeFieldValueMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeFieldValueMethods<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field value. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn patch(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + CreativeFieldValuePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative field value by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn get(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueGetCall<'a, C, A> { + CreativeFieldValueGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing creative field value. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn delete(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + CreativeFieldValueDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative field value. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn insert(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + CreativeFieldValueInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_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 creative field value. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn update(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + CreativeFieldValueUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.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 creative field values, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn list(&self, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueListCall<'a, C, A> { + CreativeFieldValueListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeField* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.creative_fields(); +/// # } +/// ``` +pub struct CreativeFieldMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeFieldMethods<'a, C, A> {} + +impl<'a, C, A> CreativeFieldMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: CreativeField, profile_id: &str) -> CreativeFieldUpdateCall<'a, C, A> { + CreativeFieldUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 creative fields, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeFieldListCall<'a, C, A> { + CreativeFieldListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing creative field. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn delete(&self, profile_id: &str, id: &str) -> CreativeFieldDeleteCall<'a, C, A> { + CreativeFieldDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative field by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn get(&self, profile_id: &str, id: &str) -> CreativeFieldGetCall<'a, C, A> { + CreativeFieldGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative field. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: CreativeField, profile_id: &str) -> CreativeFieldInsertCall<'a, C, A> { + CreativeFieldInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 creative field. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn patch(&self, request: CreativeField, profile_id: &str, id: &str) -> CreativeFieldPatchCall<'a, C, A> { + CreativeFieldPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRole* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_roles(); +/// # } +/// ``` +pub struct UserRoleMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRoleMethods<'a, C, A> {} + +impl<'a, C, A> UserRoleMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new user role. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: UserRole, profile_id: &str) -> UserRoleInsertCall<'a, C, A> { + UserRoleInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRoleGetCall<'a, C, A> { + UserRoleGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 user role. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: UserRole, profile_id: &str) -> UserRoleUpdateCall<'a, C, A> { + UserRoleUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing user role. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn delete(&self, profile_id: &str, id: &str) -> UserRoleDeleteCall<'a, C, A> { + UserRoleDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 user role. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn patch(&self, request: UserRole, profile_id: &str, id: &str) -> UserRolePatchCall<'a, C, A> { + UserRolePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 user roles, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRoleListCall<'a, C, A> { + UserRoleListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _account_user_role_only: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *operatingSystemVersion* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.operating_system_versions(); +/// # } +/// ``` +pub struct OperatingSystemVersionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OperatingSystemVersionMethods<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system version by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Operating system version ID. + pub fn get(&self, profile_id: &str, id: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + OperatingSystemVersionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 operating system versions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> OperatingSystemVersionListCall<'a, C, A> { + OperatingSystemVersionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *landingPage* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.landing_pages(); +/// # } +/// ``` +pub struct LandingPageMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for LandingPageMethods<'a, C, A> {} + +impl<'a, C, A> LandingPageMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one campaign landing page by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn get(&self, profile_id: &str, campaign_id: &str, id: &str) -> LandingPageGetCall<'a, C, A> { + LandingPageGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: 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 campaign landing page. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn update(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageUpdateCall<'a, C, A> { + LandingPageUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.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 landing pages for the specified campaign. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn list(&self, profile_id: &str, campaign_id: &str) -> LandingPageListCall<'a, C, A> { + LandingPageListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new landing page for the specified campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn insert(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageInsertCall<'a, C, A> { + LandingPageInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_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 campaign landing page. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn patch(&self, request: LandingPage, profile_id: &str, campaign_id: &str, id: &str) -> LandingPagePatchCall<'a, C, A> { + LandingPagePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing campaign landing page. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn delete(&self, profile_id: &str, campaign_id: &str, id: &str) -> LandingPageDeleteCall<'a, C, A> { + LandingPageDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeAsset* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.creative_assets(); +/// # } +/// ``` +pub struct CreativeAssetMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeAssetMethods<'a, C, A> {} + +impl<'a, C, A> CreativeAssetMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative asset. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Advertiser ID of this creative. This is a required field. + pub fn insert(&self, request: CreativeAssetMetadata, profile_id: &str, advertiser_id: &str) -> CreativeAssetInsertCall<'a, C, A> { + CreativeAssetInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *campaignCreativeAssociation* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.campaign_creative_associations(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CampaignCreativeAssociationMethods<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Campaign ID in this association. + pub fn insert(&self, request: CampaignCreativeAssociation, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + CampaignCreativeAssociationInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.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 creative IDs associated with the specified campaign. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Campaign ID in this association. + pub fn list(&self, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + CampaignCreativeAssociationListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _sort_order: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *changeLog* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.change_logs(); +/// # } +/// ``` +pub struct ChangeLogMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ChangeLogMethods<'a, C, A> {} + +impl<'a, C, A> ChangeLogMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of change logs. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ChangeLogListCall<'a, C, A> { + ChangeLogListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _user_profile_ids: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _object_type: Default::default(), + _object_ids: Default::default(), + _min_change_time: Default::default(), + _max_results: Default::default(), + _max_change_time: Default::default(), + _ids: Default::default(), + _action: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one change log by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Change log ID. + pub fn get(&self, profile_id: &str, id: &str) -> ChangeLogGetCall<'a, C, A> { + ChangeLogGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *remarketingListShare* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.remarketing_list_shares(); +/// # } +/// ``` +pub struct RemarketingListShareMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for RemarketingListShareMethods<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list share by remarketing list ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `remarketingListId` - Remarketing list ID. + pub fn get(&self, profile_id: &str, remarketing_list_id: &str) -> RemarketingListShareGetCall<'a, C, A> { + RemarketingListShareGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _remarketing_list_id: remarketing_list_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 remarketing list share. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `remarketingListId` - Remarketing list ID. + pub fn patch(&self, request: RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, C, A> { + RemarketingListSharePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _remarketing_list_id: remarketing_list_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 remarketing list share. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: RemarketingListShare, profile_id: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + RemarketingListShareUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *report* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.reports(); +/// # } +/// ``` +pub struct ReportMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {} + +impl<'a, C, A> ReportMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Runs a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + pub fn run(&self, profile_id: &str, report_id: &str) -> ReportRunCall<'a, C, A> { + ReportRunCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _synchronous: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn patch(&self, request: Report, profile_id: &str, report_id: &str) -> ReportPatchCall<'a, C, A> { + ReportPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists files for a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the parent report. + pub fn files_list(&self, profile_id: &str, report_id: &str) -> ReportFileListCall<'a, C, A> { + ReportFileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: 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: + /// + /// Creates a report. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn insert(&self, request: Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { + ReportInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn update(&self, request: Report, profile_id: &str, report_id: &str) -> ReportUpdateCall<'a, C, A> { + ReportUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn compatible_fields_query(&self, request: Report, profile_id: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + ReportCompatibleFieldQueryCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn get(&self, profile_id: &str, report_id: &str) -> ReportGetCall<'a, C, A> { + ReportGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report file. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + /// * `fileId` - The ID of the report file. + pub fn files_get(&self, profile_id: &str, report_id: &str, file_id: &str) -> ReportFileGetCall<'a, C, A> { + ReportFileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _file_id: file_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn delete(&self, profile_id: &str, report_id: &str) -> ReportDeleteCall<'a, C, A> { + ReportDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of reports. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + pub fn list(&self, profile_id: &str) -> ReportListCall<'a, C, A> { + ReportListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _scope: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *advertiser* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.advertisers(); +/// # } +/// ``` +pub struct AdvertiserMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdvertiserMethods<'a, C, A> {} + +impl<'a, C, A> AdvertiserMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new advertiser. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Advertiser, profile_id: &str) -> AdvertiserInsertCall<'a, C, A> { + AdvertiserInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser ID. + pub fn patch(&self, request: Advertiser, profile_id: &str, id: &str) -> AdvertiserPatchCall<'a, C, A> { + AdvertiserPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 advertisers, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdvertiserListCall<'a, C, A> { + AdvertiserListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _status: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _only_parent: Default::default(), + _max_results: Default::default(), + _include_advertisers_without_groups_only: Default::default(), + _ids: Default::default(), + _floodlight_configuration_ids: Default::default(), + _advertiser_group_ids: 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 advertiser. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Advertiser, profile_id: &str) -> AdvertiserUpdateCall<'a, C, A> { + AdvertiserUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one advertiser by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGetCall<'a, C, A> { + AdvertiserGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *dimensionValue* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `query(...)` +/// // to build up your call. +/// let rb = hub.dimension_values(); +/// # } +/// ``` +pub struct DimensionValueMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DimensionValueMethods<'a, C, A> {} + +impl<'a, C, A> DimensionValueMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of report dimension values for a list of filters. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn query(&self, request: DimensionValueRequest, profile_id: &str) -> DimensionValueQueryCall<'a, C, A> { + DimensionValueQueryCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightActivityGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_activity_groups(); +/// # } +/// ``` +pub struct FloodlightActivityGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightActivityGroupMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight activity group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity Group ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + FloodlightActivityGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight activity group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity Group ID. + pub fn patch(&self, request: FloodlightActivityGroup, profile_id: &str, id: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + FloodlightActivityGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight activity groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + FloodlightActivityGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _type_: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _floodlight_configuration_id: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new floodlight activity group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { + FloodlightActivityGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 floodlight activity group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + FloodlightActivityGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *metro* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.metros(); +/// # } +/// ``` +pub struct MetroMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for MetroMethods<'a, C, A> {} + +impl<'a, C, A> MetroMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of metros. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> MetroListCall<'a, C, A> { + MetroListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *order* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.orders(); +/// # } +/// ``` +pub struct OrderMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OrderMethods<'a, C, A> {} + +impl<'a, C, A> OrderMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of orders, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderListCall<'a, C, A> { + OrderListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one order by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + /// * `id` - Order ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderGetCall<'a, C, A> { + OrderGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *directorySiteContact* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.directory_site_contacts(); +/// # } +/// ``` +pub struct DirectorySiteContactMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DirectorySiteContactMethods<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one directory site contact by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Directory site contact ID. + pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteContactGetCall<'a, C, A> { + DirectorySiteContactGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 directory site contacts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DirectorySiteContactListCall<'a, C, A> { + DirectorySiteContactListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userProfile* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_profiles(); +/// # } +/// ``` +pub struct UserProfileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserProfileMethods<'a, C, A> {} + +impl<'a, C, A> UserProfileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of user profiles for a user. + pub fn list(&self) -> UserProfileListCall<'a, C, A> { + UserProfileListCall { + hub: self.hub, + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one user profile by ID. + /// + /// # Arguments + /// + /// * `profileId` - The user profile ID. + pub fn get(&self, profile_id: &str) -> UserProfileGetCall<'a, C, A> { + UserProfileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *ad* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.ads(); +/// # } +/// ``` +pub struct AdMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdMethods<'a, C, A> {} + +impl<'a, C, A> AdMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing ad. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Ad ID. + pub fn patch(&self, request: Ad, profile_id: &str, id: &str) -> AdPatchCall<'a, C, A> { + AdPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new ad. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Ad, profile_id: &str) -> AdInsertCall<'a, C, A> { + AdInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 ads, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdListCall<'a, C, A> { + AdListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _type_: Default::default(), + _ssl_required: Default::default(), + _ssl_compliant: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _search_string: Default::default(), + _remarketing_list_ids: Default::default(), + _placement_ids: Default::default(), + _page_token: Default::default(), + _overridden_event_tag_id: Default::default(), + _max_results: Default::default(), + _landing_page_ids: Default::default(), + _ids: Default::default(), + _dynamic_click_tracker: Default::default(), + _creative_type: Default::default(), + _creative_optimization_configuration_ids: Default::default(), + _creative_ids: Default::default(), + _compatibility: Default::default(), + _campaign_ids: Default::default(), + _audience_segment_ids: Default::default(), + _archived: Default::default(), + _advertiser_id: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one ad by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Ad ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdGetCall<'a, C, A> { + AdGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 ad. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Ad, profile_id: &str) -> AdUpdateCall<'a, C, A> { + AdUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountPermission* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_permissions(); +/// # } +/// ``` +pub struct AccountPermissionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountPermissionMethods<'a, C, A> {} + +impl<'a, C, A> AccountPermissionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one account permission by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account permission ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGetCall<'a, C, A> { + AccountPermissionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 account permissions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountPermissionListCall<'a, C, A> { + AccountPermissionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *connectionType* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.connection_types(); +/// # } +/// ``` +pub struct ConnectionTypeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ConnectionTypeMethods<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of connection types. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ConnectionTypeListCall<'a, C, A> { + ConnectionTypeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one connection type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Connection type ID. + pub fn get(&self, profile_id: &str, id: &str) -> ConnectionTypeGetCall<'a, C, A> { + ConnectionTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *advertiserGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.advertiser_groups(); +/// # } +/// ``` +pub struct AdvertiserGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdvertiserGroupMethods<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one advertiser group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGroupGetCall<'a, C, A> { + AdvertiserGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 advertiser groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdvertiserGroupListCall<'a, C, A> { + AdvertiserGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new advertiser group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupInsertCall<'a, C, A> { + AdvertiserGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { + AdvertiserGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn patch(&self, request: AdvertiserGroup, profile_id: &str, id: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + AdvertiserGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing advertiser group. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn delete(&self, profile_id: &str, id: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + AdvertiserGroupDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *site* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.sites(); +/// # } +/// ``` +pub struct SiteMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SiteMethods<'a, C, A> {} + +impl<'a, C, A> SiteMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Site, profile_id: &str) -> SiteInsertCall<'a, C, A> { + SiteInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one site by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Site ID. + pub fn get(&self, profile_id: &str, id: &str) -> SiteGetCall<'a, C, A> { + SiteGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 sites, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SiteListCall<'a, C, A> { + SiteListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _unmapped_site: Default::default(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _campaign_ids: Default::default(), + _approved: Default::default(), + _ad_words_site: Default::default(), + _accepts_publisher_paid_placements: Default::default(), + _accepts_interstitial_placements: Default::default(), + _accepts_in_stream_video_placements: 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 site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Site, profile_id: &str) -> SiteUpdateCall<'a, C, A> { + SiteUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 site. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Site ID. + pub fn patch(&self, request: Site, profile_id: &str, id: &str) -> SitePatchCall<'a, C, A> { + SitePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightActivity* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `generatetag(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_activities(); +/// # } +/// ``` +pub struct FloodlightActivityMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightActivityMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight activity by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGetCall<'a, C, A> { + FloodlightActivityGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight activities, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightActivityListCall<'a, C, A> { + FloodlightActivityListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _tag_string: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _floodlight_configuration_id: Default::default(), + _floodlight_activity_group_type: Default::default(), + _floodlight_activity_group_tag_string: Default::default(), + _floodlight_activity_group_name: Default::default(), + _floodlight_activity_group_ids: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new floodlight activity. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityInsertCall<'a, C, A> { + FloodlightActivityInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing floodlight activity. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn delete(&self, profile_id: &str, id: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + FloodlightActivityDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight activity. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn patch(&self, request: FloodlightActivity, profile_id: &str, id: &str) -> FloodlightActivityPatchCall<'a, C, A> { + FloodlightActivityPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates a tag for a floodlight activity. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn generatetag(&self, profile_id: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + FloodlightActivityGeneratetagCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _floodlight_activity_id: 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 floodlight activity. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityUpdateCall<'a, C, A> { + FloodlightActivityUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _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 `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.regions(); +/// # } +/// ``` +pub struct RegionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +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 a list of regions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> RegionListCall<'a, C, A> { + RegionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.creative_groups(); +/// # } +/// ``` +pub struct CreativeGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeGroupMethods<'a, C, A> {} + +impl<'a, C, A> CreativeGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupInsertCall<'a, C, A> { + CreativeGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative group ID. + pub fn get(&self, profile_id: &str, id: &str) -> CreativeGroupGetCall<'a, C, A> { + CreativeGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 creative group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupUpdateCall<'a, C, A> { + CreativeGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 creative groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeGroupListCall<'a, C, A> { + CreativeGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _group_number: Default::default(), + _advertiser_ids: 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 creative group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative group ID. + pub fn patch(&self, request: CreativeGroup, profile_id: &str, id: &str) -> CreativeGroupPatchCall<'a, C, A> { + CreativeGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *targetableRemarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.targetable_remarketing_lists(); +/// # } +/// ``` +pub struct TargetableRemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for TargetableRemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of targetable remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only targetable remarketing lists targetable by these advertisers. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> TargetableRemarketingListListCall<'a, C, A> { + TargetableRemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + TargetableRemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *subaccount* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.subaccounts(); +/// # } +/// ``` +pub struct SubaccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SubaccountMethods<'a, C, A> {} + +impl<'a, C, A> SubaccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing subaccount. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Subaccount ID. + pub fn patch(&self, request: Subaccount, profile_id: &str, id: &str) -> SubaccountPatchCall<'a, C, A> { + SubaccountPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new subaccount. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Subaccount, profile_id: &str) -> SubaccountInsertCall<'a, C, A> { + SubaccountInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 subaccount. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Subaccount, profile_id: &str) -> SubaccountUpdateCall<'a, C, A> { + SubaccountUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 list of subaccounts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SubaccountListCall<'a, C, A> { + SubaccountListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one subaccount by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Subaccount ID. + pub fn get(&self, profile_id: &str, id: &str) -> SubaccountGetCall<'a, C, A> { + SubaccountGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *mobileCarrier* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.mobile_carriers(); +/// # } +/// ``` +pub struct MobileCarrierMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for MobileCarrierMethods<'a, C, A> {} + +impl<'a, C, A> MobileCarrierMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one mobile carrier by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Mobile carrier ID. + pub fn get(&self, profile_id: &str, id: &str) -> MobileCarrierGetCall<'a, C, A> { + MobileCarrierGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 mobile carriers. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> MobileCarrierListCall<'a, C, A> { + MobileCarrierListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightConfiguration* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_configurations(); +/// # } +/// ``` +pub struct FloodlightConfigurationMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightConfigurationMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight configuration by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight configuration ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + FloodlightConfigurationGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight configuration. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightConfiguration, profile_id: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { + FloodlightConfigurationUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 floodlight configuration. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight configuration ID. + pub fn patch(&self, request: FloodlightConfiguration, profile_id: &str, id: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + FloodlightConfigurationPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight configurations, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightConfigurationListCall<'a, C, A> { + FloodlightConfigurationListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *operatingSystem* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.operating_systems(); +/// # } +/// ``` +pub struct OperatingSystemMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OperatingSystemMethods<'a, C, A> {} + +impl<'a, C, A> OperatingSystemMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of operating systems. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> OperatingSystemListCall<'a, C, A> { + OperatingSystemListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system by DART ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `dartId` - Operating system DART ID. + pub fn get(&self, profile_id: &str, dart_id: &str) -> OperatingSystemGetCall<'a, C, A> { + OperatingSystemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _dart_id: dart_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *file* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.files(); +/// # } +/// ``` +pub struct FileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FileMethods<'a, C, A> {} + +impl<'a, C, A> FileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Lists files for a user profile. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + pub fn list(&self, profile_id: &str) -> FileListCall<'a, C, A> { + FileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _scope: Default::default(), + _page_token: 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: + /// + /// Retrieves a report file by its report ID and file ID. + /// + /// # Arguments + /// + /// * `reportId` - The ID of the report. + /// * `fileId` - The ID of the report file. + pub fn get(&self, report_id: &str, file_id: &str) -> FileGetCall<'a, C, A> { + FileGetCall { + hub: self.hub, + _report_id: report_id.to_string(), + _file_id: file_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placementGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.placement_groups(); +/// # } +/// ``` +pub struct PlacementGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementGroupMethods<'a, C, A> {} + +impl<'a, C, A> PlacementGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of placement groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementGroupListCall<'a, C, A> { + PlacementGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_ids: Default::default(), + _search_string: Default::default(), + _pricing_types: Default::default(), + _placement_strategy_ids: Default::default(), + _placement_group_type: Default::default(), + _page_token: Default::default(), + _min_start_date: Default::default(), + _min_end_date: Default::default(), + _max_start_date: Default::default(), + _max_results: Default::default(), + _max_end_date: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _content_category_ids: Default::default(), + _campaign_ids: Default::default(), + _archived: Default::default(), + _advertiser_ids: 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 placement group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupUpdateCall<'a, C, A> { + PlacementGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupInsertCall<'a, C, A> { + PlacementGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement group ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementGroupGetCall<'a, C, A> { + PlacementGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 placement group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement group ID. + pub fn patch(&self, request: PlacementGroup, profile_id: &str, id: &str) -> PlacementGroupPatchCall<'a, C, A> { + PlacementGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *inventoryItem* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.inventory_items(); +/// # } +/// ``` +pub struct InventoryItemMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for InventoryItemMethods<'a, C, A> {} + +impl<'a, C, A> InventoryItemMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of inventory items, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> InventoryItemListCall<'a, C, A> { + InventoryItemListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _type_: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _page_token: Default::default(), + _order_id: Default::default(), + _max_results: Default::default(), + _in_plan: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one inventory item by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + /// * `id` - Inventory item ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> InventoryItemGetCall<'a, C, A> { + InventoryItemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRolePermission* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_role_permissions(); +/// # } +/// ``` +pub struct UserRolePermissionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRolePermissionMethods<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role permission by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role permission ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGetCall<'a, C, A> { + UserRolePermissionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 list of user role permissions, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRolePermissionListCall<'a, C, A> { + UserRolePermissionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountPermissionGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_permission_groups(); +/// # } +/// ``` +pub struct AccountPermissionGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountPermissionGroupMethods<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the list of account permission groups. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountPermissionGroupListCall<'a, C, A> { + AccountPermissionGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one account permission group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account permission group ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + AccountPermissionGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *contentCategory* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.content_categories(); +/// # } +/// ``` +pub struct ContentCategoryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ContentCategoryMethods<'a, C, A> {} + +impl<'a, C, A> ContentCategoryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of content categories, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ContentCategoryListCall<'a, C, A> { + ContentCategoryListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: 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 content category. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryUpdateCall<'a, C, A> { + ContentCategoryUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new content category. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryInsertCall<'a, C, A> { + ContentCategoryInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing content category. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn delete(&self, profile_id: &str, id: &str) -> ContentCategoryDeleteCall<'a, C, A> { + ContentCategoryDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one content category by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn get(&self, profile_id: &str, id: &str) -> ContentCategoryGetCall<'a, C, A> { + ContentCategoryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 content category. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn patch(&self, request: ContentCategory, profile_id: &str, id: &str) -> ContentCategoryPatchCall<'a, C, A> { + ContentCategoryPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creative* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.creatives(); +/// # } +/// ``` +pub struct CreativeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeMethods<'a, C, A> {} + +impl<'a, C, A> CreativeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Creative, profile_id: &str) -> CreativeUpdateCall<'a, C, A> { + CreativeUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Creative, profile_id: &str) -> CreativeInsertCall<'a, C, A> { + CreativeInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative ID. + pub fn get(&self, profile_id: &str, id: &str) -> CreativeGetCall<'a, C, A> { + CreativeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 creatives, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeListCall<'a, C, A> { + CreativeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _types: Default::default(), + _studio_creative_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _search_string: Default::default(), + _rendering_ids: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _creative_field_ids: Default::default(), + _companion_creative_ids: Default::default(), + _campaign_id: Default::default(), + _archived: Default::default(), + _advertiser_id: Default::default(), + _active: 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 creative. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative ID. + pub fn patch(&self, request: Creative, profile_id: &str, id: &str) -> CreativePatchCall<'a, C, A> { + CreativePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *campaign* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.campaigns(); +/// # } +/// ``` +pub struct CampaignMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CampaignMethods<'a, C, A> {} + +impl<'a, C, A> CampaignMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one campaign by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Campaign ID. + pub fn get(&self, profile_id: &str, id: &str) -> CampaignGetCall<'a, C, A> { + CampaignGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `defaultLandingPageName` - Default landing page name for this new campaign. Must be less than 256 characters long. + /// * `defaultLandingPageUrl` - Default landing page URL for this new campaign. + pub fn insert(&self, request: Campaign, profile_id: &str, default_landing_page_name: &str, default_landing_page_url: &str) -> CampaignInsertCall<'a, C, A> { + CampaignInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _default_landing_page_name: default_landing_page_name.to_string(), + _default_landing_page_url: default_landing_page_url.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 campaign. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Campaign ID. + pub fn patch(&self, request: Campaign, profile_id: &str, id: &str) -> CampaignPatchCall<'a, C, A> { + CampaignPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: 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 campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Campaign, profile_id: &str) -> CampaignUpdateCall<'a, C, A> { + CampaignUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 campaigns, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CampaignListCall<'a, C, A> { + CampaignListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _overridden_event_tag_id: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _excluded_ids: Default::default(), + _at_least_one_optimization_activity: Default::default(), + _archived: Default::default(), + _advertiser_ids: Default::default(), + _advertiser_group_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *eventTag* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.event_tags(); +/// # } +/// ``` +pub struct EventTagMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for EventTagMethods<'a, C, A> {} + +impl<'a, C, A> EventTagMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing event tag. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn delete(&self, profile_id: &str, id: &str) -> EventTagDeleteCall<'a, C, A> { + EventTagDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 event tags, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> EventTagListCall<'a, C, A> { + EventTagListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _ids: Default::default(), + _event_tag_types: Default::default(), + _enabled: Default::default(), + _definitions_only: Default::default(), + _campaign_id: Default::default(), + _advertiser_id: Default::default(), + _ad_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new event tag. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: EventTag, profile_id: &str) -> EventTagInsertCall<'a, C, A> { + EventTagInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 event tag. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn patch(&self, request: EventTag, profile_id: &str, id: &str) -> EventTagPatchCall<'a, C, A> { + EventTagPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: 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 event tag. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: EventTag, profile_id: &str) -> EventTagUpdateCall<'a, C, A> { + EventTagUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one event tag by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn get(&self, profile_id: &str, id: &str) -> EventTagGetCall<'a, C, A> { + EventTagGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *remarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.remarketing_lists(); +/// # } +/// ``` +pub struct RemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for RemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> RemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> RemarketingListGetCall<'a, C, A> { + RemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 remarketing list. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: RemarketingList, profile_id: &str) -> RemarketingListUpdateCall<'a, C, A> { + RemarketingListUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only remarketing lists owned by this advertiser. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> RemarketingListListCall<'a, C, A> { + RemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _floodlight_activity_id: Default::default(), + _active: 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 remarketing list. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn patch(&self, request: RemarketingList, profile_id: &str, id: &str) -> RemarketingListPatchCall<'a, C, A> { + RemarketingListPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new remarketing list. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: RemarketingList, profile_id: &str) -> RemarketingListInsertCall<'a, C, A> { + RemarketingListInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *city* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.cities(); +/// # } +/// ``` +pub struct CityMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CityMethods<'a, C, A> {} + +impl<'a, C, A> CityMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of cities, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CityListCall<'a, C, A> { + CityListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _region_dart_ids: Default::default(), + _name_prefix: Default::default(), + _dart_ids: Default::default(), + _country_dart_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placementStrategy* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.placement_strategies(); +/// # } +/// ``` +pub struct PlacementStrategyMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementStrategyMethods<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing placement strategy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + PlacementStrategyUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement strategy by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementStrategyGetCall<'a, C, A> { + PlacementStrategyGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 placement strategies, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementStrategyListCall<'a, C, A> { + PlacementStrategyListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing placement strategy. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn delete(&self, profile_id: &str, id: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + PlacementStrategyDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement strategy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyInsertCall<'a, C, A> { + PlacementStrategyInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 placement strategy. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn patch(&self, request: PlacementStrategy, profile_id: &str, id: &str) -> PlacementStrategyPatchCall<'a, C, A> { + PlacementStrategyPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.projects(); +/// # } +/// ``` +pub struct ProjectMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +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: + /// + /// Retrieves a list of projects, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ProjectListCall<'a, C, A> { + ProjectListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one project by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Project ID. + pub fn get(&self, profile_id: &str, id: &str) -> ProjectGetCall<'a, C, A> { + ProjectGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *directorySite* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.directory_sites(); +/// # } +/// ``` +pub struct DirectorySiteMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DirectorySiteMethods<'a, C, A> {} + +impl<'a, C, A> DirectorySiteMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new directory site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: DirectorySite, profile_id: &str) -> DirectorySiteInsertCall<'a, C, A> { + DirectorySiteInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 directory sites, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DirectorySiteListCall<'a, C, A> { + DirectorySiteListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _parent_id: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _dfp_network_code: Default::default(), + _country_id: Default::default(), + _active: Default::default(), + _accepts_publisher_paid_placements: Default::default(), + _accepts_interstitial_placements: Default::default(), + _accepts_in_stream_video_placements: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one directory site by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Directory site ID. + pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteGetCall<'a, C, A> { + DirectorySiteGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *dynamicTargetingKey* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.dynamic_targeting_keys(); +/// # } +/// ``` +pub struct DynamicTargetingKeyMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DynamicTargetingKeyMethods<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing dynamic targeting key. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `objectId` - ID of the object of this dynamic targeting key. This is a required field. + /// * `name` - Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + /// * `objectType` - Type of the object of this dynamic targeting key. This is a required field. + pub fn delete(&self, profile_id: &str, object_id: &str, name: &str, object_type: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + DynamicTargetingKeyDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _object_id: object_id.to_string(), + _name: name.to_string(), + _object_type: object_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 dynamic targeting keys. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + DynamicTargetingKeyListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _object_type: Default::default(), + _object_id: Default::default(), + _names: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: DynamicTargetingKey, profile_id: &str) -> DynamicTargetingKeyInsertCall<'a, C, A> { + DynamicTargetingKeyInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *size* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.sizes(); +/// # } +/// ``` +pub struct SizeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SizeMethods<'a, C, A> {} + +impl<'a, C, A> SizeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new size. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Size, profile_id: &str) -> SizeInsertCall<'a, C, A> { + SizeInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 sizes, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SizeListCall<'a, C, A> { + SizeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _width: Default::default(), + _ids: Default::default(), + _iab_standard: Default::default(), + _height: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one size by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Size ID. + pub fn get(&self, profile_id: &str, id: &str) -> SizeGetCall<'a, C, A> { + SizeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountActiveAdSummary* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_active_ad_summaries(); +/// # } +/// ``` +pub struct AccountActiveAdSummaryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountActiveAdSummaryMethods<'a, C, A> {} + +impl<'a, C, A> AccountActiveAdSummaryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets the account's active ad summary by account ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `summaryAccountId` - Account ID. + pub fn get(&self, profile_id: &str, summary_account_id: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + AccountActiveAdSummaryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _summary_account_id: summary_account_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountUserProfile* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.account_user_profiles(); +/// # } +/// ``` +pub struct AccountUserProfileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountUserProfileMethods<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing account user profile. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileUpdateCall<'a, C, A> { + AccountUserProfileUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 account user profiles, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountUserProfileListCall<'a, C, A> { + AccountUserProfileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _user_role_id: Default::default(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new account user profile. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileInsertCall<'a, C, A> { + AccountUserProfileInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 account user profile. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User profile ID. + pub fn patch(&self, request: AccountUserProfile, profile_id: &str, id: &str) -> AccountUserProfilePatchCall<'a, C, A> { + AccountUserProfilePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one account user profile by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User profile ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountUserProfileGetCall<'a, C, A> { + AccountUserProfileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *country* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.countries(); +/// # } +/// ``` +pub struct CountryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CountryMethods<'a, C, A> {} + +impl<'a, C, A> CountryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of countries. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CountryListCall<'a, C, A> { + CountryListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one country by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `dartId` - Country DART ID. + pub fn get(&self, profile_id: &str, dart_id: &str) -> CountryGetCall<'a, C, A> { + CountryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _dart_id: dart_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *orderDocument* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.order_documents(); +/// # } +/// ``` +pub struct OrderDocumentMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OrderDocumentMethods<'a, C, A> {} + +impl<'a, C, A> OrderDocumentMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one order document by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + /// * `id` - Order document ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderDocumentGetCall<'a, C, A> { + OrderDocumentGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.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 order documents, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderDocumentListCall<'a, C, A> { + OrderDocumentListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _order_id: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _approved: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *postalCode* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.postal_codes(); +/// # } +/// ``` +pub struct PostalCodeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PostalCodeMethods<'a, C, A> {} + +impl<'a, C, A> PostalCodeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one postal code by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `code` - Postal code ID. + pub fn get(&self, profile_id: &str, code: &str) -> PostalCodeGetCall<'a, C, A> { + PostalCodeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _code: code.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 postal codes. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PostalCodeListCall<'a, C, A> { + PostalCodeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *browser* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.browsers(); +/// # } +/// ``` +pub struct BrowserMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for BrowserMethods<'a, C, A> {} + +impl<'a, C, A> BrowserMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of browsers. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> BrowserListCall<'a, C, A> { + BrowserListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *account* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.accounts(); +/// # } +/// ``` +pub struct AccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} + +impl<'a, C, A> AccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one account by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountGetCall<'a, C, A> { + AccountGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 accounts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountListCall<'a, C, A> { + AccountListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _active: 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 account. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Account, profile_id: &str) -> AccountUpdateCall<'a, C, A> { + AccountUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 account. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account ID. + pub fn patch(&self, request: Account, profile_id: &str, id: &str) -> AccountPatchCall<'a, C, A> { + AccountPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placement* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d5 as dfareporting2d5; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d5::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `generatetags(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.placements(); +/// # } +/// ``` +pub struct PlacementMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementMethods<'a, C, A> {} + +impl<'a, C, A> PlacementMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing placement. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement ID. + pub fn patch(&self, request: Placement, profile_id: &str, id: &str) -> PlacementPatchCall<'a, C, A> { + PlacementPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 placements, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementListCall<'a, C, A> { + PlacementListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _site_ids: Default::default(), + _search_string: Default::default(), + _pricing_types: Default::default(), + _placement_strategy_ids: Default::default(), + _payment_source: Default::default(), + _page_token: Default::default(), + _min_start_date: Default::default(), + _min_end_date: Default::default(), + _max_start_date: Default::default(), + _max_results: Default::default(), + _max_end_date: Default::default(), + _ids: Default::default(), + _group_ids: Default::default(), + _directory_site_ids: Default::default(), + _content_category_ids: Default::default(), + _compatibilities: Default::default(), + _campaign_ids: Default::default(), + _archived: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Placement, profile_id: &str) -> PlacementInsertCall<'a, C, A> { + PlacementInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Placement, profile_id: &str) -> PlacementUpdateCall<'a, C, A> { + PlacementUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates tags for a placement. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn generatetags(&self, profile_id: &str) -> PlacementGeneratetagCall<'a, C, A> { + PlacementGeneratetagCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _tag_formats: Default::default(), + _placement_ids: Default::default(), + _campaign_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementGetCall<'a, C, A> { + PlacementGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + + + +// ################### +// CallBuilders ### +// ################# + +/// Inserts conversions. +/// +/// A builder for the *batchinsert* method supported by a *conversion* resource. +/// It is not used directly, but through a `ConversionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::ConversionsBatchInsertRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ConversionsBatchInsertRequest::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.conversions().batchinsert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ConversionBatchinsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ConversionsBatchInsertRequest, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConversionBatchinsertCall<'a, C, A> {} + +impl<'a, C, A> ConversionBatchinsertCall<'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, ConversionsBatchInsertResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.conversions.batchinsert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/conversions/batchinsert".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Ddmconversion.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ConversionsBatchInsertRequest) -> ConversionBatchinsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConversionBatchinsertCall<'a, C, A> { + self._profile_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) -> ConversionBatchinsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConversionBatchinsertCall<'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::Ddmconversion`. + /// + /// 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) -> ConversionBatchinsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role permission group by ID. +/// +/// A builder for the *get* method supported by a *userRolePermissionGroup* resource. +/// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permission_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGroupGetCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupGetCall<'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, UserRolePermissionGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissionGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRolePermissionGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role permission group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._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) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of all supported user role permission groups. +/// +/// A builder for the *list* method supported by a *userRolePermissionGroup* resource. +/// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permission_groups().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGroupListCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupListCall<'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, UserRolePermissionGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissionGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRolePermissionGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGroupListCall<'a, C, A> { + self._profile_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) -> UserRolePermissionGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one platform type by ID. +/// +/// A builder for the *get* method supported by a *platformType* resource. +/// It is not used directly, but through a `PlatformTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.platform_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlatformTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlatformTypeGetCall<'a, C, A> {} + +impl<'a, C, A> PlatformTypeGetCall<'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, PlatformType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.platformTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/platformTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Platform type ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._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) -> PlatformTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlatformTypeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlatformTypeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of platform types. +/// +/// A builder for the *list* method supported by a *platformType* resource. +/// It is not used directly, but through a `PlatformTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.platform_types().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlatformTypeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlatformTypeListCall<'a, C, A> {} + +impl<'a, C, A> PlatformTypeListCall<'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, PlatformTypesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.platformTypes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/platformTypes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlatformTypeListCall<'a, C, A> { + self._profile_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) -> PlatformTypeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlatformTypeListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlatformTypeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field value. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().patch(req, "profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValuePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValuePatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValuePatchCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._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) -> CreativeFieldValuePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValuePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValuePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative field value by ID. +/// +/// A builder for the *get* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().get("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueGetCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].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 ["id", "creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._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) -> CreativeFieldValueGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing creative field value. +/// +/// A builder for the *delete* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().delete("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueDeleteCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueDeleteCall<'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: "dfareporting.creativeFieldValues.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].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 ["id", "creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._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) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative field value. +/// +/// A builder for the *insert* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().insert(req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueInsertCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._creative_field_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) -> CreativeFieldValueInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field value. +/// +/// A builder for the *update* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().update(req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueUpdateCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._creative_field_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) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative field values, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().list("profileId", "creativeFieldId") +/// .sort_order("erat") +/// .sort_field("sadipscing") +/// .search_string("dolor") +/// .page_token("eirmod") +/// .max_results(-43) +/// .add_ids("amet") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueListCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueListCall<'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, CreativeFieldValuesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "creativeFieldId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed. + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative field values with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._ids.push(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) -> CreativeFieldValueListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field. +/// +/// A builder for the *update* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldUpdateCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldUpdateCall<'a, C, A> { + self._profile_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) -> CreativeFieldUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative fields, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().list("profileId") +/// .sort_order("eirmod") +/// .sort_field("dolore") +/// .search_string("invidunt") +/// .page_token("aliquyam") +/// .max_results(-73) +/// .add_ids("Lorem") +/// .add_advertiser_ids("sea") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldListCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldListCall<'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, CreativeFieldsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative fields by name or ID. Wildcards (*) are allowed. For example, "creativefield*2015" will return creative fields with names like "creativefield June 2015", "creativefield April 2015", or simply "creativefield 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativefield" will match creative fields with the name "my creativefield", "creativefield 2015", or simply "creativefield". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeFieldListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative fields with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creative fields that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._advertiser_ids.push(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) -> CreativeFieldListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing creative field. +/// +/// A builder for the *delete* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldDeleteCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldDeleteCall<'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: "dfareporting.creativeFields.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, C, A> { + self._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) -> CreativeFieldDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative field by ID. +/// +/// A builder for the *get* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldGetCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, C, A> { + self._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) -> CreativeFieldGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative field. +/// +/// A builder for the *insert* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldInsertCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldInsertCall<'a, C, A> { + self._profile_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) -> CreativeFieldInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldPatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldPatchCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, C, A> { + self._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) -> CreativeFieldPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new user role. +/// +/// A builder for the *insert* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleInsertCall<'a, C, A> {} + +impl<'a, C, A> UserRoleInsertCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRoleInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleInsertCall<'a, C, A> { + self._profile_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) -> UserRoleInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role by ID. +/// +/// A builder for the *get* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleGetCall<'a, C, A> {} + +impl<'a, C, A> UserRoleGetCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRoleGetCall<'a, C, A> { + self._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) -> UserRoleGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing user role. +/// +/// A builder for the *update* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleUpdateCall<'a, C, A> {} + +impl<'a, C, A> UserRoleUpdateCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRoleUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleUpdateCall<'a, C, A> { + self._profile_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) -> UserRoleUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing user role. +/// +/// A builder for the *delete* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserRoleDeleteCall<'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: "dfareporting.userRoles.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, C, A> { + self._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) -> UserRoleDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing user role. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePatchCall<'a, C, A> {} + +impl<'a, C, A> UserRolePatchCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRolePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> UserRolePatchCall<'a, C, A> { + self._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) -> UserRolePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of user roles, possibly filtered. +/// +/// A builder for the *list* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().list("profileId") +/// .subaccount_id("consetetur") +/// .sort_order("amet.") +/// .sort_field("voluptua.") +/// .search_string("Lorem") +/// .page_token("gubergren") +/// .max_results(-20) +/// .add_ids("sit") +/// .account_user_role_only(true) +/// .doit(); +/// # } +/// ``` +pub struct UserRoleListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _account_user_role_only: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleListCall<'a, C, A> {} + +impl<'a, C, A> UserRoleListCall<'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, UserRolesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._account_user_role_only { + params.push(("accountUserRoleOnly", value.to_string())); + } + for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "accountUserRoleOnly"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user roles that belong to this subaccount. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "userrole*2015" will return objects with names like "userrole June 2015", "userrole April 2015", or simply "userrole 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "userrole" will match objects with name "my userrole", "userrole 2015", or simply "userrole". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> UserRoleListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only user roles with the specified IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only account level user roles not associated with any specific subaccount. + /// + /// Sets the *account user role only* query property to the given value. + pub fn account_user_role_only(mut self, new_value: bool) -> UserRoleListCall<'a, C, A> { + self._account_user_role_only = 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) -> UserRoleListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one operating system version by ID. +/// +/// A builder for the *get* method supported by a *operatingSystemVersion* resource. +/// It is not used directly, but through a `OperatingSystemVersionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_system_versions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemVersionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemVersionGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionGetCall<'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, OperatingSystemVersion)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystemVersions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/operatingSystemVersions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system version ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._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) -> OperatingSystemVersionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemVersionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemVersionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of operating system versions. +/// +/// A builder for the *list* method supported by a *operatingSystemVersion* resource. +/// It is not used directly, but through a `OperatingSystemVersionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_system_versions().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemVersionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemVersionListCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionListCall<'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, OperatingSystemVersionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystemVersions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/operatingSystemVersions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemVersionListCall<'a, C, A> { + self._profile_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) -> OperatingSystemVersionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemVersionListCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemVersionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one campaign landing page by ID. +/// +/// A builder for the *get* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().get("profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageGetCall<'a, C, A> {} + +impl<'a, C, A> LandingPageGetCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId"), ("{id}", "id")].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 ["id", "campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._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) -> LandingPageGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageGetCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign landing page. +/// +/// A builder for the *update* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().update(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageUpdateCall<'a, C, A> {} + +impl<'a, C, A> LandingPageUpdateCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPageUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageUpdateCall<'a, C, A> { + self._campaign_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) -> LandingPageUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of landing pages for the specified campaign. +/// +/// A builder for the *list* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().list("profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageListCall<'a, C, A> {} + +impl<'a, C, A> LandingPageListCall<'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, LandingPagesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageListCall<'a, C, A> { + self._campaign_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) -> LandingPageListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageListCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new landing page for the specified campaign. +/// +/// A builder for the *insert* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().insert(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageInsertCall<'a, C, A> {} + +impl<'a, C, A> LandingPageInsertCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPageInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageInsertCall<'a, C, A> { + self._campaign_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) -> LandingPageInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign landing page. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().patch(req, "profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPagePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPagePatchCall<'a, C, A> {} + +impl<'a, C, A> LandingPagePatchCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPagePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._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) -> LandingPagePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPagePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPagePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing campaign landing page. +/// +/// A builder for the *delete* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().delete("profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageDeleteCall<'a, C, A> {} + +impl<'a, C, A> LandingPageDeleteCall<'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: "dfareporting.landingPages.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId"), ("{id}", "id")].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 ["id", "campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._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) -> LandingPageDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative asset. +/// +/// A builder for the *insert* method supported by a *creativeAsset* resource. +/// It is not used directly, but through a `CreativeAssetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeAssetMetadata; +/// use std::fs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeAssetMetadata::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `upload_resumable(...)`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.creative_assets().insert(req, "profileId", "advertiserId") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// # } +/// ``` +pub struct CreativeAssetInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeAssetMetadata, + _profile_id: String, + _advertiser_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeAssetInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeAssets.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + for &field in ["alt", "profileId", "advertiserId"].iter() { + if self._additional_params.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, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/dfareporting/v2.5/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "multipart") + } else if protocol == "resumable" { + ("https://www.googleapis.com/resumable/upload/dfareporting/v2.5/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "resumable") + } else { + unreachable!() + }; + params.push(("uploadType", upload_type.to_string())); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{advertiserId}", "advertiserId")].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 ["advertiserId", "profileId"].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(); + + let mut should_ask_dlg_for_url = false; + let mut upload_url_from_server; + let mut upload_url: Option = None; + + 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 = { + if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { + should_ask_dlg_for_url = false; + upload_url_from_server = false; + let url = upload_url.as_ref().and_then(|s| Some(hyper::Url::parse(s).unwrap())).unwrap(); + hyper::client::Response::new(url, Box::new(cmn::DummyNetworkStream)).and_then(|mut res| { + res.status = hyper::status::StatusCode::Ok; + res.headers.set(Location(upload_url.as_ref().unwrap().clone())); + Ok(res) + }) + } else { + let mut mp_reader: MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + "simple" => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + let mime_type = mp_reader.mime_type(); + (&mut mp_reader as &mut io::Read, ContentType(mime_type)) + }, + _ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())), + }; + 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(content_type) + .body(&mut body_reader); + upload_url_from_server = true; + if protocol == "resumable" { + req = req.header(cmn::XUploadContentType(reader_mime_type.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)) + } + } + if protocol == "resumable" { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + let mut client = &mut *self.hub.client.borrow_mut(); + let upload_result = { + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + cmn::ResumableUploadHelper { + client: &mut client.borrow_mut(), + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &mut *self.hub.auth.borrow_mut(), + user_agent: &self.hub._user_agent, + auth_header: auth_header.clone(), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload() + }; + match upload_result { + None => { + dlg.finished(false); + return Err(Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Some(Ok(upload_result)) => { + res = upload_result; + if !res.status.is_success() { + dlg.store_upload_url(None); + dlg.finished(false); + return Err(Error::Failure(res)) + } + } + } + } + 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) + } + } + } + } + + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *max size*: 1024MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(stream, mime_type, "simple") + } + /// Upload media in a resumable fashion. + /// Even if the upload fails or is interrupted, it can be resumed for a + /// certain amount of time as the server maintains state temporarily. + /// + /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL + /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate + /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using + /// `cancel_chunk_upload(...)`. + /// + /// * *max size*: 1024MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(resumeable_stream, mime_type, "resumable") + } + + /// + /// 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: CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID of this creative. This is a required field. + /// + /// Sets the *advertiser 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 advertiser_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._advertiser_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) -> CreativeAssetInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeAssetInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeAssetInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already. +/// +/// A builder for the *insert* method supported by a *campaignCreativeAssociation* resource. +/// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CampaignCreativeAssociation; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CampaignCreativeAssociation::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.campaign_creative_associations().insert(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CampaignCreativeAssociation, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignCreativeAssociationInsertCall<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationInsertCall<'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, CampaignCreativeAssociation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaignCreativeAssociations.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: CampaignCreativeAssociation) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID in this association. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._campaign_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) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignCreativeAssociationInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignCreativeAssociationInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of creative IDs associated with the specified campaign. +/// +/// A builder for the *list* method supported by a *campaignCreativeAssociation* resource. +/// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaign_creative_associations().list("profileId", "campaignId") +/// .sort_order("sadipscing") +/// .page_token("rebum.") +/// .max_results(-33) +/// .doit(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _sort_order: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignCreativeAssociationListCall<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationListCall<'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, CampaignCreativeAssociationsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaignCreativeAssociations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.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())); + } + for &field in ["alt", "profileId", "campaignId", "sortOrder", "pageToken", "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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID in this association. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CampaignCreativeAssociationListCall<'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) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignCreativeAssociationListCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignCreativeAssociationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of change logs. +/// +/// A builder for the *list* method supported by a *changeLog* resource. +/// It is not used directly, but through a `ChangeLogMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.change_logs().list("profileId") +/// .add_user_profile_ids("sed") +/// .search_string("aliquyam") +/// .page_token("sit") +/// .object_type("eirmod") +/// .add_object_ids("consetetur") +/// .min_change_time("labore") +/// .max_results(-30) +/// .max_change_time("ea") +/// .add_ids("gubergren") +/// .action("aliquyam") +/// .doit(); +/// # } +/// ``` +pub struct ChangeLogListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _user_profile_ids: Vec, + _search_string: Option, + _page_token: Option, + _object_type: Option, + _object_ids: Vec, + _min_change_time: Option, + _max_results: Option, + _max_change_time: Option, + _ids: Vec, + _action: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ChangeLogListCall<'a, C, A> {} + +impl<'a, C, A> ChangeLogListCall<'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, ChangeLogsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.changeLogs.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._user_profile_ids.len() > 0 { + for f in self._user_profile_ids.iter() { + params.push(("userProfileIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._object_type { + params.push(("objectType", value.to_string())); + } + if self._object_ids.len() > 0 { + for f in self._object_ids.iter() { + params.push(("objectIds", f.to_string())); + } + } + if let Some(value) = self._min_change_time { + params.push(("minChangeTime", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_change_time { + params.push(("maxChangeTime", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._action { + params.push(("action", value.to_string())); + } + for &field in ["alt", "profileId", "userProfileIds", "searchString", "pageToken", "objectType", "objectIds", "minChangeTime", "maxResults", "maxChangeTime", "ids", "action"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/changeLogs".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only change logs with these user profile IDs. + /// + /// Append the given value to the *user profile ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_user_profile_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._user_profile_ids.push(new_value.to_string()); + self + } + /// Select only change logs whose object ID, user name, old or new values match the search string. + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only change logs with the specified object type. + /// + /// Sets the *object type* query property to the given value. + pub fn object_type(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._object_type = Some(new_value.to_string()); + self + } + /// Select only change logs with these object IDs. + /// + /// Append the given value to the *object ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_object_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._object_ids.push(new_value.to_string()); + self + } + /// Select only change logs whose change time is before the specified minChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset. + /// + /// Sets the *min change time* query property to the given value. + pub fn min_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._min_change_time = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ChangeLogListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only change logs whose change time is before the specified maxChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset. + /// + /// Sets the *max change time* query property to the given value. + pub fn max_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._max_change_time = Some(new_value.to_string()); + self + } + /// Select only change logs with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only change logs with the specified action. + /// + /// Sets the *action* query property to the given value. + pub fn action(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._action = 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) -> ChangeLogListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ChangeLogListCall<'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::Dfatrafficking`. + /// + /// 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) -> ChangeLogListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one change log by ID. +/// +/// A builder for the *get* method supported by a *changeLog* resource. +/// It is not used directly, but through a `ChangeLogMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.change_logs().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ChangeLogGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ChangeLogGetCall<'a, C, A> {} + +impl<'a, C, A> ChangeLogGetCall<'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, ChangeLog)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.changeLogs.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/changeLogs/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ChangeLogGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Change log ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ChangeLogGetCall<'a, C, A> { + self._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) -> ChangeLogGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ChangeLogGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ChangeLogGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list share by remarketing list ID. +/// +/// A builder for the *get* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_list_shares().get("profileId", "remarketingListId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListShareGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _remarketing_list_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListShareGetCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareGetCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingListShares/{remarketingListId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{remarketingListId}", "remarketingListId")].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 ["remarketingListId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *remarketing list 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 remarketing_list_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { + self._remarketing_list_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) -> RemarketingListShareGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListShareGetCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListShareGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list share. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::RemarketingListShare; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingListShare::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.remarketing_list_shares().patch(req, "profileId", "remarketingListId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListSharePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingListShare, + _profile_id: String, + _remarketing_list_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListSharePatchCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListSharePatchCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingListShares".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingListShare) -> RemarketingListSharePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *remarketing list id* 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 remarketing_list_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { + self._remarketing_list_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) -> RemarketingListSharePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListSharePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListSharePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list share. +/// +/// A builder for the *update* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::RemarketingListShare; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingListShare::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.remarketing_list_shares().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListShareUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingListShare, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListShareUpdateCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareUpdateCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingListShares".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingListShare) -> RemarketingListShareUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + self._profile_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) -> RemarketingListShareUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListShareUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListShareUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Runs a report. +/// +/// A builder for the *run* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().run("profileId", "reportId") +/// .synchronous(true) +/// .doit(); +/// # } +/// ``` +pub struct ReportRunCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _synchronous: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportRunCall<'a, C, A> {} + +impl<'a, C, A> ReportRunCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.run", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._synchronous { + params.push(("synchronous", value.to_string())); + } + for &field in ["alt", "profileId", "reportId", "synchronous"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}/run".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// If set and true, tries to run the report synchronously. + /// + /// Sets the *synchronous* query property to the given value. + pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, C, A> { + self._synchronous = 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) -> ReportRunCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportRunCall<'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) -> ReportRunCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().patch(req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportPatchCall<'a, C, A> {} + +impl<'a, C, A> ReportPatchCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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: Report) -> ReportPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._report_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) -> ReportPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportPatchCall<'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) -> ReportPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists files for a report. +/// +/// A builder for the *files.list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().files_list("profileId", "reportId") +/// .sort_order("clita") +/// .sort_field("diam") +/// .page_token("justo") +/// .max_results(-57) +/// .doit(); +/// # } +/// ``` +pub struct ReportFileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportFileListCall<'a, C, A> {} + +impl<'a, C, A> ReportFileListCall<'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, FileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.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())); + } + for &field in ["alt", "profileId", "reportId", "sortOrder", "sortField", "pageToken", "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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}/files".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the parent report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'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) -> ReportFileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportFileListCall<'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) -> ReportFileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a report. +/// +/// A builder for the *insert* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportInsertCall<'a, C, A> {} + +impl<'a, C, A> ReportInsertCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Report) -> ReportInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportInsertCall<'a, C, A> { + self._profile_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) -> ReportInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportInsertCall<'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) -> ReportInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. +/// +/// A builder for the *update* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().update(req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportUpdateCall<'a, C, A> {} + +impl<'a, C, A> ReportUpdateCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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: Report) -> ReportUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._report_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) -> ReportUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportUpdateCall<'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) -> ReportUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. +/// +/// A builder for the *compatibleFields.query* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().compatible_fields_query(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportCompatibleFieldQueryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportCompatibleFieldQueryCall<'a, C, A> {} + +impl<'a, C, A> ReportCompatibleFieldQueryCall<'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, CompatibleFields)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.compatibleFields.query", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/compatiblefields/query".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Report) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._profile_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) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportCompatibleFieldQueryCall<'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) -> ReportCompatibleFieldQueryCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report by its ID. +/// +/// A builder for the *get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().get("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportGetCall<'a, C, A> {} + +impl<'a, C, A> ReportGetCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._report_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) -> ReportGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportGetCall<'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) -> ReportGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report 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 `File` structure that you would usually get. The latter will be a default value. +/// +/// A builder for the *files.get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().files_get("profileId", "reportId", "fileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportFileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _file_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportFileGetCall<'a, C, A> {} + +impl<'a, C, A> ReportFileGetCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + params.push(("fileId", self._file_id.to_string())); + for &field in ["profileId", "reportId", "fileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}/files/{fileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId"), ("{fileId}", "fileId")].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 ["fileId", "reportId", "profileId"].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 = 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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The ID of the report file. + /// + /// Sets the *file 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 file_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._file_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) -> ReportFileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportFileGetCall<'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) -> ReportFileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a report by its ID. +/// +/// A builder for the *delete* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().delete("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportDeleteCall<'a, C, A> {} + +impl<'a, C, A> ReportDeleteCall<'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: "dfareporting.reports.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._report_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) -> ReportDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportDeleteCall<'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) -> ReportDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of reports. +/// +/// A builder for the *list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().list("profileId") +/// .sort_order("dolor") +/// .sort_field("diam") +/// .scope("kasd") +/// .page_token("invidunt") +/// .max_results(-15) +/// .doit(); +/// # } +/// ``` +pub struct ReportListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _scope: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportListCall<'a, C, A> {} + +impl<'a, C, A> ReportListCall<'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, ReportList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._scope { + params.push(("scope", value.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())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "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/dfareporting/v2.5/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The scope that defines which results are returned, default is 'MINE'. + /// + /// Sets the *scope* query property to the given value. + pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._scope = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportListCall<'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) -> ReportListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportListCall<'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) -> ReportListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new advertiser. +/// +/// A builder for the *insert* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserInsertCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserInsertCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserInsertCall<'a, C, A> { + self._profile_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) -> AdvertiserInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserPatchCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserPatchCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, C, A> { + self._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) -> AdvertiserPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of advertisers, possibly filtered. +/// +/// A builder for the *list* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertisers().list("profileId") +/// .subaccount_id("At") +/// .status("consetetur") +/// .sort_order("et") +/// .sort_field("sed") +/// .search_string("sit") +/// .page_token("takimata") +/// .only_parent(true) +/// .max_results(-91) +/// .include_advertisers_without_groups_only(true) +/// .add_ids("Lorem") +/// .add_floodlight_configuration_ids("Lorem") +/// .add_advertiser_group_ids("diam") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _status: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _only_parent: Option, + _max_results: Option, + _include_advertisers_without_groups_only: Option, + _ids: Vec, + _floodlight_configuration_ids: Vec, + _advertiser_group_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserListCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserListCall<'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, AdvertisersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._status { + params.push(("status", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._only_parent { + params.push(("onlyParent", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._include_advertisers_without_groups_only { + params.push(("includeAdvertisersWithoutGroupsOnly", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._floodlight_configuration_ids.len() > 0 { + for f in self._floodlight_configuration_ids.iter() { + params.push(("floodlightConfigurationIds", f.to_string())); + } + } + if self._advertiser_group_ids.len() > 0 { + for f in self._advertiser_group_ids.iter() { + params.push(("advertiserGroupIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "subaccountId", "status", "sortOrder", "sortField", "searchString", "pageToken", "onlyParent", "maxResults", "includeAdvertisersWithoutGroupsOnly", "ids", "floodlightConfigurationIds", "advertiserGroupIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only advertisers with these subaccount IDs. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Select only advertisers with the specified status. + /// + /// Sets the *status* query property to the given value. + pub fn status(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._status = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser June 2015", "advertiser April 2015", or simply "advertiser 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertiser" will match objects with name "my advertiser", "advertiser 2015", or simply "advertiser". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only advertisers which use another advertiser's floodlight configuration. + /// + /// Sets the *only parent* query property to the given value. + pub fn only_parent(mut self, new_value: bool) -> AdvertiserListCall<'a, C, A> { + self._only_parent = Some(new_value); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdvertiserListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only advertisers which do not belong to any advertiser group. + /// + /// Sets the *include advertisers without groups only* query property to the given value. + pub fn include_advertisers_without_groups_only(mut self, new_value: bool) -> AdvertiserListCall<'a, C, A> { + self._include_advertisers_without_groups_only = Some(new_value); + self + } + /// Select only advertisers with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only advertisers with these floodlight configuration IDs. + /// + /// Append the given value to the *floodlight configuration ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_floodlight_configuration_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._floodlight_configuration_ids.push(new_value.to_string()); + self + } + /// Select only advertisers with these advertiser group IDs. + /// + /// Append the given value to the *advertiser group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_group_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._advertiser_group_ids.push(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) -> AdvertiserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser. +/// +/// A builder for the *update* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserUpdateCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserUpdateCall<'a, C, A> { + self._profile_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) -> AdvertiserUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one advertiser by ID. +/// +/// A builder for the *get* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertisers().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGetCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGetCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertisers/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGetCall<'a, C, A> { + self._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) -> AdvertiserGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of report dimension values for a list of filters. +/// +/// A builder for the *query* method supported by a *dimensionValue* resource. +/// It is not used directly, but through a `DimensionValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::DimensionValueRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DimensionValueRequest::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.dimension_values().query(req, "profileId") +/// .page_token("ut") +/// .max_results(-3) +/// .doit(); +/// # } +/// ``` +pub struct DimensionValueQueryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DimensionValueRequest, + _profile_id: String, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DimensionValueQueryCall<'a, C, A> {} + +impl<'a, C, A> DimensionValueQueryCall<'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, DimensionValueList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dimensionValues.query", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.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())); + } + for &field in ["alt", "profileId", "pageToken", "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/dfareporting/v2.5/userprofiles/{profileId}/dimensionvalues/query".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DimensionValueRequest) -> DimensionValueQueryCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DimensionValueQueryCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DimensionValueQueryCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DimensionValueQueryCall<'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) -> DimensionValueQueryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DimensionValueQueryCall<'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) -> DimensionValueQueryCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight activity group by ID. +/// +/// A builder for the *get* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activity_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupGetCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity Group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._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) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupPatchCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity Group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._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) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight activity groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activity_groups().list("profileId") +/// .type_("dolor") +/// .sort_order("et") +/// .sort_field("et") +/// .search_string("vero") +/// .page_token("ut") +/// .max_results(-30) +/// .add_ids("et") +/// .floodlight_configuration_id("ipsum") +/// .advertiser_id("justo") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _type_: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _floodlight_configuration_id: Option, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupListCall<'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, FloodlightActivityGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._floodlight_configuration_id { + params.push(("floodlightConfigurationId", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "type", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only floodlight activity groups with the specified floodlight activity group type. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._type_ = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivitygroup*2015" will return objects with names like "floodlightactivitygroup June 2015", "floodlightactivitygroup April 2015", or simply "floodlightactivitygroup 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivitygroup" will match objects with name "my floodlightactivitygroup activity", "floodlightactivitygroup 2015", or simply "floodlightactivitygroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FloodlightActivityGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only floodlight activity groups with the specified IDs. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only floodlight activity groups with the specified floodlight configuration ID. Must specify either advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *floodlight configuration id* query property to the given value. + pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._floodlight_configuration_id = Some(new_value.to_string()); + self + } + /// Select only floodlight activity groups with the specified advertiser ID. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._advertiser_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) -> FloodlightActivityGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new floodlight activity group. +/// +/// A builder for the *insert* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupInsertCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._profile_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) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity group. +/// +/// A builder for the *update* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupUpdateCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of metros. +/// +/// A builder for the *list* method supported by a *metro* resource. +/// It is not used directly, but through a `MetroMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.metros().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct MetroListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MetroListCall<'a, C, A> {} + +impl<'a, C, A> MetroListCall<'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, MetrosListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.metros.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/metros".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MetroListCall<'a, C, A> { + self._profile_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) -> MetroListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MetroListCall<'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::Dfatrafficking`. + /// + /// 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) -> MetroListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of orders, possibly filtered. +/// +/// A builder for the *list* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.orders().list("profileId", "projectId") +/// .sort_order("nonumy") +/// .sort_field("et") +/// .add_site_id("sed") +/// .search_string("no") +/// .page_token("invidunt") +/// .max_results(-15) +/// .add_ids("labore") +/// .doit(); +/// # } +/// ``` +pub struct OrderListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderListCall<'a, C, A> {} + +impl<'a, C, A> OrderListCall<'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, OrdersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/orders".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// 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) -> OrderListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only orders that are associated with these site IDs. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for orders by name or ID. Wildcards (*) are allowed. For example, "order*2015" will return orders with names like "order June 2015", "order April 2015", or simply "order 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "order" will match orders with name "my order", "order 2015", or simply "order". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> OrderListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only orders with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._ids.push(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) -> OrderListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderListCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one order by ID. +/// +/// A builder for the *get* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.orders().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OrderGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderGetCall<'a, C, A> {} + +impl<'a, C, A> OrderGetCall<'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, Order)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/orders/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// 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) -> OrderGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._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) -> OrderGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one directory site contact by ID. +/// +/// A builder for the *get* method supported by a *directorySiteContact* resource. +/// It is not used directly, but through a `DirectorySiteContactMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_site_contacts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteContactGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteContactGetCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactGetCall<'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, DirectorySiteContact)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySiteContacts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/directorySiteContacts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Directory site contact ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, C, A> { + self._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) -> DirectorySiteContactGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteContactGetCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteContactGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of directory site contacts, possibly filtered. +/// +/// A builder for the *list* method supported by a *directorySiteContact* resource. +/// It is not used directly, but through a `DirectorySiteContactMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_site_contacts().list("profileId") +/// .sort_order("sea") +/// .sort_field("consetetur") +/// .search_string("diam") +/// .page_token("accusam") +/// .max_results(-68) +/// .add_ids("consetetur") +/// .add_directory_site_ids("dolor") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteContactListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _directory_site_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteContactListCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactListCall<'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, DirectorySiteContactsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySiteContacts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/directorySiteContacts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "directory site contact*2015" will return objects with names like "directory site contact June 2015", "directory site contact April 2015", or simply "directory site contact 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site contact" will match objects with name "my directory site contact", "directory site contact 2015", or simply "directory site contact". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DirectorySiteContactListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only directory site contacts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only directory site contacts with these directory site IDs. This is a required field. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._directory_site_ids.push(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) -> DirectorySiteContactListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteContactListCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteContactListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of user profiles for a user. +/// +/// A builder for the *list* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_profiles().list() +/// .doit(); +/// # } +/// ``` +pub struct UserProfileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserProfileListCall<'a, C, A> {} + +impl<'a, C, A> UserProfileListCall<'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, UserProfileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userProfiles.list", + 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/dfareporting/v2.5/userprofiles".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)); + } + + + + 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) -> UserProfileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileListCall<'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) -> UserProfileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user profile by ID. +/// +/// A builder for the *get* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_profiles().get("profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserProfileGetCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGetCall<'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, UserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userProfiles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserProfileGetCall<'a, C, A> { + self._profile_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) -> UserProfileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGetCall<'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) -> UserProfileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing ad. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdPatchCall<'a, C, A> {} + +impl<'a, C, A> AdPatchCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Ad ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdPatchCall<'a, C, A> { + self._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) -> AdPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new ad. +/// +/// A builder for the *insert* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdInsertCall<'a, C, A> {} + +impl<'a, C, A> AdInsertCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdInsertCall<'a, C, A> { + self._profile_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) -> AdInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of ads, possibly filtered. +/// +/// A builder for the *list* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.ads().list("profileId") +/// .add_type("sed") +/// .ssl_required(false) +/// .ssl_compliant(true) +/// .sort_order("dolore") +/// .sort_field("Lorem") +/// .add_size_ids("consetetur") +/// .search_string("consetetur") +/// .add_remarketing_list_ids("eirmod") +/// .add_placement_ids("labore") +/// .page_token("gubergren") +/// .overridden_event_tag_id("et") +/// .max_results(-45) +/// .add_landing_page_ids("accusam") +/// .add_ids("magna") +/// .dynamic_click_tracker(false) +/// .creative_type("rebum.") +/// .add_creative_optimization_configuration_ids("et") +/// .add_creative_ids("clita") +/// .compatibility("eos") +/// .add_campaign_ids("dolores") +/// .add_audience_segment_ids("vero") +/// .archived(false) +/// .advertiser_id("vero") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct AdListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _type_: Vec, + _ssl_required: Option, + _ssl_compliant: Option, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _search_string: Option, + _remarketing_list_ids: Vec, + _placement_ids: Vec, + _page_token: Option, + _overridden_event_tag_id: Option, + _max_results: Option, + _landing_page_ids: Vec, + _ids: Vec, + _dynamic_click_tracker: Option, + _creative_type: Option, + _creative_optimization_configuration_ids: Vec, + _creative_ids: Vec, + _compatibility: Option, + _campaign_ids: Vec, + _audience_segment_ids: Vec, + _archived: Option, + _advertiser_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdListCall<'a, C, A> {} + +impl<'a, C, A> AdListCall<'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, AdsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((27 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._type_.len() > 0 { + for f in self._type_.iter() { + params.push(("type", f.to_string())); + } + } + if let Some(value) = self._ssl_required { + params.push(("sslRequired", value.to_string())); + } + if let Some(value) = self._ssl_compliant { + params.push(("sslCompliant", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._remarketing_list_ids.len() > 0 { + for f in self._remarketing_list_ids.iter() { + params.push(("remarketingListIds", f.to_string())); + } + } + if self._placement_ids.len() > 0 { + for f in self._placement_ids.iter() { + params.push(("placementIds", f.to_string())); + } + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._overridden_event_tag_id { + params.push(("overriddenEventTagId", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._landing_page_ids.len() > 0 { + for f in self._landing_page_ids.iter() { + params.push(("landingPageIds", f.to_string())); + } + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._dynamic_click_tracker { + params.push(("dynamicClickTracker", value.to_string())); + } + if let Some(value) = self._creative_type { + params.push(("creativeType", value.to_string())); + } + if self._creative_optimization_configuration_ids.len() > 0 { + for f in self._creative_optimization_configuration_ids.iter() { + params.push(("creativeOptimizationConfigurationIds", f.to_string())); + } + } + if self._creative_ids.len() > 0 { + for f in self._creative_ids.iter() { + params.push(("creativeIds", f.to_string())); + } + } + if let Some(value) = self._compatibility { + params.push(("compatibility", value.to_string())); + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if self._audience_segment_ids.len() > 0 { + for f in self._audience_segment_ids.iter() { + params.push(("audienceSegmentIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "type", "sslRequired", "sslCompliant", "sortOrder", "sortField", "sizeIds", "searchString", "remarketingListIds", "placementIds", "pageToken", "overriddenEventTagId", "maxResults", "landingPageIds", "ids", "dynamicClickTracker", "creativeType", "creativeOptimizationConfigurationIds", "creativeIds", "compatibility", "campaignIds", "audienceSegmentIds", "archived", "advertiserId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only ads with these types. + /// + /// 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) -> AdListCall<'a, C, A> { + self._type_.push(new_value.to_string()); + self + } + /// Select only ads that require SSL. + /// + /// Sets the *ssl required* query property to the given value. + pub fn ssl_required(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._ssl_required = Some(new_value); + self + } + /// Select only ads that are SSL-compliant. + /// + /// Sets the *ssl compliant* query property to the given value. + pub fn ssl_compliant(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._ssl_compliant = Some(new_value); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only ads with these size IDs. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "ad*2015" will return objects with names like "ad June 2015", "ad April 2015", or simply "ad 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "ad" will match objects with name "my ad", "ad 2015", or simply "ad". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only ads whose list targeting expression use these remarketing list IDs. + /// + /// Append the given value to the *remarketing list ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_remarketing_list_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._remarketing_list_ids.push(new_value.to_string()); + self + } + /// Select only ads with these placement IDs assigned. + /// + /// Append the given value to the *placement ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._placement_ids.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only ads with this event tag override ID. + /// + /// Sets the *overridden event tag id* query property to the given value. + pub fn overridden_event_tag_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._overridden_event_tag_id = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only ads with these landing page IDs. + /// + /// Append the given value to the *landing page ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_landing_page_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._landing_page_ids.push(new_value.to_string()); + self + } + /// Select only ads with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only dynamic click trackers. Applicable when type is AD_SERVING_CLICK_TRACKER. If true, select dynamic click trackers. If false, select static click trackers. Leave unset to select both. + /// + /// Sets the *dynamic click tracker* query property to the given value. + pub fn dynamic_click_tracker(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._dynamic_click_tracker = Some(new_value); + self + } + /// Select only ads with the specified creativeType. + /// + /// Sets the *creative type* query property to the given value. + pub fn creative_type(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_type = Some(new_value.to_string()); + self + } + /// Select only ads with these creative optimization configuration IDs. + /// + /// Append the given value to the *creative optimization configuration ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_optimization_configuration_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_optimization_configuration_ids.push(new_value.to_string()); + self + } + /// Select only ads with these creative IDs assigned. + /// + /// Append the given value to the *creative ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_ids.push(new_value.to_string()); + self + } + /// Select default ads with the specified compatibility. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering an in-stream video ads developed with the VAST standard. + /// + /// Sets the *compatibility* query property to the given value. + pub fn compatibility(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._compatibility = Some(new_value.to_string()); + self + } + /// Select only ads with these campaign IDs. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only ads with these audience segment IDs. + /// + /// Append the given value to the *audience segment ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_audience_segment_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._audience_segment_ids.push(new_value.to_string()); + self + } + /// Select only archived ads. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only ads with this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only active ads. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._active = 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) -> AdListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one ad by ID. +/// +/// A builder for the *get* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.ads().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdGetCall<'a, C, A> {} + +impl<'a, C, A> AdGetCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/ads/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Ad ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdGetCall<'a, C, A> { + self._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) -> AdGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing ad. +/// +/// A builder for the *update* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdUpdateCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdUpdateCall<'a, C, A> { + self._profile_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) -> AdUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account permission by ID. +/// +/// A builder for the *get* method supported by a *accountPermission* resource. +/// It is not used directly, but through a `AccountPermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permissions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGetCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGetCall<'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, AccountPermission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountPermissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account permission ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C, A> { + self._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) -> AccountPermissionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of account permissions. +/// +/// A builder for the *list* method supported by a *accountPermission* resource. +/// It is not used directly, but through a `AccountPermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permissions().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionListCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionListCall<'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, AccountPermissionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountPermissions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionListCall<'a, C, A> { + self._profile_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) -> AccountPermissionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of connection types. +/// +/// A builder for the *list* method supported by a *connectionType* resource. +/// It is not used directly, but through a `ConnectionTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.connection_types().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct ConnectionTypeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConnectionTypeListCall<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeListCall<'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, ConnectionTypesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.connectionTypes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/connectionTypes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConnectionTypeListCall<'a, C, A> { + self._profile_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) -> ConnectionTypeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConnectionTypeListCall<'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::Dfatrafficking`. + /// + /// 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) -> ConnectionTypeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one connection type by ID. +/// +/// A builder for the *get* method supported by a *connectionType* resource. +/// It is not used directly, but through a `ConnectionTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.connection_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ConnectionTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConnectionTypeGetCall<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeGetCall<'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, ConnectionType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.connectionTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/connectionTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Connection type ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._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) -> ConnectionTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConnectionTypeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ConnectionTypeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one advertiser group by ID. +/// +/// A builder for the *get* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupGetCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupGetCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, C, A> { + self._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) -> AdvertiserGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of advertiser groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().list("profileId") +/// .sort_order("accusam") +/// .sort_field("labore") +/// .search_string("diam") +/// .page_token("nonumy") +/// .max_results(-93) +/// .add_ids("diam") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupListCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupListCall<'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, AdvertiserGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser group June 2015", "advertiser group April 2015", or simply "advertiser group 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertisergroup" will match objects with name "my advertisergroup", "advertisergroup 2015", or simply "advertisergroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdvertiserGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only advertiser groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._ids.push(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) -> AdvertiserGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new advertiser group. +/// +/// A builder for the *insert* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupInsertCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupInsertCall<'a, C, A> { + self._profile_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) -> AdvertiserGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser group. +/// +/// A builder for the *update* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupUpdateCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._profile_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) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupPatchCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + self._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) -> AdvertiserGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing advertiser group. +/// +/// A builder for the *delete* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupDeleteCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupDeleteCall<'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: "dfareporting.advertiserGroups.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._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) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new site. +/// +/// A builder for the *insert* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SiteInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteInsertCall<'a, C, A> {} + +impl<'a, C, A> SiteInsertCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SiteInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteInsertCall<'a, C, A> { + self._profile_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) -> SiteInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one site by ID. +/// +/// A builder for the *get* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sites().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SiteGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteGetCall<'a, C, A> {} + +impl<'a, C, A> SiteGetCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sites/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Site ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SiteGetCall<'a, C, A> { + self._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) -> SiteGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of sites, possibly filtered. +/// +/// A builder for the *list* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sites().list("profileId") +/// .unmapped_site(false) +/// .subaccount_id("dolores") +/// .sort_order("dolores") +/// .sort_field("et") +/// .search_string("sed") +/// .page_token("et") +/// .max_results(-31) +/// .add_ids("nonumy") +/// .add_directory_site_ids("sit") +/// .add_campaign_ids("aliquyam") +/// .approved(false) +/// .ad_words_site(true) +/// .accepts_publisher_paid_placements(false) +/// .accepts_interstitial_placements(false) +/// .accepts_in_stream_video_placements(false) +/// .doit(); +/// # } +/// ``` +pub struct SiteListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _unmapped_site: Option, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _directory_site_ids: Vec, + _campaign_ids: Vec, + _approved: Option, + _ad_words_site: Option, + _accepts_publisher_paid_placements: Option, + _accepts_interstitial_placements: Option, + _accepts_in_stream_video_placements: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteListCall<'a, C, A> {} + +impl<'a, C, A> SiteListCall<'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, SitesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((18 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._unmapped_site { + params.push(("unmappedSite", value.to_string())); + } + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + if let Some(value) = self._ad_words_site { + params.push(("adWordsSite", value.to_string())); + } + if let Some(value) = self._accepts_publisher_paid_placements { + params.push(("acceptsPublisherPaidPlacements", value.to_string())); + } + if let Some(value) = self._accepts_interstitial_placements { + params.push(("acceptsInterstitialPlacements", value.to_string())); + } + if let Some(value) = self._accepts_in_stream_video_placements { + params.push(("acceptsInStreamVideoPlacements", value.to_string())); + } + for &field in ["alt", "profileId", "unmappedSite", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds", "campaignIds", "approved", "adWordsSite", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only sites that have not been mapped to a directory site. + /// + /// Sets the *unmapped site* query property to the given value. + pub fn unmapped_site(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._unmapped_site = Some(new_value); + self + } + /// Select only sites with this subaccount ID. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or keyName. Wildcards (*) are allowed. For example, "site*2015" will return objects with names like "site June 2015", "site April 2015", or simply "site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "site" will match objects with name "my site", "site 2015", or simply "site". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> SiteListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only sites with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only sites with these directory site IDs. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only sites with these campaign IDs. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only approved sites. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._approved = Some(new_value); + self + } + /// Select only AdWords sites. + /// + /// Sets the *ad words site* query property to the given value. + pub fn ad_words_site(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._ad_words_site = Some(new_value); + self + } + /// Select only sites that accept publisher paid placements. + /// + /// Sets the *accepts publisher paid placements* query property to the given value. + pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_publisher_paid_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts interstitial placements* query property to the given value. + pub fn accepts_interstitial_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_interstitial_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts in stream video placements* query property to the given value. + pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_in_stream_video_placements = 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) -> SiteListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteListCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing site. +/// +/// A builder for the *update* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SiteUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteUpdateCall<'a, C, A> {} + +impl<'a, C, A> SiteUpdateCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SiteUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteUpdateCall<'a, C, A> { + self._profile_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) -> SiteUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing site. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SitePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SitePatchCall<'a, C, A> {} + +impl<'a, C, A> SitePatchCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SitePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SitePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Site ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> SitePatchCall<'a, C, A> { + self._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) -> SitePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SitePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> SitePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight activity by ID. +/// +/// A builder for the *get* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGetCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, C, A> { + self._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) -> FloodlightActivityGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight activities, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().list("profileId") +/// .tag_string("diam") +/// .sort_order("eirmod") +/// .sort_field("sadipscing") +/// .search_string("Lorem") +/// .page_token("sed") +/// .max_results(-2) +/// .add_ids("dolore") +/// .floodlight_configuration_id("et") +/// .floodlight_activity_group_type("At") +/// .floodlight_activity_group_tag_string("sit") +/// .floodlight_activity_group_name("ut") +/// .add_floodlight_activity_group_ids("diam") +/// .advertiser_id("tempor") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _tag_string: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _floodlight_configuration_id: Option, + _floodlight_activity_group_type: Option, + _floodlight_activity_group_tag_string: Option, + _floodlight_activity_group_name: Option, + _floodlight_activity_group_ids: Vec, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityListCall<'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, FloodlightActivitiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._tag_string { + params.push(("tagString", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._floodlight_configuration_id { + params.push(("floodlightConfigurationId", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_type { + params.push(("floodlightActivityGroupType", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_tag_string { + params.push(("floodlightActivityGroupTagString", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_name { + params.push(("floodlightActivityGroupName", value.to_string())); + } + if self._floodlight_activity_group_ids.len() > 0 { + for f in self._floodlight_activity_group_ids.iter() { + params.push(("floodlightActivityGroupIds", f.to_string())); + } + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "tagString", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "floodlightActivityGroupType", "floodlightActivityGroupTagString", "floodlightActivityGroupName", "floodlightActivityGroupIds", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only floodlight activities with the specified tag string. + /// + /// Sets the *tag string* query property to the given value. + pub fn tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._tag_string = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivity*2015" will return objects with names like "floodlightactivity June 2015", "floodlightactivity April 2015", or simply "floodlightactivity 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivity" will match objects with name "my floodlightactivity activity", "floodlightactivity 2015", or simply "floodlightactivity". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FloodlightActivityListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only floodlight activities with the specified IDs. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only floodlight activities for the specified floodlight configuration ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *floodlight configuration id* query property to the given value. + pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_configuration_id = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group type. + /// + /// Sets the *floodlight activity group type* query property to the given value. + pub fn floodlight_activity_group_type(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_type = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group tag string. + /// + /// Sets the *floodlight activity group tag string* query property to the given value. + pub fn floodlight_activity_group_tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_tag_string = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group name. + /// + /// Sets the *floodlight activity group name* query property to the given value. + pub fn floodlight_activity_group_name(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_name = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group IDs. + /// + /// Append the given value to the *floodlight activity group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_floodlight_activity_group_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_ids.push(new_value.to_string()); + self + } + /// Select only floodlight activities for the specified advertiser ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._advertiser_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) -> FloodlightActivityListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new floodlight activity. +/// +/// A builder for the *insert* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityInsertCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityInsertCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityInsertCall<'a, C, A> { + self._profile_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) -> FloodlightActivityInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing floodlight activity. +/// +/// A builder for the *delete* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityDeleteCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityDeleteCall<'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: "dfareporting.floodlightActivities.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + self._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) -> FloodlightActivityDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityPatchCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, C, A> { + self._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) -> FloodlightActivityPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates a tag for a floodlight activity. +/// +/// A builder for the *generatetag* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().generatetag("profileId") +/// .floodlight_activity_id("sed") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGeneratetagCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _floodlight_activity_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGeneratetagCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGeneratetagCall<'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, FloodlightActivitiesGenerateTagResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.generatetag", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._floodlight_activity_id { + params.push(("floodlightActivityId", value.to_string())); + } + for &field in ["alt", "profileId", "floodlightActivityId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities/generatetag".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID for which we want to generate a tag. + /// + /// Sets the *floodlight activity id* query property to the given value. + pub fn floodlight_activity_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._floodlight_activity_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) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGeneratetagCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGeneratetagCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity. +/// +/// A builder for the *update* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityUpdateCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightActivityUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of regions. +/// +/// 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_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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("profileId") +/// .doit(); +/// # } +/// ``` +pub struct RegionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _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, RegionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.regions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/regions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RegionListCall<'a, C, A> { + self._profile_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) -> 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::Dfatrafficking`. + /// + /// 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 + } +} + + +/// Inserts a new creative group. +/// +/// A builder for the *insert* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupInsertCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupInsertCall<'a, C, A> { + self._profile_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) -> CreativeGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative group by ID. +/// +/// A builder for the *get* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupGetCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, C, A> { + self._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) -> CreativeGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative group. +/// +/// A builder for the *update* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupUpdateCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupUpdateCall<'a, C, A> { + self._profile_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) -> CreativeGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_groups().list("profileId") +/// .sort_order("labore") +/// .sort_field("nonumy") +/// .search_string("erat") +/// .page_token("gubergren") +/// .max_results(-30) +/// .add_ids("et") +/// .group_number(-97) +/// .add_advertiser_ids("Lorem") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _group_number: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupListCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupListCall<'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, CreativeGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._group_number { + params.push(("groupNumber", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "groupNumber", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative groups by name or ID. Wildcards (*) are allowed. For example, "creativegroup*2015" will return creative groups with names like "creativegroup June 2015", "creativegroup April 2015", or simply "creativegroup 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativegroup" will match creative groups with the name "my creativegroup", "creativegroup 2015", or simply "creativegroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creative groups that belong to this subgroup. + /// + /// Sets the *group number* query property to the given value. + pub fn group_number(mut self, new_value: i32) -> CreativeGroupListCall<'a, C, A> { + self._group_number = Some(new_value); + self + } + /// Select only creative groups that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._advertiser_ids.push(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) -> CreativeGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupPatchCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, C, A> { + self._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) -> CreativeGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of targetable remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targetable_remarketing_lists().list("profileId", "advertiserId") +/// .sort_order("voluptua.") +/// .sort_field("takimata") +/// .page_token("dolor") +/// .name("takimata") +/// .max_results(-28) +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _name: Option, + _max_results: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListListCall<'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, TargetableRemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/targetableRemarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only targetable remarketing lists targetable by these advertisers. + /// + /// Sets the *advertiser id* 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 advertiser_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> TargetableRemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only active or only inactive targetable remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> TargetableRemarketingListListCall<'a, C, A> { + self._active = 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) -> TargetableRemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetableRemarketingListListCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetableRemarketingListListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targetable_remarketing_lists().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListGetCall<'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, TargetableRemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/targetableRemarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._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) -> TargetableRemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetableRemarketingListGetCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetableRemarketingListGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing subaccount. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountPatchCall<'a, C, A> {} + +impl<'a, C, A> SubaccountPatchCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Subaccount ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> SubaccountPatchCall<'a, C, A> { + self._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) -> SubaccountPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new subaccount. +/// +/// A builder for the *insert* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountInsertCall<'a, C, A> {} + +impl<'a, C, A> SubaccountInsertCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountInsertCall<'a, C, A> { + self._profile_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) -> SubaccountInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing subaccount. +/// +/// A builder for the *update* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountUpdateCall<'a, C, A> {} + +impl<'a, C, A> SubaccountUpdateCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountUpdateCall<'a, C, A> { + self._profile_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) -> SubaccountUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of subaccounts, possibly filtered. +/// +/// A builder for the *list* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.subaccounts().list("profileId") +/// .sort_order("consetetur") +/// .sort_field("sea") +/// .search_string("nonumy") +/// .page_token("consetetur") +/// .max_results(-73) +/// .add_ids("clita") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountListCall<'a, C, A> {} + +impl<'a, C, A> SubaccountListCall<'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, SubaccountsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "subaccount*2015" will return objects with names like "subaccount June 2015", "subaccount April 2015", or simply "subaccount 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "subaccount" will match objects with name "my subaccount", "subaccount 2015", or simply "subaccount". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> SubaccountListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only subaccounts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._ids.push(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) -> SubaccountListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountListCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one subaccount by ID. +/// +/// A builder for the *get* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.subaccounts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountGetCall<'a, C, A> {} + +impl<'a, C, A> SubaccountGetCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/subaccounts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Subaccount ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SubaccountGetCall<'a, C, A> { + self._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) -> SubaccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one mobile carrier by ID. +/// +/// A builder for the *get* method supported by a *mobileCarrier* resource. +/// It is not used directly, but through a `MobileCarrierMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.mobile_carriers().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct MobileCarrierGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MobileCarrierGetCall<'a, C, A> {} + +impl<'a, C, A> MobileCarrierGetCall<'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, MobileCarrier)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.mobileCarriers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/mobileCarriers/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Mobile carrier ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._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) -> MobileCarrierGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MobileCarrierGetCall<'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::Dfatrafficking`. + /// + /// 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) -> MobileCarrierGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of mobile carriers. +/// +/// A builder for the *list* method supported by a *mobileCarrier* resource. +/// It is not used directly, but through a `MobileCarrierMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.mobile_carriers().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct MobileCarrierListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MobileCarrierListCall<'a, C, A> {} + +impl<'a, C, A> MobileCarrierListCall<'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, MobileCarriersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.mobileCarriers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/mobileCarriers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MobileCarrierListCall<'a, C, A> { + self._profile_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) -> MobileCarrierListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MobileCarrierListCall<'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::Dfatrafficking`. + /// + /// 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) -> MobileCarrierListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight configuration by ID. +/// +/// A builder for the *get* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_configurations().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationGetCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightConfigurations/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight configuration ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._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) -> FloodlightConfigurationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight configuration. +/// +/// A builder for the *update* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightConfiguration::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.floodlight_configurations().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightConfiguration, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationUpdateCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightConfiguration) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight configuration. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::FloodlightConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightConfiguration::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.floodlight_configurations().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightConfiguration, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationPatchCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightConfiguration) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight configuration ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._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) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight configurations, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_configurations().list("profileId") +/// .add_ids("sanctus") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationListCall<'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, FloodlightConfigurationsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Set of IDs of floodlight configurations to retrieve. Required field; otherwise an empty list will be returned. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, C, A> { + self._ids.push(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) -> FloodlightConfigurationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of operating systems. +/// +/// A builder for the *list* method supported by a *operatingSystem* resource. +/// It is not used directly, but through a `OperatingSystemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_systems().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemListCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemListCall<'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, OperatingSystemsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystems.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/operatingSystems".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemListCall<'a, C, A> { + self._profile_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) -> OperatingSystemListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemListCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one operating system by DART ID. +/// +/// A builder for the *get* method supported by a *operatingSystem* resource. +/// It is not used directly, but through a `OperatingSystemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_systems().get("profileId", "dartId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _dart_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemGetCall<'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, OperatingSystem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("dartId", self._dart_id.to_string())); + for &field in ["alt", "profileId", "dartId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/operatingSystems/{dartId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].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 ["dartId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system DART ID. + /// + /// Sets the *dart 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 dart_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._dart_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) -> OperatingSystemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists files for a user profile. +/// +/// A builder for the *list* method supported by a *file* resource. +/// It is not used directly, but through a `FileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.files().list("profileId") +/// .sort_order("et") +/// .sort_field("clita") +/// .scope("ipsum") +/// .page_token("dolor") +/// .max_results(-94) +/// .doit(); +/// # } +/// ``` +pub struct FileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _scope: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FileListCall<'a, C, A> {} + +impl<'a, C, A> FileListCall<'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, FileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.files.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._scope { + params.push(("scope", value.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())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "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/dfareporting/v2.5/userprofiles/{profileId}/files".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The scope that defines which results are returned, default is 'MINE'. + /// + /// Sets the *scope* query property to the given value. + pub fn scope(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._scope = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FileListCall<'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) -> FileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FileListCall<'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) -> FileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report file by its report ID and file ID. +/// +/// 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 `File` structure that you would usually get. The latter will be a default value. +/// +/// A builder for the *get* method supported by a *file* resource. +/// It is not used directly, but through a `FileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.files().get("reportId", "fileId") +/// .doit(); +/// # } +/// ``` +pub struct FileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _report_id: String, + _file_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FileGetCall<'a, C, A> {} + +impl<'a, C, A> FileGetCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.files.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("reportId", self._report_id.to_string())); + params.push(("fileId", self._file_id.to_string())); + for &field in ["reportId", "fileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/reports/{reportId}/files/{fileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{reportId}", "reportId"), ("{fileId}", "fileId")].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 ["fileId", "reportId"].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 = 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) + } + } + } + } + + + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> FileGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The ID of the report file. + /// + /// Sets the *file 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 file_id(mut self, new_value: &str) -> FileGetCall<'a, C, A> { + self._file_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) -> FileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FileGetCall<'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) -> FileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placement groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_groups().list("profileId") +/// .sort_order("duo") +/// .sort_field("et") +/// .add_site_ids("sit") +/// .search_string("eirmod") +/// .add_pricing_types("no") +/// .add_placement_strategy_ids("Lorem") +/// .placement_group_type("sed") +/// .page_token("tempor") +/// .min_start_date("clita") +/// .min_end_date("kasd") +/// .max_start_date("elitr") +/// .max_results(-68) +/// .max_end_date("vero") +/// .add_ids("sadipscing") +/// .add_directory_site_ids("sed") +/// .add_content_category_ids("vero") +/// .add_campaign_ids("nonumy") +/// .archived(false) +/// .add_advertiser_ids("ea") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _site_ids: Vec, + _search_string: Option, + _pricing_types: Vec, + _placement_strategy_ids: Vec, + _placement_group_type: Option, + _page_token: Option, + _min_start_date: Option, + _min_end_date: Option, + _max_start_date: Option, + _max_results: Option, + _max_end_date: Option, + _ids: Vec, + _directory_site_ids: Vec, + _content_category_ids: Vec, + _campaign_ids: Vec, + _archived: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupListCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupListCall<'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, PlacementGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((22 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_ids.len() > 0 { + for f in self._site_ids.iter() { + params.push(("siteIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._pricing_types.len() > 0 { + for f in self._pricing_types.iter() { + params.push(("pricingTypes", f.to_string())); + } + } + if self._placement_strategy_ids.len() > 0 { + for f in self._placement_strategy_ids.iter() { + params.push(("placementStrategyIds", f.to_string())); + } + } + if let Some(value) = self._placement_group_type { + params.push(("placementGroupType", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._min_start_date { + params.push(("minStartDate", value.to_string())); + } + if let Some(value) = self._min_end_date { + params.push(("minEndDate", value.to_string())); + } + if let Some(value) = self._max_start_date { + params.push(("maxStartDate", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_end_date { + params.push(("maxEndDate", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._content_category_ids.len() > 0 { + for f in self._content_category_ids.iter() { + params.push(("contentCategoryIds", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "placementGroupType", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "directorySiteIds", "contentCategoryIds", "campaignIds", "archived", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these sites. + /// + /// Append the given value to the *site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._site_ids.push(new_value.to_string()); + self + } + /// Allows searching for placement groups by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placement groups with names like "placement group June 2015", "placement group May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementgroup" will match placement groups with name "my placementgroup", "placementgroup 2015", or simply "placementgroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only placement groups with these pricing types. + /// + /// Append the given value to the *pricing types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_pricing_types(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._pricing_types.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these placement strategies. + /// + /// Append the given value to the *placement strategy ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._placement_strategy_ids.push(new_value.to_string()); + self + } + /// Select only placement groups belonging with this group type. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting. + /// + /// Sets the *placement group type* query property to the given value. + pub fn placement_group_type(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._placement_group_type = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min start date* query property to the given value. + pub fn min_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._min_start_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min end date* query property to the given value. + pub fn min_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._min_end_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max start date* query property to the given value. + pub fn max_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._max_start_date = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max end date* query property to the given value. + pub fn max_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._max_end_date = Some(new_value.to_string()); + self + } + /// Select only placement groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these directory sites. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these content categories. + /// + /// Append the given value to the *content category ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._content_category_ids.push(new_value.to_string()); + self + } + /// Select only placement groups that belong to these campaigns. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only archived placements. Don't set this field to select both archived and non-archived placements. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> PlacementGroupListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only placement groups that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._advertiser_ids.push(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) -> PlacementGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement group. +/// +/// A builder for the *update* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupUpdateCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupUpdateCall<'a, C, A> { + self._profile_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) -> PlacementGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement group. +/// +/// A builder for the *insert* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupInsertCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupInsertCall<'a, C, A> { + self._profile_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) -> PlacementGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement group by ID. +/// +/// A builder for the *get* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupGetCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, C, A> { + self._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) -> PlacementGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupPatchCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, C, A> { + self._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) -> PlacementGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of inventory items, possibly filtered. +/// +/// A builder for the *list* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.inventory_items().list("profileId", "projectId") +/// .type_("et") +/// .sort_order("justo") +/// .sort_field("kasd") +/// .add_site_id("kasd") +/// .page_token("ipsum") +/// .add_order_id("eos") +/// .max_results(-91) +/// .in_plan(true) +/// .add_ids("voluptua.") +/// .doit(); +/// # } +/// ``` +pub struct InventoryItemListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _type_: Option, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _page_token: Option, + _order_id: Vec, + _max_results: Option, + _in_plan: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InventoryItemListCall<'a, C, A> {} + +impl<'a, C, A> InventoryItemListCall<'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, InventoryItemsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if self._order_id.len() > 0 { + for f in self._order_id.iter() { + params.push(("orderId", f.to_string())); + } + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._in_plan { + params.push(("inPlan", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "projectId", "type", "sortOrder", "sortField", "siteId", "pageToken", "orderId", "maxResults", "inPlan", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/inventoryItems".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> InventoryItemListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Select only inventory items with this type. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._type_ = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only inventory items that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only inventory items that belong to specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> InventoryItemListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only inventory items that are in plan. + /// + /// Sets the *in plan* query property to the given value. + pub fn in_plan(mut self, new_value: bool) -> InventoryItemListCall<'a, C, A> { + self._in_plan = Some(new_value); + self + } + /// Select only inventory items with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._ids.push(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) -> InventoryItemListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InventoryItemListCall<'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::Dfatrafficking`. + /// + /// 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) -> InventoryItemListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one inventory item by ID. +/// +/// A builder for the *get* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.inventory_items().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct InventoryItemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InventoryItemGetCall<'a, C, A> {} + +impl<'a, C, A> InventoryItemGetCall<'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, InventoryItem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/inventoryItems/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> InventoryItemGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Inventory item ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._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) -> InventoryItemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InventoryItemGetCall<'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::Dfatrafficking`. + /// + /// 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) -> InventoryItemGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role permission by ID. +/// +/// A builder for the *get* method supported by a *userRolePermission* resource. +/// It is not used directly, but through a `UserRolePermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permissions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGetCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGetCall<'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, UserRolePermission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRolePermissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role permission ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, C, A> { + self._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) -> UserRolePermissionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of user role permissions, possibly filtered. +/// +/// A builder for the *list* method supported by a *userRolePermission* resource. +/// It is not used directly, but through a `UserRolePermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permissions().list("profileId") +/// .add_ids("tempor") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionListCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionListCall<'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, UserRolePermissionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/userRolePermissions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user role permissions with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> UserRolePermissionListCall<'a, C, A> { + self._ids.push(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) -> UserRolePermissionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of account permission groups. +/// +/// A builder for the *list* method supported by a *accountPermissionGroup* resource. +/// It is not used directly, but through a `AccountPermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permission_groups().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGroupListCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupListCall<'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, AccountPermissionGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissionGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountPermissionGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGroupListCall<'a, C, A> { + self._profile_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) -> AccountPermissionGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account permission group by ID. +/// +/// A builder for the *get* method supported by a *accountPermissionGroup* resource. +/// It is not used directly, but through a `AccountPermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permission_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGroupGetCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupGetCall<'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, AccountPermissionGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissionGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountPermissionGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account permission group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + self._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) -> AccountPermissionGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of content categories, possibly filtered. +/// +/// A builder for the *list* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().list("profileId") +/// .sort_order("clita") +/// .sort_field("et") +/// .search_string("eirmod") +/// .page_token("ea") +/// .max_results(-71) +/// .add_ids("sed") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryListCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryListCall<'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, ContentCategoriesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "contentcategory*2015" will return objects with names like "contentcategory June 2015", "contentcategory April 2015", or simply "contentcategory 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "contentcategory" will match objects with name "my contentcategory", "contentcategory 2015", or simply "contentcategory". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ContentCategoryListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only content categories with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._ids.push(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) -> ContentCategoryListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryListCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing content category. +/// +/// A builder for the *update* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryUpdateCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryUpdateCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryUpdateCall<'a, C, A> { + self._profile_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) -> ContentCategoryUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new content category. +/// +/// A builder for the *insert* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryInsertCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryInsertCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryInsertCall<'a, C, A> { + self._profile_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) -> ContentCategoryInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing content category. +/// +/// A builder for the *delete* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryDeleteCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryDeleteCall<'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: "dfareporting.contentCategories.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, C, A> { + self._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) -> ContentCategoryDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one content category by ID. +/// +/// A builder for the *get* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryGetCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryGetCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, C, A> { + self._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) -> ContentCategoryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing content category. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryPatchCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryPatchCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, C, A> { + self._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) -> ContentCategoryPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative. +/// +/// A builder for the *update* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeUpdateCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativeUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeUpdateCall<'a, C, A> { + self._profile_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) -> CreativeUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative. +/// +/// A builder for the *insert* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeInsertCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativeInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeInsertCall<'a, C, A> { + self._profile_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) -> CreativeInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative by ID. +/// +/// A builder for the *get* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creatives().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeGetCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creatives/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeGetCall<'a, C, A> { + self._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) -> CreativeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creatives, possibly filtered. +/// +/// A builder for the *list* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creatives().list("profileId") +/// .add_types("invidunt") +/// .studio_creative_id("voluptua.") +/// .sort_order("erat") +/// .sort_field("ipsum") +/// .add_size_ids("no") +/// .search_string("vero") +/// .add_rendering_ids("sed") +/// .page_token("vero") +/// .max_results(-84) +/// .add_ids("Lorem") +/// .add_creative_field_ids("invidunt") +/// .add_companion_creative_ids("duo") +/// .campaign_id("dolor") +/// .archived(false) +/// .advertiser_id("diam") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct CreativeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _types: Vec, + _studio_creative_id: Option, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _search_string: Option, + _rendering_ids: Vec, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _creative_field_ids: Vec, + _companion_creative_ids: Vec, + _campaign_id: Option, + _archived: Option, + _advertiser_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeListCall<'a, C, A> {} + +impl<'a, C, A> CreativeListCall<'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, CreativesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((19 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._types.len() > 0 { + for f in self._types.iter() { + params.push(("types", f.to_string())); + } + } + if let Some(value) = self._studio_creative_id { + params.push(("studioCreativeId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._rendering_ids.len() > 0 { + for f in self._rendering_ids.iter() { + params.push(("renderingIds", f.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._creative_field_ids.len() > 0 { + for f in self._creative_field_ids.iter() { + params.push(("creativeFieldIds", f.to_string())); + } + } + if self._companion_creative_ids.len() > 0 { + for f in self._companion_creative_ids.iter() { + params.push(("companionCreativeIds", f.to_string())); + } + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "types", "studioCreativeId", "sortOrder", "sortField", "sizeIds", "searchString", "renderingIds", "pageToken", "maxResults", "ids", "creativeFieldIds", "companionCreativeIds", "campaignId", "archived", "advertiserId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only creatives with these creative types. + /// + /// Append the given value to the *types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_types(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._types.push(new_value.to_string()); + self + } + /// Select only creatives corresponding to this Studio creative ID. + /// + /// Sets the *studio creative id* query property to the given value. + pub fn studio_creative_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._studio_creative_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only creatives with these size IDs. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "creative*2015" will return objects with names like "creative June 2015", "creative April 2015", or simply "creative 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "creative" will match objects with name "my creative", "creative 2015", or simply "creative". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only creatives with these rendering IDs. + /// + /// Append the given value to the *rendering ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_rendering_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._rendering_ids.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creatives with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creatives with these creative field IDs. + /// + /// Append the given value to the *creative field ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_field_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._creative_field_ids.push(new_value.to_string()); + self + } + /// Select only in-stream video creatives with these companion IDs. + /// + /// Append the given value to the *companion creative ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_companion_creative_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._companion_creative_ids.push(new_value.to_string()); + self + } + /// Select only creatives with this campaign ID. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._campaign_id = Some(new_value.to_string()); + self + } + /// Select only archived creatives. Leave blank to select archived and unarchived creatives. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> CreativeListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only creatives with this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only active creatives. Leave blank to select active and inactive creatives. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> CreativeListCall<'a, C, A> { + self._active = 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) -> CreativeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativePatchCall<'a, C, A> {} + +impl<'a, C, A> CreativePatchCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativePatchCall<'a, C, A> { + self._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) -> CreativePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one campaign by ID. +/// +/// A builder for the *get* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaigns().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CampaignGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignGetCall<'a, C, A> {} + +impl<'a, C, A> CampaignGetCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CampaignGetCall<'a, C, A> { + self._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) -> CampaignGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new campaign. +/// +/// A builder for the *insert* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().insert(req, "profileId", "defaultLandingPageName", "defaultLandingPageUrl") +/// .doit(); +/// # } +/// ``` +pub struct CampaignInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _default_landing_page_name: String, + _default_landing_page_url: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignInsertCall<'a, C, A> {} + +impl<'a, C, A> CampaignInsertCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("defaultLandingPageName", self._default_landing_page_name.to_string())); + params.push(("defaultLandingPageUrl", self._default_landing_page_url.to_string())); + for &field in ["alt", "profileId", "defaultLandingPageName", "defaultLandingPageUrl"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Default landing page name for this new campaign. Must be less than 256 characters long. + /// + /// Sets the *default landing page 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 default_landing_page_name(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._default_landing_page_name = new_value.to_string(); + self + } + /// Default landing page URL for this new campaign. + /// + /// Sets the *default landing page url* 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 default_landing_page_url(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._default_landing_page_url = 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) -> CampaignInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CampaignPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignPatchCall<'a, C, A> {} + +impl<'a, C, A> CampaignPatchCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CampaignPatchCall<'a, C, A> { + self._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) -> CampaignPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign. +/// +/// A builder for the *update* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CampaignUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignUpdateCall<'a, C, A> {} + +impl<'a, C, A> CampaignUpdateCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignUpdateCall<'a, C, A> { + self._profile_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) -> CampaignUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of campaigns, possibly filtered. +/// +/// A builder for the *list* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaigns().list("profileId") +/// .subaccount_id("duo") +/// .sort_order("ipsum") +/// .sort_field("diam") +/// .search_string("sed") +/// .page_token("et") +/// .overridden_event_tag_id("tempor") +/// .max_results(-20) +/// .add_ids("takimata") +/// .add_excluded_ids("invidunt") +/// .at_least_one_optimization_activity(true) +/// .archived(false) +/// .add_advertiser_ids("voluptua.") +/// .add_advertiser_group_ids("et") +/// .doit(); +/// # } +/// ``` +pub struct CampaignListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _overridden_event_tag_id: Option, + _max_results: Option, + _ids: Vec, + _excluded_ids: Vec, + _at_least_one_optimization_activity: Option, + _archived: Option, + _advertiser_ids: Vec, + _advertiser_group_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignListCall<'a, C, A> {} + +impl<'a, C, A> CampaignListCall<'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, CampaignsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._overridden_event_tag_id { + params.push(("overriddenEventTagId", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._excluded_ids.len() > 0 { + for f in self._excluded_ids.iter() { + params.push(("excludedIds", f.to_string())); + } + } + if let Some(value) = self._at_least_one_optimization_activity { + params.push(("atLeastOneOptimizationActivity", value.to_string())); + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + if self._advertiser_group_ids.len() > 0 { + for f in self._advertiser_group_ids.iter() { + params.push(("advertiserGroupIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "overriddenEventTagId", "maxResults", "ids", "excludedIds", "atLeastOneOptimizationActivity", "archived", "advertiserIds", "advertiserGroupIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only campaigns that belong to this subaccount. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for campaigns by name or ID. Wildcards (*) are allowed. For example, "campaign*2015" will return campaigns with names like "campaign June 2015", "campaign April 2015", or simply "campaign 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "campaign" will match campaigns with name "my campaign", "campaign 2015", or simply "campaign". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only campaigns that have overridden this event tag ID. + /// + /// Sets the *overridden event tag id* query property to the given value. + pub fn overridden_event_tag_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._overridden_event_tag_id = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CampaignListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only campaigns with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Exclude campaigns with these IDs. + /// + /// Append the given value to the *excluded ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_excluded_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._excluded_ids.push(new_value.to_string()); + self + } + /// Select only campaigns that have at least one optimization activity. + /// + /// Sets the *at least one optimization activity* query property to the given value. + pub fn at_least_one_optimization_activity(mut self, new_value: bool) -> CampaignListCall<'a, C, A> { + self._at_least_one_optimization_activity = Some(new_value); + self + } + /// Select only archived campaigns. Don't set this field to select both archived and non-archived campaigns. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> CampaignListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only campaigns that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._advertiser_ids.push(new_value.to_string()); + self + } + /// Select only campaigns whose advertisers belong to these advertiser groups. + /// + /// Append the given value to the *advertiser group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_group_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._advertiser_group_ids.push(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) -> CampaignListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignListCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing event tag. +/// +/// A builder for the *delete* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagDeleteCall<'a, C, A> {} + +impl<'a, C, A> EventTagDeleteCall<'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: "dfareporting.eventTags.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> EventTagDeleteCall<'a, C, A> { + self._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) -> EventTagDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of event tags, possibly filtered. +/// +/// A builder for the *list* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().list("profileId") +/// .sort_order("justo") +/// .sort_field("gubergren") +/// .search_string("ipsum") +/// .add_ids("amet.") +/// .add_event_tag_types("dolor") +/// .enabled(false) +/// .definitions_only(false) +/// .campaign_id("magna") +/// .advertiser_id("amet.") +/// .ad_id("eirmod") +/// .doit(); +/// # } +/// ``` +pub struct EventTagListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _ids: Vec, + _event_tag_types: Vec, + _enabled: Option, + _definitions_only: Option, + _campaign_id: Option, + _advertiser_id: Option, + _ad_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagListCall<'a, C, A> {} + +impl<'a, C, A> EventTagListCall<'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, EventTagsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._event_tag_types.len() > 0 { + for f in self._event_tag_types.iter() { + params.push(("eventTagTypes", f.to_string())); + } + } + if let Some(value) = self._enabled { + params.push(("enabled", value.to_string())); + } + if let Some(value) = self._definitions_only { + params.push(("definitionsOnly", value.to_string())); + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._ad_id { + params.push(("adId", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "ids", "eventTagTypes", "enabled", "definitionsOnly", "campaignId", "advertiserId", "adId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "eventtag*2015" will return objects with names like "eventtag June 2015", "eventtag April 2015", or simply "eventtag 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "eventtag" will match objects with name "my eventtag", "eventtag 2015", or simply "eventtag". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only event tags with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only event tags with the specified event tag types. Event tag types can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. + /// + /// Append the given value to the *event tag types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_event_tag_types(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._event_tag_types.push(new_value.to_string()); + self + } + /// Select only enabled event tags. What is considered enabled or disabled depends on the definitionsOnly parameter. When definitionsOnly is set to true, only the specified advertiser or campaign's event tags' enabledByDefault field is examined. When definitionsOnly is set to false, the specified ad or specified campaign's parent advertiser's or parent campaign's event tags' enabledByDefault and status fields are examined as well. + /// + /// Sets the *enabled* query property to the given value. + pub fn enabled(mut self, new_value: bool) -> EventTagListCall<'a, C, A> { + self._enabled = Some(new_value); + self + } + /// Examine only the specified campaign or advertiser's event tags for matching selector criteria. When set to false, the parent advertiser and parent campaign of the specified ad or campaign is examined as well. In addition, when set to false, the status field is examined as well, along with the enabledByDefault field. This parameter can not be set to true when adId is specified as ads do not define their own even tags. + /// + /// Sets the *definitions only* query property to the given value. + pub fn definitions_only(mut self, new_value: bool) -> EventTagListCall<'a, C, A> { + self._definitions_only = Some(new_value); + self + } + /// Select only event tags that belong to this campaign. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._campaign_id = Some(new_value.to_string()); + self + } + /// Select only event tags that belong to this advertiser. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only event tags that belong to this ad. + /// + /// Sets the *ad id* query property to the given value. + pub fn ad_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._ad_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) -> EventTagListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagListCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new event tag. +/// +/// A builder for the *insert* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct EventTagInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagInsertCall<'a, C, A> {} + +impl<'a, C, A> EventTagInsertCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagInsertCall<'a, C, A> { + self._profile_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) -> EventTagInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing event tag. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagPatchCall<'a, C, A> {} + +impl<'a, C, A> EventTagPatchCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> EventTagPatchCall<'a, C, A> { + self._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) -> EventTagPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing event tag. +/// +/// A builder for the *update* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct EventTagUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagUpdateCall<'a, C, A> {} + +impl<'a, C, A> EventTagUpdateCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagUpdateCall<'a, C, A> { + self._profile_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) -> EventTagUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one event tag by ID. +/// +/// A builder for the *get* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagGetCall<'a, C, A> {} + +impl<'a, C, A> EventTagGetCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/eventTags/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> EventTagGetCall<'a, C, A> { + self._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) -> EventTagGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagGetCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_lists().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListGetCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._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) -> RemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListGetCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. +/// +/// A builder for the *update* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListUpdateCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListUpdateCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListUpdateCall<'a, C, A> { + self._profile_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) -> RemarketingListUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_lists().list("profileId", "advertiserId") +/// .sort_order("tempor") +/// .sort_field("consetetur") +/// .page_token("eirmod") +/// .name("aliquyam") +/// .max_results(-10) +/// .floodlight_activity_id("aliquyam") +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _name: Option, + _max_results: Option, + _floodlight_activity_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListListCall<'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, RemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._floodlight_activity_id { + params.push(("floodlightActivityId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "floodlightActivityId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only remarketing lists owned by this advertiser. + /// + /// Sets the *advertiser id* 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 advertiser_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> RemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only remarketing lists that have this floodlight activity ID. + /// + /// Sets the *floodlight activity id* query property to the given value. + pub fn floodlight_activity_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._floodlight_activity_id = Some(new_value.to_string()); + self + } + /// Select only active or only inactive remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> RemarketingListListCall<'a, C, A> { + self._active = 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) -> RemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListListCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListPatchCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListPatchCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._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) -> RemarketingListPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new remarketing list. +/// +/// A builder for the *insert* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListInsertCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListInsertCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListInsertCall<'a, C, A> { + self._profile_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) -> RemarketingListInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of cities, possibly filtered. +/// +/// A builder for the *list* method supported by a *city* resource. +/// It is not used directly, but through a `CityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.cities().list("profileId") +/// .add_region_dart_ids("clita") +/// .name_prefix("est") +/// .add_dart_ids("sit") +/// .add_country_dart_ids("ipsum") +/// .doit(); +/// # } +/// ``` +pub struct CityListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _region_dart_ids: Vec, + _name_prefix: Option, + _dart_ids: Vec, + _country_dart_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CityListCall<'a, C, A> {} + +impl<'a, C, A> CityListCall<'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, CitiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.cities.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._region_dart_ids.len() > 0 { + for f in self._region_dart_ids.iter() { + params.push(("regionDartIds", f.to_string())); + } + } + if let Some(value) = self._name_prefix { + params.push(("namePrefix", value.to_string())); + } + if self._dart_ids.len() > 0 { + for f in self._dart_ids.iter() { + params.push(("dartIds", f.to_string())); + } + } + if self._country_dart_ids.len() > 0 { + for f in self._country_dart_ids.iter() { + params.push(("countryDartIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "regionDartIds", "namePrefix", "dartIds", "countryDartIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/cities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only cities from these regions. + /// + /// Append the given value to the *region dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_region_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._region_dart_ids.push(new_value.to_string()); + self + } + /// Select only cities with names starting with this prefix. + /// + /// Sets the *name prefix* query property to the given value. + pub fn name_prefix(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._name_prefix = Some(new_value.to_string()); + self + } + /// Select only cities with these DART IDs. + /// + /// Append the given value to the *dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._dart_ids.push(new_value.to_string()); + self + } + /// Select only cities from these countries. + /// + /// Append the given value to the *country dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_country_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._country_dart_ids.push(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) -> CityListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CityListCall<'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::Dfatrafficking`. + /// + /// 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) -> CityListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement strategy. +/// +/// A builder for the *update* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyUpdateCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + self._profile_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) -> PlacementStrategyUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement strategy by ID. +/// +/// A builder for the *get* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyGetCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._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) -> PlacementStrategyGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placement strategies, possibly filtered. +/// +/// A builder for the *list* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().list("profileId") +/// .sort_order("ea") +/// .sort_field("dolor") +/// .search_string("consetetur") +/// .page_token("sadipscing") +/// .max_results(-49) +/// .add_ids("et") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyListCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyListCall<'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, PlacementStrategiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "placementstrategy*2015" will return objects with names like "placementstrategy June 2015", "placementstrategy April 2015", or simply "placementstrategy 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementstrategy" will match objects with name "my placementstrategy", "placementstrategy 2015", or simply "placementstrategy". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementStrategyListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placement strategies with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._ids.push(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) -> PlacementStrategyListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing placement strategy. +/// +/// A builder for the *delete* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyDeleteCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyDeleteCall<'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: "dfareporting.placementStrategies.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + self._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) -> PlacementStrategyDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement strategy. +/// +/// A builder for the *insert* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyInsertCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyInsertCall<'a, C, A> { + self._profile_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) -> PlacementStrategyInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement strategy. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyPatchCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, C, A> { + self._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) -> PlacementStrategyPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of projects, possibly filtered. +/// +/// A builder for the *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_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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().list("profileId") +/// .sort_order("sit") +/// .sort_field("vero") +/// .search_string("nonumy") +/// .page_token("accusam") +/// .max_results(-6) +/// .add_ids("sit") +/// .add_advertiser_ids("erat") +/// .doit(); +/// # } +/// ``` +pub struct ProjectListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectListCall<'a, C, A> {} + +impl<'a, C, A> ProjectListCall<'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, ProjectsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.projects.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for projects by name or ID. Wildcards (*) are allowed. For example, "project*2015" will return projects with names like "project June 2015", "project April 2015", or simply "project 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "project" will match projects with name "my project", "project 2015", or simply "project". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ProjectListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only projects with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only projects with these advertiser IDs. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._advertiser_ids.push(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) -> ProjectListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectListCall<'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::Dfatrafficking`. + /// + /// 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) -> ProjectListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one project by ID. +/// +/// 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_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ProjectGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: 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: "dfareporting.projects.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._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) -> 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::Dfatrafficking`. + /// + /// 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 + } +} + + +/// Inserts a new directory site. +/// +/// A builder for the *insert* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::DirectorySite; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DirectorySite::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.directory_sites().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DirectorySite, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteInsertCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteInsertCall<'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, DirectorySite)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/directorySites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DirectorySite) -> DirectorySiteInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteInsertCall<'a, C, A> { + self._profile_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) -> DirectorySiteInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of directory sites, possibly filtered. +/// +/// A builder for the *list* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_sites().list("profileId") +/// .sort_order("tempor") +/// .sort_field("ut") +/// .search_string("kasd") +/// .parent_id("diam") +/// .page_token("ut") +/// .max_results(-29) +/// .add_ids("eos") +/// .dfp_network_code("elitr") +/// .country_id("tempor") +/// .active(true) +/// .accepts_publisher_paid_placements(false) +/// .accepts_interstitial_placements(false) +/// .accepts_in_stream_video_placements(false) +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _parent_id: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _dfp_network_code: Option, + _country_id: Option, + _active: Option, + _accepts_publisher_paid_placements: Option, + _accepts_interstitial_placements: Option, + _accepts_in_stream_video_placements: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteListCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteListCall<'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, DirectorySitesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._parent_id { + params.push(("parentId", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._dfp_network_code { + params.push(("dfp_network_code", value.to_string())); + } + if let Some(value) = self._country_id { + params.push(("countryId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + if let Some(value) = self._accepts_publisher_paid_placements { + params.push(("acceptsPublisherPaidPlacements", value.to_string())); + } + if let Some(value) = self._accepts_interstitial_placements { + params.push(("acceptsInterstitialPlacements", value.to_string())); + } + if let Some(value) = self._accepts_in_stream_video_placements { + params.push(("acceptsInStreamVideoPlacements", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "parentId", "pageToken", "maxResults", "ids", "dfp_network_code", "countryId", "active", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/directorySites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or URL. Wildcards (*) are allowed. For example, "directory site*2015" will return objects with names like "directory site June 2015", "directory site April 2015", or simply "directory site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site" will match objects with name "my directory site", "directory site 2015" or simply, "directory site". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only directory sites with this parent ID. + /// + /// Sets the *parent id* query property to the given value. + pub fn parent_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._parent_id = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DirectorySiteListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only directory sites with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only directory sites with this DFP network code. + /// + /// Sets the *dfp_network_code* query property to the given value. + pub fn dfp_network_code(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._dfp_network_code = Some(new_value.to_string()); + self + } + /// Select only directory sites with this country ID. + /// + /// Sets the *country id* query property to the given value. + pub fn country_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._country_id = Some(new_value.to_string()); + self + } + /// Select only active directory sites. Leave blank to retrieve both active and inactive directory sites. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._active = Some(new_value); + self + } + /// Select only directory sites that accept publisher paid placements. This field can be left blank. + /// + /// Sets the *accepts publisher paid placements* query property to the given value. + pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_publisher_paid_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts interstitial placements* query property to the given value. + pub fn accepts_interstitial_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_interstitial_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts in stream video placements* query property to the given value. + pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_in_stream_video_placements = 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) -> DirectorySiteListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteListCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one directory site by ID. +/// +/// A builder for the *get* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_sites().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteGetCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteGetCall<'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, DirectorySite)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/directorySites/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Directory site ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, C, A> { + self._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) -> DirectorySiteGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteGetCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing dynamic targeting key. +/// +/// A builder for the *delete* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.dynamic_targeting_keys().delete("profileId", "objectId", "name", "objectType") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _object_id: String, + _name: String, + _object_type: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyDeleteCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyDeleteCall<'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: "dfareporting.dynamicTargetingKeys.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("objectId", self._object_id.to_string())); + params.push(("name", self._name.to_string())); + params.push(("objectType", self._object_type.to_string())); + for &field in ["profileId", "objectId", "name", "objectType"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/dynamicTargetingKeys/{objectId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{objectId}", "objectId")].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 ["objectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// ID of the object of this dynamic targeting key. This is a required field. + /// + /// Sets the *object 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 object_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._object_id = new_value.to_string(); + self + } + /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + /// + /// Sets the *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 name(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._name = new_value.to_string(); + self + } + /// Type of the object of this dynamic targeting key. This is a required field. + /// + /// Sets the *object type* 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 object_type(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._object_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) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of dynamic targeting keys. +/// +/// A builder for the *list* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.dynamic_targeting_keys().list("profileId") +/// .object_type("clita") +/// .object_id("tempor") +/// .add_names("Stet") +/// .advertiser_id("dolor") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _object_type: Option, + _object_id: Option, + _names: Vec, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyListCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyListCall<'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, DynamicTargetingKeysListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dynamicTargetingKeys.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._object_type { + params.push(("objectType", value.to_string())); + } + if let Some(value) = self._object_id { + params.push(("objectId", value.to_string())); + } + if self._names.len() > 0 { + for f in self._names.iter() { + params.push(("names", f.to_string())); + } + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "objectType", "objectId", "names", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/dynamicTargetingKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only dynamic targeting keys with this object type. + /// + /// Sets the *object type* query property to the given value. + pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._object_type = Some(new_value.to_string()); + self + } + /// Select only dynamic targeting keys with this object ID. + /// + /// Sets the *object id* query property to the given value. + pub fn object_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._object_id = Some(new_value.to_string()); + self + } + /// Select only dynamic targeting keys exactly matching these names. + /// + /// Append the given value to the *names* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_names(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._names.push(new_value.to_string()); + self + } + /// Select only dynamic targeting keys whose object has this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._advertiser_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) -> DynamicTargetingKeyListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyListCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement. +/// +/// A builder for the *insert* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::DynamicTargetingKey; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DynamicTargetingKey::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.dynamic_targeting_keys().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DynamicTargetingKey, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyInsertCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyInsertCall<'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, DynamicTargetingKey)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dynamicTargetingKeys.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/dynamicTargetingKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DynamicTargetingKey) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._profile_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) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new size. +/// +/// A builder for the *insert* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Size; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Size::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.sizes().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SizeInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Size, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeInsertCall<'a, C, A> {} + +impl<'a, C, A> SizeInsertCall<'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, Size)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sizes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Size) -> SizeInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeInsertCall<'a, C, A> { + self._profile_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) -> SizeInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of sizes, possibly filtered. +/// +/// A builder for the *list* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sizes().list("profileId") +/// .width(-68) +/// .add_ids("amet.") +/// .iab_standard(true) +/// .height(-2) +/// .doit(); +/// # } +/// ``` +pub struct SizeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _width: Option, + _ids: Vec, + _iab_standard: Option, + _height: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeListCall<'a, C, A> {} + +impl<'a, C, A> SizeListCall<'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, SizesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._width { + params.push(("width", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._iab_standard { + params.push(("iabStandard", value.to_string())); + } + if let Some(value) = self._height { + params.push(("height", value.to_string())); + } + for &field in ["alt", "profileId", "width", "ids", "iabStandard", "height"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sizes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only sizes with this width. + /// + /// Sets the *width* query property to the given value. + pub fn width(mut self, new_value: i32) -> SizeListCall<'a, C, A> { + self._width = Some(new_value); + self + } + /// Select only sizes with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SizeListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only IAB standard sizes. + /// + /// Sets the *iab standard* query property to the given value. + pub fn iab_standard(mut self, new_value: bool) -> SizeListCall<'a, C, A> { + self._iab_standard = Some(new_value); + self + } + /// Select only sizes with this height. + /// + /// Sets the *height* query property to the given value. + pub fn height(mut self, new_value: i32) -> SizeListCall<'a, C, A> { + self._height = 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) -> SizeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeListCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one size by ID. +/// +/// A builder for the *get* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sizes().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SizeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeGetCall<'a, C, A> {} + +impl<'a, C, A> SizeGetCall<'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, Size)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/sizes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Size ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SizeGetCall<'a, C, A> { + self._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) -> SizeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the account's active ad summary by account ID. +/// +/// A builder for the *get* method supported by a *accountActiveAdSummary* resource. +/// It is not used directly, but through a `AccountActiveAdSummaryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_active_ad_summaries().get("profileId", "summaryAccountId") +/// .doit(); +/// # } +/// ``` +pub struct AccountActiveAdSummaryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _summary_account_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountActiveAdSummaryGetCall<'a, C, A> {} + +impl<'a, C, A> AccountActiveAdSummaryGetCall<'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, AccountActiveAdSummary)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountActiveAdSummaries.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("summaryAccountId", self._summary_account_id.to_string())); + for &field in ["alt", "profileId", "summaryAccountId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{summaryAccountId}", "summaryAccountId")].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 ["summaryAccountId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *summary account 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 summary_account_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._summary_account_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) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountActiveAdSummaryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountActiveAdSummaryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account user profile. +/// +/// A builder for the *update* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileUpdateCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileUpdateCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfileUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileUpdateCall<'a, C, A> { + self._profile_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) -> AccountUserProfileUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of account user profiles, possibly filtered. +/// +/// A builder for the *list* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_user_profiles().list("profileId") +/// .user_role_id("accusam") +/// .subaccount_id("accusam") +/// .sort_order("invidunt") +/// .sort_field("eirmod") +/// .search_string("sit") +/// .page_token("elitr") +/// .max_results(-46) +/// .add_ids("ut") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _user_role_id: Option, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileListCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileListCall<'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, AccountUserProfilesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._user_role_id { + params.push(("userRoleId", value.to_string())); + } + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "userRoleId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user profiles with the specified user role ID. + /// + /// Sets the *user role id* query property to the given value. + pub fn user_role_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._user_role_id = Some(new_value.to_string()); + self + } + /// Select only user profiles with the specified subaccount ID. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "user profile*2015" will return objects with names like "user profile June 2015", "user profile April 2015", or simply "user profile 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "user profile" will match objects with name "my user profile", "user profile 2015", or simply "user profile". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AccountUserProfileListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only user profiles with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only active user profiles. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AccountUserProfileListCall<'a, C, A> { + self._active = 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) -> AccountUserProfileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new account user profile. +/// +/// A builder for the *insert* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileInsertCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileInsertCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfileInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileInsertCall<'a, C, A> { + self._profile_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) -> AccountUserProfileInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account user profile. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfilePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfilePatchCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfilePatchCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfilePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User profile ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, C, A> { + self._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) -> AccountUserProfilePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfilePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfilePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account user profile by ID. +/// +/// A builder for the *get* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_user_profiles().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileGetCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileGetCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accountUserProfiles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User profile ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, C, A> { + self._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) -> AccountUserProfileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of countries. +/// +/// A builder for the *list* method supported by a *country* resource. +/// It is not used directly, but through a `CountryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.countries().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct CountryListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CountryListCall<'a, C, A> {} + +impl<'a, C, A> CountryListCall<'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, CountriesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.countries.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/countries".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CountryListCall<'a, C, A> { + self._profile_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) -> CountryListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CountryListCall<'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::Dfatrafficking`. + /// + /// 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) -> CountryListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one country by ID. +/// +/// A builder for the *get* method supported by a *country* resource. +/// It is not used directly, but through a `CountryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.countries().get("profileId", "dartId") +/// .doit(); +/// # } +/// ``` +pub struct CountryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _dart_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CountryGetCall<'a, C, A> {} + +impl<'a, C, A> CountryGetCall<'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, Country)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.countries.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("dartId", self._dart_id.to_string())); + for &field in ["alt", "profileId", "dartId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/countries/{dartId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].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 ["dartId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CountryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Country DART ID. + /// + /// Sets the *dart 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 dart_id(mut self, new_value: &str) -> CountryGetCall<'a, C, A> { + self._dart_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) -> CountryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CountryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CountryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one order document by ID. +/// +/// A builder for the *get* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.order_documents().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OrderDocumentGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderDocumentGetCall<'a, C, A> {} + +impl<'a, C, A> OrderDocumentGetCall<'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, OrderDocument)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/orderDocuments/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> OrderDocumentGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order document ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { + self._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) -> OrderDocumentGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderDocumentGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderDocumentGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of order documents, possibly filtered. +/// +/// A builder for the *list* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.order_documents().list("profileId", "projectId") +/// .sort_order("clita") +/// .sort_field("Stet") +/// .add_site_id("ut") +/// .search_string("et") +/// .page_token("tempor") +/// .add_order_id("sed") +/// .max_results(-78) +/// .add_ids("At") +/// .approved(true) +/// .doit(); +/// # } +/// ``` +pub struct OrderDocumentListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _search_string: Option, + _page_token: Option, + _order_id: Vec, + _max_results: Option, + _ids: Vec, + _approved: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderDocumentListCall<'a, C, A> {} + +impl<'a, C, A> OrderDocumentListCall<'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, OrderDocumentsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if self._order_id.len() > 0 { + for f in self._order_id.iter() { + params.push(("orderId", f.to_string())); + } + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "orderId", "maxResults", "ids", "approved"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/projects/{projectId}/orderDocuments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> OrderDocumentListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only order documents that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for order documents by name or ID. Wildcards (*) are allowed. For example, "orderdocument*2015" will return order documents with names like "orderdocument June 2015", "orderdocument April 2015", or simply "orderdocument 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "orderdocument" will match order documents with name "my orderdocument", "orderdocument 2015", or simply "orderdocument". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only order documents for specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> OrderDocumentListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only order documents with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only order documents that have been approved by at least one user. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> OrderDocumentListCall<'a, C, A> { + self._approved = 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) -> OrderDocumentListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderDocumentListCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderDocumentListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one postal code by ID. +/// +/// A builder for the *get* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.postal_codes().get("profileId", "code") +/// .doit(); +/// # } +/// ``` +pub struct PostalCodeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _code: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PostalCodeGetCall<'a, C, A> {} + +impl<'a, C, A> PostalCodeGetCall<'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, PostalCode)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("code", self._code.to_string())); + for &field in ["alt", "profileId", "code"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/postalCodes/{code}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{code}", "code")].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 ["code", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Postal code ID. + /// + /// Sets the *code* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn code(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { + self._code = 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) -> PostalCodeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PostalCodeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PostalCodeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of postal codes. +/// +/// A builder for the *list* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.postal_codes().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct PostalCodeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PostalCodeListCall<'a, C, A> {} + +impl<'a, C, A> PostalCodeListCall<'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, PostalCodesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/postalCodes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PostalCodeListCall<'a, C, A> { + self._profile_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) -> PostalCodeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PostalCodeListCall<'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::Dfatrafficking`. + /// + /// 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) -> PostalCodeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of browsers. +/// +/// A builder for the *list* method supported by a *browser* resource. +/// It is not used directly, but through a `BrowserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.browsers().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct BrowserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for BrowserListCall<'a, C, A> {} + +impl<'a, C, A> BrowserListCall<'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, BrowsersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.browsers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/browsers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> BrowserListCall<'a, C, A> { + self._profile_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) -> BrowserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> BrowserListCall<'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::Dfatrafficking`. + /// + /// 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) -> BrowserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account by ID. +/// +/// A builder for the *get* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.accounts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} + +impl<'a, C, A> AccountGetCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accounts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._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) -> AccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of accounts, possibly filtered. +/// +/// A builder for the *list* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.accounts().list("profileId") +/// .sort_order("amet") +/// .sort_field("invidunt") +/// .search_string("dolore") +/// .page_token("dolor") +/// .max_results(-49) +/// .add_ids("et") +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct AccountListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountListCall<'a, C, A> {} + +impl<'a, C, A> AccountListCall<'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, AccountsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "account*2015" will return objects with names like "account June 2015", "account April 2015", or simply "account 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "account" will match objects with name "my account", "account 2015", or simply "account". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only accounts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only active accounts. Don't set this field to select both active and non-active accounts. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AccountListCall<'a, C, A> { + self._active = 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) -> AccountListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. +/// +/// A builder for the *update* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Account::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.accounts().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Account, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} + +impl<'a, C, A> AccountUpdateCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { + self._profile_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) -> AccountUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Account::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.accounts().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Account, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPatchCall<'a, C, A> {} + +impl<'a, C, A> AccountPatchCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Account) -> AccountPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._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) -> AccountPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementPatchCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementPatchCall<'a, C, A> { + self._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) -> PlacementPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placements, possibly filtered. +/// +/// A builder for the *list* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().list("profileId") +/// .sort_order("amet.") +/// .sort_field("sed") +/// .add_size_ids("sea") +/// .add_site_ids("consetetur") +/// .search_string("sea") +/// .add_pricing_types("voluptua.") +/// .add_placement_strategy_ids("At") +/// .payment_source("sanctus") +/// .page_token("sit") +/// .min_start_date("sit") +/// .min_end_date("magna") +/// .max_start_date("amet.") +/// .max_results(-13) +/// .max_end_date("Stet") +/// .add_ids("sed") +/// .add_group_ids("eirmod") +/// .add_directory_site_ids("elitr") +/// .add_content_category_ids("gubergren") +/// .add_compatibilities("sit") +/// .add_campaign_ids("et") +/// .archived(false) +/// .add_advertiser_ids("justo") +/// .doit(); +/// # } +/// ``` +pub struct PlacementListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _site_ids: Vec, + _search_string: Option, + _pricing_types: Vec, + _placement_strategy_ids: Vec, + _payment_source: Option, + _page_token: Option, + _min_start_date: Option, + _min_end_date: Option, + _max_start_date: Option, + _max_results: Option, + _max_end_date: Option, + _ids: Vec, + _group_ids: Vec, + _directory_site_ids: Vec, + _content_category_ids: Vec, + _compatibilities: Vec, + _campaign_ids: Vec, + _archived: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementListCall<'a, C, A> {} + +impl<'a, C, A> PlacementListCall<'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, PlacementsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((25 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if self._site_ids.len() > 0 { + for f in self._site_ids.iter() { + params.push(("siteIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._pricing_types.len() > 0 { + for f in self._pricing_types.iter() { + params.push(("pricingTypes", f.to_string())); + } + } + if self._placement_strategy_ids.len() > 0 { + for f in self._placement_strategy_ids.iter() { + params.push(("placementStrategyIds", f.to_string())); + } + } + if let Some(value) = self._payment_source { + params.push(("paymentSource", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._min_start_date { + params.push(("minStartDate", value.to_string())); + } + if let Some(value) = self._min_end_date { + params.push(("minEndDate", value.to_string())); + } + if let Some(value) = self._max_start_date { + params.push(("maxStartDate", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_end_date { + params.push(("maxEndDate", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._group_ids.len() > 0 { + for f in self._group_ids.iter() { + params.push(("groupIds", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._content_category_ids.len() > 0 { + for f in self._content_category_ids.iter() { + params.push(("contentCategoryIds", f.to_string())); + } + } + if self._compatibilities.len() > 0 { + for f in self._compatibilities.iter() { + params.push(("compatibilities", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "sizeIds", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "paymentSource", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "groupIds", "directorySiteIds", "contentCategoryIds", "compatibilities", "campaignIds", "archived", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only placements that are associated with these sizes. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these sites. + /// + /// Append the given value to the *site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._site_ids.push(new_value.to_string()); + self + } + /// Allows searching for placements by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placements with names like "placement June 2015", "placement May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placement" will match placements with name "my placement", "placement 2015", or simply "placement". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only placements with these pricing types. + /// + /// Append the given value to the *pricing types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_pricing_types(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._pricing_types.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these placement strategies. + /// + /// Append the given value to the *placement strategy ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._placement_strategy_ids.push(new_value.to_string()); + self + } + /// Select only placements with this payment source. + /// + /// Sets the *payment source* query property to the given value. + pub fn payment_source(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._payment_source = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min start date* query property to the given value. + pub fn min_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._min_start_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min end date* query property to the given value. + pub fn min_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._min_end_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max start date* query property to the given value. + pub fn max_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._max_start_date = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max end date* query property to the given value. + pub fn max_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._max_end_date = Some(new_value.to_string()); + self + } + /// Select only placements with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only placements that belong to these placement groups. + /// + /// Append the given value to the *group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_group_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._group_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these directory sites. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these content categories. + /// + /// Append the given value to the *content category ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._content_category_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these compatibilities. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. + /// + /// Append the given value to the *compatibilities* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_compatibilities(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._compatibilities.push(new_value.to_string()); + self + } + /// Select only placements that belong to these campaigns. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only archived placements. Don't set this field to select both archived and non-archived placements. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> PlacementListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only placements that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._advertiser_ids.push(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) -> PlacementListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement. +/// +/// A builder for the *insert* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementInsertCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementInsertCall<'a, C, A> { + self._profile_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) -> PlacementInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement. +/// +/// A builder for the *update* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// use dfareporting2d5::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementUpdateCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementUpdateCall<'a, C, A> { + self._profile_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) -> PlacementUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates tags for a placement. +/// +/// A builder for the *generatetags* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().generatetags("profileId") +/// .add_tag_formats("tempor") +/// .add_placement_ids("ipsum") +/// .campaign_id("est") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGeneratetagCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _tag_formats: Vec, + _placement_ids: Vec, + _campaign_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGeneratetagCall<'a, C, A> {} + +impl<'a, C, A> PlacementGeneratetagCall<'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, PlacementsGenerateTagsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.generatetags", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._tag_formats.len() > 0 { + for f in self._tag_formats.iter() { + params.push(("tagFormats", f.to_string())); + } + } + if self._placement_ids.len() > 0 { + for f in self._placement_ids.iter() { + params.push(("placementIds", f.to_string())); + } + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + for &field in ["alt", "profileId", "tagFormats", "placementIds", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements/generatetags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Tag formats to generate for these placements. + /// + /// Append the given value to the *tag formats* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_tag_formats(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._tag_formats.push(new_value.to_string()); + self + } + /// Generate tags for these placements. + /// + /// Append the given value to the *placement ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_ids(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._placement_ids.push(new_value.to_string()); + self + } + /// Generate placements belonging to this campaign. This is a required field. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._campaign_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) -> PlacementGeneratetagCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGeneratetagCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGeneratetagCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement by ID. +/// +/// A builder for the *get* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d5 as dfareporting2d5; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d5::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementGetCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.5/userprofiles/{profileId}/placements/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._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) -> PlacementGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/dfareporting2d6-cli/Cargo.toml b/gen/dfareporting2d6-cli/Cargo.toml new file mode 100644 index 0000000000..56dae639a1 --- /dev/null +++ b/gen/dfareporting2d6-cli/Cargo.toml @@ -0,0 +1,42 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-dfareporting2d6-cli" +version = "0.3.6+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" +homepage = "https://developers.google.com/doubleclick-advertisers/" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli" +license = "MIT" +keywords = ["dfareporting", "google", "cli"] + +[[bin]] +name = "dfareporting2d6" + +[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.4" +yup-hyper-mock = "^1.0" +clap = "^2.0" + +[features] +default = ["with-serde-codegen"] +nightly = ["serde_macros","yup-oauth2/nightly","google-dfareporting2d6/nightly"] +with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dfareporting2d6/with-serde-codegen"] + +[build-dependencies] +serde_codegen = { version = "^ 0.8", optional = true } + + +[dependencies.google-dfareporting2d6] +path = "../dfareporting2d6" +optional = true +default-features = false diff --git a/gen/dfareporting2d6-cli/LICENSE.md b/gen/dfareporting2d6-cli/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/dfareporting2d6-cli/LICENSE.md @@ -0,0 +1,30 @@ + +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/dfareporting2d6-cli/README.md b/gen/dfareporting2d6-cli/README.md new file mode 100644 index 0000000000..b21cd21668 --- /dev/null +++ b/gen/dfareporting2d6-cli/README.md @@ -0,0 +1,372 @@ + +The `dfareporting2d6` command-line interface *(CLI)* allows to use most features of the *Google dfareporting* 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 *dfareporting* API can be found at the +[official documentation site](https://developers.google.com/doubleclick-advertisers/). + +# 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/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) + +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*. + +```bash +dfareporting2d6 [options] + account-active-ad-summaries + get [-p ]... [-o ] + account-permission-groups + get [-p ]... [-o ] + list [-p ]... [-o ] + account-permissions + get [-p ]... [-o ] + list [-p ]... [-o ] + account-user-profiles + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + accounts + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + ads + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + advertiser-groups + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + advertisers + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + browsers + list [-p ]... [-o ] + campaign-creative-associations + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + campaigns + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + change-logs + get [-p ]... [-o ] + list [-p ]... [-o ] + cities + list [-p ]... [-o ] + connection-types + get [-p ]... [-o ] + list [-p ]... [-o ] + content-categories + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + conversions + batchinsert (-r )... [-p ]... [-o ] + countries + get [-p ]... [-o ] + list [-p ]... [-o ] + creative-assets + insert (-r )... (-u (simple|resumable) -f [-m ]) [-p ]... [-o ] + creative-field-values + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creative-fields + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creative-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + creatives + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + dimension-values + query (-r )... [-p ]... [-o ] + directory-site-contacts + get [-p ]... [-o ] + list [-p ]... [-o ] + directory-sites + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + dynamic-targeting-keys + delete [-p ]... + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + event-tags + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + files + get [-p ]... [-o ] + list [-p ]... [-o ] + floodlight-activities + delete [-p ]... + generatetag [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + floodlight-activity-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + floodlight-configurations + get [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + inventory-items + get [-p ]... [-o ] + list [-p ]... [-o ] + landing-pages + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + languages + list [-p ]... [-o ] + metros + list [-p ]... [-o ] + mobile-carriers + get [-p ]... [-o ] + list [-p ]... [-o ] + operating-system-versions + get [-p ]... [-o ] + list [-p ]... [-o ] + operating-systems + get [-p ]... [-o ] + list [-p ]... [-o ] + order-documents + get [-p ]... [-o ] + list [-p ]... [-o ] + orders + get [-p ]... [-o ] + list [-p ]... [-o ] + placement-groups + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + placement-strategies + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + placements + generatetags [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + platform-types + get [-p ]... [-o ] + list [-p ]... [-o ] + postal-codes + get [-p ]... [-o ] + list [-p ]... [-o ] + projects + get [-p ]... [-o ] + list [-p ]... [-o ] + regions + list [-p ]... [-o ] + remarketing-list-shares + get [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + remarketing-lists + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + reports + compatible-fields-query (-r )... [-p ]... [-o ] + delete [-p ]... + files-get [-p ]... [-o ] + files-list [-p ]... [-o ] + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + run [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + sites + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + sizes + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + subaccounts + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + targetable-remarketing-lists + get [-p ]... [-o ] + list [-p ]... [-o ] + targeting-templates + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + user-profiles + get [-p ]... [-o ] + list [-p ]... [-o ] + user-role-permission-groups + get [-p ]... [-o ] + list [-p ]... [-o ] + user-role-permissions + get [-p ]... [-o ] + list [-p ]... [-o ] + user-roles + delete [-p ]... + get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] + list [-p ]... [-o ] + patch (-r )... [-p ]... [-o ] + update (-r )... [-p ]... [-o ] + dfareporting2d6 --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 `dfareporting2d6-`. 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/dfareporting2d6-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/dfareporting2d6-secret.json`, assuming that the required *dfareporting* 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. `dfareporting2d6 --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/dfareporting2d6-cli/mkdocs.yml b/gen/dfareporting2d6-cli/mkdocs.yml new file mode 100644 index 0000000000..893f0c8c27 --- /dev/null +++ b/gen/dfareporting2d6-cli/mkdocs.yml @@ -0,0 +1,218 @@ +site_name: dfareporting v0.3.6+20160803 +site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d6-cli +site_description: Write integrating applications with bcore + +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d6-cli + +docs_dir: docs +site_dir: build_html + +pages: +- ['index.md', 'Home'] +- ['account-active-ad-summaries_get.md', 'Account Active Ad Summaries', 'Get'] +- ['account-permission-groups_get.md', 'Account Permission Groups', 'Get'] +- ['account-permission-groups_list.md', 'Account Permission Groups', 'List'] +- ['account-permissions_get.md', 'Account Permissions', 'Get'] +- ['account-permissions_list.md', 'Account Permissions', 'List'] +- ['account-user-profiles_get.md', 'Account User Profiles', 'Get'] +- ['account-user-profiles_insert.md', 'Account User Profiles', 'Insert'] +- ['account-user-profiles_list.md', 'Account User Profiles', 'List'] +- ['account-user-profiles_patch.md', 'Account User Profiles', 'Patch'] +- ['account-user-profiles_update.md', 'Account User Profiles', 'Update'] +- ['accounts_get.md', 'Accounts', 'Get'] +- ['accounts_list.md', 'Accounts', 'List'] +- ['accounts_patch.md', 'Accounts', 'Patch'] +- ['accounts_update.md', 'Accounts', 'Update'] +- ['ads_get.md', 'Ads', 'Get'] +- ['ads_insert.md', 'Ads', 'Insert'] +- ['ads_list.md', 'Ads', 'List'] +- ['ads_patch.md', 'Ads', 'Patch'] +- ['ads_update.md', 'Ads', 'Update'] +- ['advertiser-groups_delete.md', 'Advertiser Groups', 'Delete'] +- ['advertiser-groups_get.md', 'Advertiser Groups', 'Get'] +- ['advertiser-groups_insert.md', 'Advertiser Groups', 'Insert'] +- ['advertiser-groups_list.md', 'Advertiser Groups', 'List'] +- ['advertiser-groups_patch.md', 'Advertiser Groups', 'Patch'] +- ['advertiser-groups_update.md', 'Advertiser Groups', 'Update'] +- ['advertisers_get.md', 'Advertisers', 'Get'] +- ['advertisers_insert.md', 'Advertisers', 'Insert'] +- ['advertisers_list.md', 'Advertisers', 'List'] +- ['advertisers_patch.md', 'Advertisers', 'Patch'] +- ['advertisers_update.md', 'Advertisers', 'Update'] +- ['browsers_list.md', 'Browsers', 'List'] +- ['campaign-creative-associations_insert.md', 'Campaign Creative Associations', 'Insert'] +- ['campaign-creative-associations_list.md', 'Campaign Creative Associations', 'List'] +- ['campaigns_get.md', 'Campaigns', 'Get'] +- ['campaigns_insert.md', 'Campaigns', 'Insert'] +- ['campaigns_list.md', 'Campaigns', 'List'] +- ['campaigns_patch.md', 'Campaigns', 'Patch'] +- ['campaigns_update.md', 'Campaigns', 'Update'] +- ['change-logs_get.md', 'Change Logs', 'Get'] +- ['change-logs_list.md', 'Change Logs', 'List'] +- ['cities_list.md', 'Cities', 'List'] +- ['connection-types_get.md', 'Connection Types', 'Get'] +- ['connection-types_list.md', 'Connection Types', 'List'] +- ['content-categories_delete.md', 'Content Categories', 'Delete'] +- ['content-categories_get.md', 'Content Categories', 'Get'] +- ['content-categories_insert.md', 'Content Categories', 'Insert'] +- ['content-categories_list.md', 'Content Categories', 'List'] +- ['content-categories_patch.md', 'Content Categories', 'Patch'] +- ['content-categories_update.md', 'Content Categories', 'Update'] +- ['conversions_batchinsert.md', 'Conversions', 'Batchinsert'] +- ['countries_get.md', 'Countries', 'Get'] +- ['countries_list.md', 'Countries', 'List'] +- ['creative-assets_insert.md', 'Creative Assets', 'Insert'] +- ['creative-field-values_delete.md', 'Creative Field Values', 'Delete'] +- ['creative-field-values_get.md', 'Creative Field Values', 'Get'] +- ['creative-field-values_insert.md', 'Creative Field Values', 'Insert'] +- ['creative-field-values_list.md', 'Creative Field Values', 'List'] +- ['creative-field-values_patch.md', 'Creative Field Values', 'Patch'] +- ['creative-field-values_update.md', 'Creative Field Values', 'Update'] +- ['creative-fields_delete.md', 'Creative Fields', 'Delete'] +- ['creative-fields_get.md', 'Creative Fields', 'Get'] +- ['creative-fields_insert.md', 'Creative Fields', 'Insert'] +- ['creative-fields_list.md', 'Creative Fields', 'List'] +- ['creative-fields_patch.md', 'Creative Fields', 'Patch'] +- ['creative-fields_update.md', 'Creative Fields', 'Update'] +- ['creative-groups_get.md', 'Creative Groups', 'Get'] +- ['creative-groups_insert.md', 'Creative Groups', 'Insert'] +- ['creative-groups_list.md', 'Creative Groups', 'List'] +- ['creative-groups_patch.md', 'Creative Groups', 'Patch'] +- ['creative-groups_update.md', 'Creative Groups', 'Update'] +- ['creatives_get.md', 'Creatives', 'Get'] +- ['creatives_insert.md', 'Creatives', 'Insert'] +- ['creatives_list.md', 'Creatives', 'List'] +- ['creatives_patch.md', 'Creatives', 'Patch'] +- ['creatives_update.md', 'Creatives', 'Update'] +- ['dimension-values_query.md', 'Dimension Values', 'Query'] +- ['directory-site-contacts_get.md', 'Directory Site Contacts', 'Get'] +- ['directory-site-contacts_list.md', 'Directory Site Contacts', 'List'] +- ['directory-sites_get.md', 'Directory Sites', 'Get'] +- ['directory-sites_insert.md', 'Directory Sites', 'Insert'] +- ['directory-sites_list.md', 'Directory Sites', 'List'] +- ['dynamic-targeting-keys_delete.md', 'Dynamic Targeting Keys', 'Delete'] +- ['dynamic-targeting-keys_insert.md', 'Dynamic Targeting Keys', 'Insert'] +- ['dynamic-targeting-keys_list.md', 'Dynamic Targeting Keys', 'List'] +- ['event-tags_delete.md', 'Event Tags', 'Delete'] +- ['event-tags_get.md', 'Event Tags', 'Get'] +- ['event-tags_insert.md', 'Event Tags', 'Insert'] +- ['event-tags_list.md', 'Event Tags', 'List'] +- ['event-tags_patch.md', 'Event Tags', 'Patch'] +- ['event-tags_update.md', 'Event Tags', 'Update'] +- ['files_get.md', 'Files', 'Get'] +- ['files_list.md', 'Files', 'List'] +- ['floodlight-activities_delete.md', 'Floodlight Activities', 'Delete'] +- ['floodlight-activities_generatetag.md', 'Floodlight Activities', 'Generatetag'] +- ['floodlight-activities_get.md', 'Floodlight Activities', 'Get'] +- ['floodlight-activities_insert.md', 'Floodlight Activities', 'Insert'] +- ['floodlight-activities_list.md', 'Floodlight Activities', 'List'] +- ['floodlight-activities_patch.md', 'Floodlight Activities', 'Patch'] +- ['floodlight-activities_update.md', 'Floodlight Activities', 'Update'] +- ['floodlight-activity-groups_get.md', 'Floodlight Activity Groups', 'Get'] +- ['floodlight-activity-groups_insert.md', 'Floodlight Activity Groups', 'Insert'] +- ['floodlight-activity-groups_list.md', 'Floodlight Activity Groups', 'List'] +- ['floodlight-activity-groups_patch.md', 'Floodlight Activity Groups', 'Patch'] +- ['floodlight-activity-groups_update.md', 'Floodlight Activity Groups', 'Update'] +- ['floodlight-configurations_get.md', 'Floodlight Configurations', 'Get'] +- ['floodlight-configurations_list.md', 'Floodlight Configurations', 'List'] +- ['floodlight-configurations_patch.md', 'Floodlight Configurations', 'Patch'] +- ['floodlight-configurations_update.md', 'Floodlight Configurations', 'Update'] +- ['inventory-items_get.md', 'Inventory Items', 'Get'] +- ['inventory-items_list.md', 'Inventory Items', 'List'] +- ['landing-pages_delete.md', 'Landing Pages', 'Delete'] +- ['landing-pages_get.md', 'Landing Pages', 'Get'] +- ['landing-pages_insert.md', 'Landing Pages', 'Insert'] +- ['landing-pages_list.md', 'Landing Pages', 'List'] +- ['landing-pages_patch.md', 'Landing Pages', 'Patch'] +- ['landing-pages_update.md', 'Landing Pages', 'Update'] +- ['languages_list.md', 'Languages', 'List'] +- ['metros_list.md', 'Metros', 'List'] +- ['mobile-carriers_get.md', 'Mobile Carriers', 'Get'] +- ['mobile-carriers_list.md', 'Mobile Carriers', 'List'] +- ['operating-system-versions_get.md', 'Operating System Versions', 'Get'] +- ['operating-system-versions_list.md', 'Operating System Versions', 'List'] +- ['operating-systems_get.md', 'Operating Systems', 'Get'] +- ['operating-systems_list.md', 'Operating Systems', 'List'] +- ['order-documents_get.md', 'Order Documents', 'Get'] +- ['order-documents_list.md', 'Order Documents', 'List'] +- ['orders_get.md', 'Orders', 'Get'] +- ['orders_list.md', 'Orders', 'List'] +- ['placement-groups_get.md', 'Placement Groups', 'Get'] +- ['placement-groups_insert.md', 'Placement Groups', 'Insert'] +- ['placement-groups_list.md', 'Placement Groups', 'List'] +- ['placement-groups_patch.md', 'Placement Groups', 'Patch'] +- ['placement-groups_update.md', 'Placement Groups', 'Update'] +- ['placement-strategies_delete.md', 'Placement Strategies', 'Delete'] +- ['placement-strategies_get.md', 'Placement Strategies', 'Get'] +- ['placement-strategies_insert.md', 'Placement Strategies', 'Insert'] +- ['placement-strategies_list.md', 'Placement Strategies', 'List'] +- ['placement-strategies_patch.md', 'Placement Strategies', 'Patch'] +- ['placement-strategies_update.md', 'Placement Strategies', 'Update'] +- ['placements_generatetags.md', 'Placements', 'Generatetags'] +- ['placements_get.md', 'Placements', 'Get'] +- ['placements_insert.md', 'Placements', 'Insert'] +- ['placements_list.md', 'Placements', 'List'] +- ['placements_patch.md', 'Placements', 'Patch'] +- ['placements_update.md', 'Placements', 'Update'] +- ['platform-types_get.md', 'Platform Types', 'Get'] +- ['platform-types_list.md', 'Platform Types', 'List'] +- ['postal-codes_get.md', 'Postal Codes', 'Get'] +- ['postal-codes_list.md', 'Postal Codes', 'List'] +- ['projects_get.md', 'Projects', 'Get'] +- ['projects_list.md', 'Projects', 'List'] +- ['regions_list.md', 'Regions', 'List'] +- ['remarketing-list-shares_get.md', 'Remarketing List Shares', 'Get'] +- ['remarketing-list-shares_patch.md', 'Remarketing List Shares', 'Patch'] +- ['remarketing-list-shares_update.md', 'Remarketing List Shares', 'Update'] +- ['remarketing-lists_get.md', 'Remarketing Lists', 'Get'] +- ['remarketing-lists_insert.md', 'Remarketing Lists', 'Insert'] +- ['remarketing-lists_list.md', 'Remarketing Lists', 'List'] +- ['remarketing-lists_patch.md', 'Remarketing Lists', 'Patch'] +- ['remarketing-lists_update.md', 'Remarketing Lists', 'Update'] +- ['reports_compatible-fields-query.md', 'Reports', 'Compatible Fields Query'] +- ['reports_delete.md', 'Reports', 'Delete'] +- ['reports_files-get.md', 'Reports', 'Files Get'] +- ['reports_files-list.md', 'Reports', 'Files List'] +- ['reports_get.md', 'Reports', 'Get'] +- ['reports_insert.md', 'Reports', 'Insert'] +- ['reports_list.md', 'Reports', 'List'] +- ['reports_patch.md', 'Reports', 'Patch'] +- ['reports_run.md', 'Reports', 'Run'] +- ['reports_update.md', 'Reports', 'Update'] +- ['sites_get.md', 'Sites', 'Get'] +- ['sites_insert.md', 'Sites', 'Insert'] +- ['sites_list.md', 'Sites', 'List'] +- ['sites_patch.md', 'Sites', 'Patch'] +- ['sites_update.md', 'Sites', 'Update'] +- ['sizes_get.md', 'Sizes', 'Get'] +- ['sizes_insert.md', 'Sizes', 'Insert'] +- ['sizes_list.md', 'Sizes', 'List'] +- ['subaccounts_get.md', 'Subaccounts', 'Get'] +- ['subaccounts_insert.md', 'Subaccounts', 'Insert'] +- ['subaccounts_list.md', 'Subaccounts', 'List'] +- ['subaccounts_patch.md', 'Subaccounts', 'Patch'] +- ['subaccounts_update.md', 'Subaccounts', 'Update'] +- ['targetable-remarketing-lists_get.md', 'Targetable Remarketing Lists', 'Get'] +- ['targetable-remarketing-lists_list.md', 'Targetable Remarketing Lists', 'List'] +- ['targeting-templates_get.md', 'Targeting Templates', 'Get'] +- ['targeting-templates_insert.md', 'Targeting Templates', 'Insert'] +- ['targeting-templates_list.md', 'Targeting Templates', 'List'] +- ['targeting-templates_patch.md', 'Targeting Templates', 'Patch'] +- ['targeting-templates_update.md', 'Targeting Templates', 'Update'] +- ['user-profiles_get.md', 'User Profiles', 'Get'] +- ['user-profiles_list.md', 'User Profiles', 'List'] +- ['user-role-permission-groups_get.md', 'User Role Permission Groups', 'Get'] +- ['user-role-permission-groups_list.md', 'User Role Permission Groups', 'List'] +- ['user-role-permissions_get.md', 'User Role Permissions', 'Get'] +- ['user-role-permissions_list.md', 'User Role Permissions', 'List'] +- ['user-roles_delete.md', 'User Roles', 'Delete'] +- ['user-roles_get.md', 'User Roles', 'Get'] +- ['user-roles_insert.md', 'User Roles', 'Insert'] +- ['user-roles_list.md', 'User Roles', 'List'] +- ['user-roles_patch.md', 'User Roles', 'Patch'] +- ['user-roles_update.md', 'User Roles', 'Update'] + +theme: readthedocs + +copyright: Copyright © 2015-2016, `Sebastian Thiel` + diff --git a/gen/dfareporting2d6-cli/src/cmn.rs b/gen/dfareporting2d6-cli/src/cmn.rs new file mode 100644 index 0000000000..779c1dc086 --- /dev/null +++ b/gen/dfareporting2d6-cli/src/cmn.rs @@ -0,0 +1,721 @@ +// 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/dfareporting2d6-cli/src/main.rs b/gen/dfareporting2d6-cli/src/main.rs new file mode 100644 index 0000000000..743146980b --- /dev/null +++ b/gen/dfareporting2d6-cli/src/main.rs @@ -0,0 +1,23510 @@ +// 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_dfareporting2d6 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::Dfareporting>, + gp: Vec<&'static str>, + gpm: Vec<(&'static str, &'static str)>, +} + + +impl<'n> Engine<'n> { + fn _account_active_ad_summaries_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_active_ad_summaries().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("summary-account-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 _account_permission_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permission_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_permission_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permission_groups().list(opt.value_of("profile-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 _account_permissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permissions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_permissions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_permissions().list(opt.value_of("profile-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 _account_user_profiles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_user_profiles().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().insert(request, opt.value_of("profile-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 _account_user_profiles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.account_user_profiles().list(opt.value_of("profile-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 { + "user-role-id" => { + call = call.user_role_id(value.unwrap_or("")); + }, + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["search-string", "subaccount-id", "sort-field", "ids", "max-results", "page-token", "user-role-id", "sort-order", "active"].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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _account_user_profiles_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.object-ids" => Some(("userRoleFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "user-role-filter.status" => Some(("userRoleFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-filter.kind" => Some(("userRoleFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.object-ids" => Some(("siteFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "site-filter.status" => Some(("siteFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter.kind" => Some(("siteFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-type" => Some(("traffickerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.object-ids" => Some(("advertiserFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "advertiser-filter.status" => Some(("advertiserFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-filter.kind" => Some(("advertiserFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.object-ids" => Some(("campaignFilter.objectIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "campaign-filter.status" => Some(("campaignFilter.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-filter.kind" => Some(("campaignFilter.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-role-id" => Some(("userRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-access-type" => Some(("userAccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-filter", "campaign-filter", "comments", "email", "id", "kind", "locale", "name", "object-ids", "site-filter", "status", "subaccount-id", "trafficker-type", "user-access-type", "user-role-filter", "user-role-id"]); + 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::AccountUserProfile = json::value::from_value(object).unwrap(); + let mut call = self.hub.account_user_profiles().update(request, opt.value_of("profile-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 _accounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _accounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order", "active"].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 _accounts_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 })), + "teaser-size-limit" => Some(("teaserSizeLimit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "maximum-image-size" => Some(("maximumImageSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-creative-size-id" => Some(("defaultCreativeSizeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-permission-ids" => Some(("accountPermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "account-profile" => Some(("accountProfile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.report-generation-time-zone-id" => Some(("reportsConfiguration.reportGenerationTimeZoneId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reports-configuration.exposure-to-conversion-enabled" => Some(("reportsConfiguration.exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.click-duration" => Some(("reportsConfiguration.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.post-impression-activities-duration" => Some(("reportsConfiguration.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-view-opt-out" => Some(("activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-ads-limit-tier" => Some(("activeAdsLimitTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "share-reports-with-twitter" => Some(("shareReportsWithTwitter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "country-id" => Some(("countryId", 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!["account-permission-ids", "account-profile", "active", "active-ads-limit-tier", "active-view-opt-out", "available-permission-ids", "click-duration", "country-id", "currency-id", "default-creative-size-id", "description", "exposure-to-conversion-enabled", "id", "kind", "locale", "lookback-configuration", "maximum-image-size", "name", "nielsen-ocr-enabled", "post-impression-activities-duration", "report-generation-time-zone-id", "reports-configuration", "share-reports-with-twitter", "teaser-size-limit"]); + 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::Account = json::value::from_value(object).unwrap(); + let mut call = self.hub.accounts().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _accounts_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 })), + "teaser-size-limit" => Some(("teaserSizeLimit", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "maximum-image-size" => Some(("maximumImageSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "locale" => Some(("locale", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-creative-size-id" => Some(("defaultCreativeSizeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-permission-ids" => Some(("accountPermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "account-profile" => Some(("accountProfile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.report-generation-time-zone-id" => Some(("reportsConfiguration.reportGenerationTimeZoneId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reports-configuration.exposure-to-conversion-enabled" => Some(("reportsConfiguration.exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.click-duration" => Some(("reportsConfiguration.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "reports-configuration.lookback-configuration.post-impression-activities-duration" => Some(("reportsConfiguration.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-view-opt-out" => Some(("activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "active-ads-limit-tier" => Some(("activeAdsLimitTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "share-reports-with-twitter" => Some(("shareReportsWithTwitter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "country-id" => Some(("countryId", 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!["account-permission-ids", "account-profile", "active", "active-ads-limit-tier", "active-view-opt-out", "available-permission-ids", "click-duration", "country-id", "currency-id", "default-creative-size-id", "description", "exposure-to-conversion-enabled", "id", "kind", "locale", "lookback-configuration", "maximum-image-size", "name", "nielsen-ocr-enabled", "post-impression-activities-duration", "report-generation-time-zone-id", "reports-configuration", "share-reports-with-twitter", "teaser-size-limit"]); + 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::Account = json::value::from_value(object).unwrap(); + let mut call = self.hub.accounts().update(request, opt.value_of("profile-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 _ads_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.ads().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "targeting-template-id" => Some(("targetingTemplateId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "targeting-template-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().insert(request, opt.value_of("profile-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 _ads_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.ads().list(opt.value_of("profile-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 { + "type" => { + call = call.add_type(value.unwrap_or("")); + }, + "ssl-required" => { + call = call.ssl_required(arg_from_str(value.unwrap_or("false"), err, "ssl-required", "boolean")); + }, + "ssl-compliant" => { + call = call.ssl_compliant(arg_from_str(value.unwrap_or("false"), err, "ssl-compliant", "boolean")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "remarketing-list-ids" => { + call = call.add_remarketing_list_ids(value.unwrap_or("")); + }, + "placement-ids" => { + call = call.add_placement_ids(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "overridden-event-tag-id" => { + call = call.overridden_event_tag_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "landing-page-ids" => { + call = call.add_landing_page_ids(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "dynamic-click-tracker" => { + call = call.dynamic_click_tracker(arg_from_str(value.unwrap_or("false"), err, "dynamic-click-tracker", "boolean")); + }, + "creative-type" => { + call = call.creative_type(value.unwrap_or("")); + }, + "creative-optimization-configuration-ids" => { + call = call.add_creative_optimization_configuration_ids(value.unwrap_or("")); + }, + "creative-ids" => { + call = call.add_creative_ids(value.unwrap_or("")); + }, + "compatibility" => { + call = call.compatibility(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "audience-segment-ids" => { + call = call.add_audience_segment_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["landing-page-ids", "overridden-event-tag-id", "campaign-ids", "archived", "creative-optimization-configuration-ids", "ssl-compliant", "size-ids", "page-token", "sort-order", "type", "ssl-required", "creative-ids", "max-results", "creative-type", "placement-ids", "active", "compatibility", "advertiser-id", "search-string", "sort-field", "audience-segment-ids", "ids", "remarketing-list-ids", "dynamic-click-tracker"].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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "targeting-template-id" => Some(("targetingTemplateId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "targeting-template-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _ads_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()[..] { + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.priority" => Some(("deliverySchedule.priority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.hard-cutoff" => Some(("deliverySchedule.hardCutoff", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.duration" => Some(("deliverySchedule.frequencyCap.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.frequency-cap.impressions" => Some(("deliverySchedule.frequencyCap.impressions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery-schedule.impression-ratio" => Some(("deliverySchedule.impressionRatio", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "targeting-template-id" => Some(("targetingTemplateId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.weight-calculation-strategy" => Some(("creativeRotation.weightCalculationStrategy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.creative-optimization-configuration-id" => Some(("creativeRotation.creativeOptimizationConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-rotation.type" => Some(("creativeRotation.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.computed-click-through-url" => Some(("clickThroughUrl.computedClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.custom-click-through-url" => Some(("clickThroughUrl.customClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.landing-page-id" => Some(("clickThroughUrl.landingPageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url.default-landing-page" => Some(("clickThroughUrl.defaultLandingPage", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "comments" => Some(("comments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-expression.expression" => Some(("remarketingListExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "audience-segment-id" => Some(("audienceSegmentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-click-tracker" => Some(("dynamicClickTracker", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "archived", "audience-segment-id", "campaign-id", "campaign-id-dimension-value", "click-through-url", "click-through-url-suffix", "click-through-url-suffix-properties", "comments", "compatibility", "computed-click-through-url", "create-info", "creative-optimization-configuration-id", "creative-rotation", "custom-click-through-url", "day-part-targeting", "days-of-week", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "default-landing-page", "delivery-schedule", "dimension-name", "duration", "dynamic-click-tracker", "end-time", "etag", "exclude-countries", "expression", "frequency-cap", "geo-targeting", "hard-cutoff", "height", "hours-of-day", "iab", "id", "id-dimension-value", "impression-ratio", "impressions", "key-value-targeting-expression", "kind", "landing-page-id", "last-modified-info", "match-type", "name", "override-inherited-event-tag", "override-inherited-suffix", "priority", "remarketing-list-expression", "size", "ssl-compliant", "ssl-required", "start-time", "subaccount-id", "targeting-template-id", "time", "type", "user-local-time", "value", "weight-calculation-strategy", "width"]); + 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::Ad = json::value::from_value(object).unwrap(); + let mut call = self.hub.ads().update(request, opt.value_of("profile-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 _advertiser_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _advertiser_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertiser_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().insert(request, opt.value_of("profile-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 _advertiser_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertiser_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _advertiser_groups_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertiser_groups_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::AdvertiserGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertiser_groups().update(request, opt.value_of("profile-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 _advertisers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertisers().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertisers_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().insert(request, opt.value_of("profile-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 _advertisers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.advertisers().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "status" => { + call = call.status(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "only-parent" => { + call = call.only_parent(arg_from_str(value.unwrap_or("false"), err, "only-parent", "boolean")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "include-advertisers-without-groups-only" => { + call = call.include_advertisers_without_groups_only(arg_from_str(value.unwrap_or("false"), err, "include-advertisers-without-groups-only", "boolean")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-ids" => { + call = call.add_floodlight_configuration_ids(value.unwrap_or("")); + }, + "advertiser-group-ids" => { + call = call.add_advertiser_group_ids(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(["status", "search-string", "subaccount-id", "include-advertisers-without-groups-only", "sort-field", "ids", "max-results", "page-token", "only-parent", "sort-order", "floodlight-configuration-ids", "advertiser-group-ids"].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 _advertisers_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _advertisers_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "original-floodlight-configuration-id" => Some(("originalFloodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix" => Some(("clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "suspended" => Some(("suspended", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "default-email" => Some(("defaultEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "click-through-url-suffix", "default-click-through-event-tag-id", "default-email", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "original-floodlight-configuration-id", "status", "subaccount-id", "suspended", "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::Advertiser = json::value::from_value(object).unwrap(); + let mut call = self.hub.advertisers().update(request, opt.value_of("profile-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 _browsers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.browsers().list(opt.value_of("profile-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 _campaign_creative_associations_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()[..] { + "creative-id" => Some(("creativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["creative-id", "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::CampaignCreativeAssociation = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaign_creative_associations().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _campaign_creative_associations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaign_creative_associations().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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", "sort-order", "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 _campaigns_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaigns().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("default-landing-page-name").unwrap_or(""), opt.value_of("default-landing-page-url").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 _campaigns_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.campaigns().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "overridden-event-tag-id" => { + call = call.overridden_event_tag_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "excluded-ids" => { + call = call.add_excluded_ids(value.unwrap_or("")); + }, + "at-least-one-optimization-activity" => { + call = call.at_least_one_optimization_activity(arg_from_str(value.unwrap_or("false"), err, "at-least-one-optimization-activity", "boolean")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(value.unwrap_or("")); + }, + "advertiser-group-ids" => { + call = call.add_advertiser_group_ids(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(["archived", "search-string", "subaccount-id", "sort-field", "advertiser-ids", "ids", "max-results", "excluded-ids", "page-token", "advertiser-group-ids", "sort-order", "overridden-event-tag-id", "at-least-one-optimization-activity"].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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _campaigns_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.click-through-url-suffix" => Some(("clickThroughUrlSuffixProperties.clickThroughUrlSuffix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "click-through-url-suffix-properties.override-inherited-suffix" => Some(("clickThroughUrlSuffixProperties.overrideInheritedSuffix", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.optimization-model" => Some(("creativeOptimizationConfiguration.optimizationModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.id" => Some(("creativeOptimizationConfiguration.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-optimization-configuration.name" => Some(("creativeOptimizationConfiguration.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "trafficker-emails" => Some(("traffickerEmails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-group-id" => Some(("advertiserGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "billing-invoice-code" => Some(("billingInvoiceCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "creative-group-ids" => Some(("creativeGroupIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "default-click-through-event-tag-properties.override-inherited-event-tag" => Some(("defaultClickThroughEventTagProperties.overrideInheritedEventTag", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "default-click-through-event-tag-properties.default-click-through-event-tag-id" => Some(("defaultClickThroughEventTagProperties.defaultClickThroughEventTagId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "nielsen-ocr-enabled" => Some(("nielsenOcrEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-group-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "billing-invoice-code", "click-duration", "click-through-url-suffix", "click-through-url-suffix-properties", "comment", "create-info", "creative-group-ids", "creative-optimization-configuration", "default-click-through-event-tag-id", "default-click-through-event-tag-properties", "dimension-name", "end-date", "etag", "external-id", "id", "id-dimension-value", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "nielsen-ocr-enabled", "optimization-model", "override-inherited-event-tag", "override-inherited-suffix", "post-impression-activities-duration", "start-date", "subaccount-id", "time", "trafficker-emails", "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::Campaign = json::value::from_value(object).unwrap(); + let mut call = self.hub.campaigns().update(request, opt.value_of("profile-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 _change_logs_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.change_logs().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _change_logs_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.change_logs().list(opt.value_of("profile-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 { + "user-profile-ids" => { + call = call.add_user_profile_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "object-type" => { + call = call.object_type(value.unwrap_or("")); + }, + "object-ids" => { + call = call.add_object_ids(value.unwrap_or("")); + }, + "min-change-time" => { + call = call.min_change_time(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-change-time" => { + call = call.max_change_time(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "action" => { + call = call.action(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(["min-change-time", "search-string", "max-change-time", "user-profile-ids", "ids", "max-results", "object-ids", "page-token", "action", "object-type"].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 _cities_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.cities().list(opt.value_of("profile-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 { + "region-dart-ids" => { + call = call.add_region_dart_ids(value.unwrap_or("")); + }, + "name-prefix" => { + call = call.name_prefix(value.unwrap_or("")); + }, + "dart-ids" => { + call = call.add_dart_ids(value.unwrap_or("")); + }, + "country-dart-ids" => { + call = call.add_country_dart_ids(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(["dart-ids", "country-dart-ids", "region-dart-ids", "name-prefix"].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 _connection_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.connection_types().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _connection_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.connection_types().list(opt.value_of("profile-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 _content_categories_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _content_categories_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().insert(request, opt.value_of("profile-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 _content_categories_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.content_categories().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _content_categories_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::ContentCategory = json::value::from_value(object).unwrap(); + let mut call = self.hub.content_categories().update(request, opt.value_of("profile-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 _conversions_batchinsert(&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 })), + "encryption-info.kind" => Some(("encryptionInfo.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-entity-id" => Some(("encryptionInfo.encryptionEntityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-source" => Some(("encryptionInfo.encryptionSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption-info.encryption-entity-type" => Some(("encryptionInfo.encryptionEntityType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["encryption-entity-id", "encryption-entity-type", "encryption-info", "encryption-source", "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::ConversionsBatchInsertRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.conversions().batchinsert(request, opt.value_of("profile-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 _countries_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.countries().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("dart-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 _countries_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.countries().list(opt.value_of("profile-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 _creative_assets_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 })), + "detected-features" => Some(("detectedFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "asset-identifier.type" => Some(("assetIdentifier.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "asset-identifier.name" => Some(("assetIdentifier.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "warned-validation-rules" => Some(("warnedValidationRules", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["asset-identifier", "detected-features", "dimension-name", "etag", "id", "id-dimension-value", "kind", "match-type", "name", "type", "value", "warned-validation-rules"]); + 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::CreativeAssetMetadata = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_assets().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 vals = opt.values_of("mode").unwrap().collect::>(); + let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); + let mut input_file = input_file_from_opts(vals[1], err); + let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); + 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::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), + CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), + CallType::Standard => 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 _creative_field_values_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _creative_field_values_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 _creative_field_values_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_field_values().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-id").unwrap_or(""), opt.value_of("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 _creative_field_values_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "value" => Some(("value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "kind", "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::CreativeFieldValue = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_field_values().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("creative-field-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 _creative_fields_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _creative_fields_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().insert(request, opt.value_of("profile-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 _creative_fields_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_fields().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "page-token", "sort-order"].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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_fields_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeField = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_fields().update(request, opt.value_of("profile-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 _creative_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().insert(request, opt.value_of("profile-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 _creative_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creative_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "group-number" => { + call = call.group_number(arg_from_str(value.unwrap_or("-0"), err, "group-number", "integer")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "group-number", "page-token", "sort-order"].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 _creative_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creative_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "group-number" => Some(("groupNumber", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "group-number", "id", "kind", "match-type", "name", "subaccount-id", "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::CreativeGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.creative_groups().update(request, opt.value_of("profile-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 _creatives_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creatives().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-asset-selection" => Some(("dynamicAssetSelection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "creative-asset-selection.default-asset-id" => Some(("creativeAssetSelection.defaultAssetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "creative-asset-selection", "custom-html", "custom-key-values", "default-asset-id", "dimension-name", "dynamic-asset-selection", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().insert(request, opt.value_of("profile-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 _creatives_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.creatives().list(opt.value_of("profile-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 { + "types" => { + call = call.add_types(value.unwrap_or("")); + }, + "studio-creative-id" => { + call = call.studio_creative_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "rendering-ids" => { + call = call.add_rendering_ids(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "creative-field-ids" => { + call = call.add_creative_field_ids(value.unwrap_or("")); + }, + "companion-creative-ids" => { + call = call.add_companion_creative_ids(value.unwrap_or("")); + }, + "campaign-id" => { + call = call.campaign_id(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["advertiser-id", "archived", "search-string", "max-results", "campaign-id", "sort-field", "rendering-ids", "ids", "studio-creative-id", "size-ids", "page-token", "sort-order", "companion-creative-ids", "active", "creative-field-ids", "types"].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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-asset-selection" => Some(("dynamicAssetSelection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "creative-asset-selection.default-asset-id" => Some(("creativeAssetSelection.defaultAssetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "creative-asset-selection", "custom-html", "custom-key-values", "default-asset-id", "dimension-name", "dynamic-asset-selection", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _creatives_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()[..] { + "artwork-type" => Some(("artworkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "latest-trafficked-creative-id" => Some(("latestTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-plugin-version" => Some(("requiredFlashPluginVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.window-height" => Some(("fsCommand.windowHeight", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.top" => Some(("fsCommand.top", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.window-width" => Some(("fsCommand.windowWidth", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "fs-command.position-option" => Some(("fsCommand.positionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "fs-command.left" => Some(("fsCommand.left", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.kind" => Some(("renderingIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.value" => Some(("renderingIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.dimension-name" => Some(("renderingIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.etag" => Some(("renderingIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.match-type" => Some(("renderingIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "rendering-id-dimension-value.id" => Some(("renderingIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "dynamic-asset-selection" => Some(("dynamicAssetSelection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-trafficked-creative-id" => Some(("studioTraffickedCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "override-css" => Some(("overrideCss", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-source" => Some(("authoringSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "required-flash-version" => Some(("requiredFlashVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "rendering-id" => Some(("renderingId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-description" => Some(("videoDescription", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-backup-image-impressions-url" => Some(("thirdPartyBackupImageImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "version" => Some(("version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "background-color" => Some(("backgroundColor", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "custom-key-values" => Some(("customKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code" => Some(("htmlCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "total-file-size" => Some(("totalFileSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "third-party-rich-media-impressions-url" => Some(("thirdPartyRichMediaImpressionsUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "studio-advertiser-id" => Some(("studioAdvertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "video-duration" => Some(("videoDuration", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), + "redirect-url" => Some(("redirectUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "commercial-id" => Some(("commercialId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-reporting-label" => Some(("backupImageReportingLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "ad-parameters" => Some(("adParameters", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "html-code-locked" => Some(("htmlCodeLocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ad-tag-keys" => Some(("adTagKeys", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "convert-flash-to-html5" => Some(("convertFlashToHtml5", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "ssl-override" => Some(("sslOverride", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-click-through-url" => Some(("backupImageClickThroughUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "studio-creative-id" => Some(("studioCreativeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "authoring-tool" => Some(("authoringTool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "allow-script-access" => Some(("allowScriptAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "companion-creatives" => Some(("companionCreatives", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "creative-asset-selection.default-asset-id" => Some(("creativeAssetSelection.defaultAssetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auto-advance-images" => Some(("auto_advance_images", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "backup-image-features" => Some(("backupImageFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "backup-image-target-window.custom-html" => Some(("backupImageTargetWindow.customHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "backup-image-target-window.target-window-option" => Some(("backupImageTargetWindow.targetWindowOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "skippable" => Some(("skippable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "ad-parameters", "ad-tag-keys", "advertiser-id", "allow-script-access", "archived", "artwork-type", "authoring-source", "authoring-tool", "auto-advance-images", "background-color", "backup-image-click-through-url", "backup-image-features", "backup-image-reporting-label", "backup-image-target-window", "commercial-id", "companion-creatives", "compatibility", "convert-flash-to-html5", "creative-asset-selection", "custom-html", "custom-key-values", "default-asset-id", "dimension-name", "dynamic-asset-selection", "etag", "fs-command", "height", "html-code", "html-code-locked", "iab", "id", "id-dimension-value", "kind", "last-modified-info", "latest-trafficked-creative-id", "left", "match-type", "name", "override-css", "position-option", "redirect-url", "rendering-id", "rendering-id-dimension-value", "required-flash-plugin-version", "required-flash-version", "size", "skippable", "ssl-compliant", "ssl-override", "studio-advertiser-id", "studio-creative-id", "studio-trafficked-creative-id", "subaccount-id", "target-window-option", "third-party-backup-image-impressions-url", "third-party-rich-media-impressions-url", "time", "top", "total-file-size", "type", "value", "version", "video-description", "video-duration", "width", "window-height", "window-width"]); + 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::Creative = json::value::from_value(object).unwrap(); + let mut call = self.hub.creatives().update(request, opt.value_of("profile-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 _dimension_values_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()[..] { + "dimension-name" => Some(("dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-date" => Some(("startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-date" => Some(("endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["dimension-name", "end-date", "kind", "start-date"]); + 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::DimensionValueRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.dimension_values().query(request, opt.value_of("profile-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("")); + }, + "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(["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 _directory_site_contacts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_site_contacts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _directory_site_contacts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_site_contacts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(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(["search-string", "directory-site-ids", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _directory_sites_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_sites().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _directory_sites_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 })), + "country-id" => Some(("countryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.nielsen-ocr-opt-out" => Some(("settings.nielsenOcrOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.active-view-opt-out" => Some(("settings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.dfp-network-name" => Some(("settings.dfp_settings.dfp_network_name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.dfp-settings.publisher-portal-only" => Some(("settings.dfp_settings.publisherPortalOnly", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.programmatic-placement-accepted" => Some(("settings.dfp_settings.programmaticPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.pub-paid-placement-accepted" => Some(("settings.dfp_settings.pubPaidPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.dfp-settings.dfp-network-code" => Some(("settings.dfp_settings.dfp_network_code", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.verification-tag-opt-out" => Some(("settings.verificationTagOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.instream-video-placement-accepted" => Some(("settings.instream_video_placement_accepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.interstitial-placement-accepted" => Some(("settings.interstitialPlacementAccepted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "settings.video-active-view-opt-out" => Some(("settings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "currency-id" => Some(("currencyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "inpage-tag-formats" => Some(("inpageTagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-id" => Some(("parentId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "interstitial-tag-formats" => Some(("interstitialTagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["active", "active-view-opt-out", "country-id", "currency-id", "description", "dfp-network-code", "dfp-network-name", "dfp-settings", "dimension-name", "etag", "id", "id-dimension-value", "inpage-tag-formats", "instream-video-placement-accepted", "interstitial-placement-accepted", "interstitial-tag-formats", "kind", "match-type", "name", "nielsen-ocr-opt-out", "parent-id", "programmatic-placement-accepted", "pub-paid-placement-accepted", "publisher-portal-only", "settings", "url", "value", "verification-tag-opt-out", "video-active-view-opt-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::DirectorySite = json::value::from_value(object).unwrap(); + let mut call = self.hub.directory_sites().insert(request, opt.value_of("profile-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 _directory_sites_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.directory_sites().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "parent-id" => { + call = call.parent_id(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "dfp-network-code" => { + call = call.dfp_network_code(value.unwrap_or("")); + }, + "country-id" => { + call = call.country_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "accepts-publisher-paid-placements" => { + call = call.accepts_publisher_paid_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-publisher-paid-placements", "boolean")); + }, + "accepts-interstitial-placements" => { + call = call.accepts_interstitial_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-interstitial-placements", "boolean")); + }, + "accepts-in-stream-video-placements" => { + call = call.accepts_in_stream_video_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-in-stream-video-placements", "boolean")); + }, + _ => { + 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(["accepts-interstitial-placements", "accepts-publisher-paid-placements", "search-string", "country-id", "accepts-in-stream-video-placements", "sort-field", "ids", "max-results", "page-token", "sort-order", "parent-id", "active", "dfp-network-code"].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 _dynamic_targeting_keys_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.dynamic_targeting_keys().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("object-id").unwrap_or(""), opt.value_of("name").unwrap_or(""), opt.value_of("object-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _dynamic_targeting_keys_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 })), + "object-id" => Some(("objectId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "object-type" => Some(("objectType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "name", "object-id", "object-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::DynamicTargetingKey = json::value::from_value(object).unwrap(); + let mut call = self.hub.dynamic_targeting_keys().insert(request, opt.value_of("profile-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 _dynamic_targeting_keys_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.dynamic_targeting_keys().list(opt.value_of("profile-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 { + "object-type" => { + call = call.object_type(value.unwrap_or("")); + }, + "object-id" => { + call = call.object_id(value.unwrap_or("")); + }, + "names" => { + call = call.add_names(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["advertiser-id", "names", "object-id", "object-type"].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 _event_tags_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _event_tags_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _event_tags_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 })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().insert(request, opt.value_of("profile-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 _event_tags_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.event_tags().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "event-tag-types" => { + call = call.add_event_tag_types(value.unwrap_or("")); + }, + "enabled" => { + call = call.enabled(arg_from_str(value.unwrap_or("false"), err, "enabled", "boolean")); + }, + "definitions-only" => { + call = call.definitions_only(arg_from_str(value.unwrap_or("false"), err, "definitions-only", "boolean")); + }, + "campaign-id" => { + call = call.campaign_id(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_id(value.unwrap_or("")); + }, + "ad-id" => { + call = call.ad_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(["search-string", "campaign-id", "sort-field", "enabled", "ids", "advertiser-id", "ad-id", "sort-order", "event-tag-types", "definitions-only"].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 _event_tags_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _event_tags_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()[..] { + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-ids" => Some(("siteIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url-escape-levels" => Some(("urlEscapeLevels", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled-by-default" => Some(("enabledByDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-filter-type" => Some(("siteFilterType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exclude-from-adx-requests" => Some(("excludeFromAdxRequests", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "campaign-id", "campaign-id-dimension-value", "dimension-name", "enabled-by-default", "etag", "exclude-from-adx-requests", "id", "kind", "match-type", "name", "site-filter-type", "site-ids", "ssl-compliant", "status", "subaccount-id", "type", "url", "url-escape-levels", "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::EventTag = json::value::from_value(object).unwrap(); + let mut call = self.hub.event_tags().update(request, opt.value_of("profile-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 _files_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut download_mode = false; + let mut call = self.hub.files().get(opt.value_of("report-id").unwrap_or(""), opt.value_of("file-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 _files_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.files().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "scope" => { + call = call.scope(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "max-results", "sort-order", "page-token", "scope"].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 _floodlight_activities_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _floodlight_activities_generatetag(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().generatetag(opt.value_of("profile-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 { + "floodlight-activity-id" => { + call = call.floodlight_activity_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(["floodlight-activity-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 _floodlight_activities_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().insert(request, opt.value_of("profile-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 _floodlight_activities_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activities().list(opt.value_of("profile-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 { + "tag-string" => { + call = call.tag_string(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-id" => { + call = call.floodlight_configuration_id(value.unwrap_or("")); + }, + "floodlight-activity-group-type" => { + call = call.floodlight_activity_group_type(value.unwrap_or("")); + }, + "floodlight-activity-group-tag-string" => { + call = call.floodlight_activity_group_tag_string(value.unwrap_or("")); + }, + "floodlight-activity-group-name" => { + call = call.floodlight_activity_group_name(value.unwrap_or("")); + }, + "floodlight-activity-group-ids" => { + call = call.add_floodlight_activity_group_ids(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["floodlight-activity-group-ids", "search-string", "floodlight-activity-group-name", "sort-field", "floodlight-configuration-id", "ids", "max-results", "advertiser-id", "page-token", "sort-order", "tag-string", "floodlight-activity-group-tag-string", "floodlight-activity-group-type"].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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activities_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()[..] { + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "secure" => Some(("secure", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-activity-group-name" => Some(("floodlightActivityGroupName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "image-tag-enabled" => Some(("imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-id" => Some(("floodlightActivityGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-tag-string" => Some(("floodlightActivityGroupTagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-compliant" => Some(("sslCompliant", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cache-busting-type" => Some(("cacheBustingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hidden" => Some(("hidden", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expected-url" => Some(("expectedUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-format" => Some(("tagFormat", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "notes" => Some(("notes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-defined-variable-types" => Some(("userDefinedVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "counting-method" => Some(("countingMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-activity-group-type" => Some(("floodlightActivityGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "cache-busting-type", "counting-method", "dimension-name", "etag", "expected-url", "floodlight-activity-group-id", "floodlight-activity-group-name", "floodlight-activity-group-tag-string", "floodlight-activity-group-type", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "hidden", "id", "id-dimension-value", "image-tag-enabled", "kind", "match-type", "name", "notes", "secure", "ssl-compliant", "ssl-required", "subaccount-id", "tag-format", "tag-string", "user-defined-variable-types", "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::FloodlightActivity = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activities().update(request, opt.value_of("profile-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 _floodlight_activity_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activity_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activity_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().insert(request, opt.value_of("profile-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 _floodlight_activity_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_activity_groups().list(opt.value_of("profile-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 { + "type" => { + call = call.type_(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "floodlight-configuration-id" => { + call = call.floodlight_configuration_id(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["search-string", "sort-field", "floodlight-configuration-id", "ids", "max-results", "advertiser-id", "page-token", "sort-order", "type"].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 _floodlight_activity_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_activity_groups_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id" => Some(("floodlightConfigurationId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.kind" => Some(("floodlightConfigurationIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.value" => Some(("floodlightConfigurationIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.dimension-name" => Some(("floodlightConfigurationIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.etag" => Some(("floodlightConfigurationIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.match-type" => Some(("floodlightConfigurationIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-configuration-id-dimension-value.id" => Some(("floodlightConfigurationIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-string" => Some(("tagString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "dimension-name", "etag", "floodlight-configuration-id", "floodlight-configuration-id-dimension-value", "id", "id-dimension-value", "kind", "match-type", "name", "subaccount-id", "tag-string", "type", "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::FloodlightActivityGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_activity_groups().update(request, opt.value_of("profile-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 _floodlight_configurations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_configurations().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_configurations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.floodlight_configurations().list(opt.value_of("profile-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 { + "ids" => { + call = call.add_ids(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(["ids"].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 _floodlight_configurations_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()[..] { + "natural-search-conversion-attribution-option" => Some(("naturalSearchConversionAttributionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exposure-to-conversion-enabled" => Some(("exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "analytics-data-sharing-enabled" => Some(("analyticsDataSharingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "first-day-of-week" => Some(("firstDayOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "standard-variable-types" => Some(("standardVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "omniture-settings.omniture-cost-data-enabled" => Some(("omnitureSettings.omnitureCostDataEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "omniture-settings.omniture-integration-enabled" => Some(("omnitureSettings.omnitureIntegrationEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-settings.dynamic-tag-enabled" => Some(("tagSettings.dynamicTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-settings.image-tag-enabled" => Some(("tagSettings.imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "in-app-attribution-tracking-enabled" => Some(("inAppAttributionTrackingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "analytics-data-sharing-enabled", "click-duration", "dimension-name", "dynamic-tag-enabled", "etag", "exposure-to-conversion-enabled", "first-day-of-week", "id", "id-dimension-value", "image-tag-enabled", "in-app-attribution-tracking-enabled", "kind", "lookback-configuration", "match-type", "natural-search-conversion-attribution-option", "omniture-cost-data-enabled", "omniture-integration-enabled", "omniture-settings", "post-impression-activities-duration", "standard-variable-types", "subaccount-id", "tag-settings", "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::FloodlightConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_configurations().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _floodlight_configurations_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()[..] { + "natural-search-conversion-attribution-option" => Some(("naturalSearchConversionAttributionOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "exposure-to-conversion-enabled" => Some(("exposureToConversionEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "analytics-data-sharing-enabled" => Some(("analyticsDataSharingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "first-day-of-week" => Some(("firstDayOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "standard-variable-types" => Some(("standardVariableTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "omniture-settings.omniture-cost-data-enabled" => Some(("omnitureSettings.omnitureCostDataEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "omniture-settings.omniture-integration-enabled" => Some(("omnitureSettings.omnitureIntegrationEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-settings.dynamic-tag-enabled" => Some(("tagSettings.dynamicTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-settings.image-tag-enabled" => Some(("tagSettings.imageTagEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "in-app-attribution-tracking-enabled" => Some(("inAppAttributionTrackingEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "analytics-data-sharing-enabled", "click-duration", "dimension-name", "dynamic-tag-enabled", "etag", "exposure-to-conversion-enabled", "first-day-of-week", "id", "id-dimension-value", "image-tag-enabled", "in-app-attribution-tracking-enabled", "kind", "lookback-configuration", "match-type", "natural-search-conversion-attribution-option", "omniture-cost-data-enabled", "omniture-integration-enabled", "omniture-settings", "post-impression-activities-duration", "standard-variable-types", "subaccount-id", "tag-settings", "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::FloodlightConfiguration = json::value::from_value(object).unwrap(); + let mut call = self.hub.floodlight_configurations().update(request, opt.value_of("profile-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 _inventory_items_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.inventory_items().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _inventory_items_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.inventory_items().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "type" => { + call = call.type_(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "in-plan" => { + call = call.in_plan(arg_from_str(value.unwrap_or("false"), err, "in-plan", "boolean")); + }, + "ids" => { + call = call.add_ids(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(["order-id", "sort-field", "ids", "max-results", "page-token", "in-plan", "site-id", "sort-order", "type"].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 _landing_pages_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _landing_pages_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().insert(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _landing_pages_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.landing_pages().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-id").unwrap_or(""), opt.value_of("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 _landing_pages_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()[..] { + "default" => Some(("default", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "url" => Some(("url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", 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!["default", "id", "kind", "name", "url"]); + 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::LandingPage = json::value::from_value(object).unwrap(); + let mut call = self.hub.landing_pages().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("campaign-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 _languages_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.languages().list(opt.value_of("profile-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 _metros_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.metros().list(opt.value_of("profile-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 _mobile_carriers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.mobile_carriers().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _mobile_carriers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.mobile_carriers().list(opt.value_of("profile-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 _operating_system_versions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_system_versions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _operating_system_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_system_versions().list(opt.value_of("profile-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 _operating_systems_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_systems().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("dart-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 _operating_systems_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.operating_systems().list(opt.value_of("profile-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 _order_documents_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.order_documents().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _order_documents_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.order_documents().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "boolean")); + }, + _ => { + 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(["order-id", "search-string", "sort-field", "ids", "max-results", "page-token", "site-id", "sort-order", "approved"].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 _orders_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.orders().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("project-id").unwrap_or(""), opt.value_of("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 _orders_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.orders().list(opt.value_of("profile-id").unwrap_or(""), 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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "site-id", "sort-order"].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 _placement_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().insert(request, opt.value_of("profile-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 _placement_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_groups().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-ids" => { + call = call.add_site_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "pricing-types" => { + call = call.add_pricing_types(value.unwrap_or("")); + }, + "placement-strategy-ids" => { + call = call.add_placement_strategy_ids(value.unwrap_or("")); + }, + "placement-group-type" => { + call = call.placement_group_type(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "min-start-date" => { + call = call.min_start_date(value.unwrap_or("")); + }, + "min-end-date" => { + call = call.min_end_date(value.unwrap_or("")); + }, + "max-start-date" => { + call = call.max_start_date(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-end-date" => { + call = call.max_end_date(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "content-category-ids" => { + call = call.add_content_category_ids(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["placement-strategy-ids", "site-ids", "search-string", "min-end-date", "directory-site-ids", "sort-field", "advertiser-ids", "archived", "ids", "max-results", "min-start-date", "page-token", "max-start-date", "sort-order", "placement-group-type", "pricing-types", "content-category-ids", "campaign-ids", "max-end-date"].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 _placement_groups_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_groups_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id" => Some(("primaryPlacementId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-type" => Some(("placementGroupType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "child-placement-ids" => Some(("childPlacementIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.kind" => Some(("primaryPlacementIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.value" => Some(("primaryPlacementIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.dimension-name" => Some(("primaryPlacementIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.etag" => Some(("primaryPlacementIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.match-type" => Some(("primaryPlacementIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary-placement-id-dimension-value.id" => Some(("primaryPlacementIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "child-placement-ids", "comment", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "id", "id-dimension-value", "kind", "last-modified-info", "match-type", "name", "placement-group-type", "placement-strategy-id", "pricing-schedule", "pricing-type", "primary-placement-id", "primary-placement-id-dimension-value", "site-id", "site-id-dimension-value", "start-date", "subaccount-id", "testing-start-date", "time", "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::PlacementGroup = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_groups().update(request, opt.value_of("profile-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 _placement_strategies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _placement_strategies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().insert(request, opt.value_of("profile-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 _placement_strategies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placement_strategies().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placement_strategies_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 })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "id", "kind", "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::PlacementStrategy = json::value::from_value(object).unwrap(); + let mut call = self.hub.placement_strategies().update(request, opt.value_of("profile-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 _placements_generatetags(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().generatetags(opt.value_of("profile-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 { + "tag-formats" => { + call = call.add_tag_formats(value.unwrap_or("")); + }, + "placement-ids" => { + call = call.add_placement_ids(value.unwrap_or("")); + }, + "campaign-id" => { + call = call.campaign_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(["tag-formats", "placement-ids", "campaign-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 _placements_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().insert(request, opt.value_of("profile-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 _placements_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.placements().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "size-ids" => { + call = call.add_size_ids(value.unwrap_or("")); + }, + "site-ids" => { + call = call.add_site_ids(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "pricing-types" => { + call = call.add_pricing_types(value.unwrap_or("")); + }, + "placement-strategy-ids" => { + call = call.add_placement_strategy_ids(value.unwrap_or("")); + }, + "payment-source" => { + call = call.payment_source(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "min-start-date" => { + call = call.min_start_date(value.unwrap_or("")); + }, + "min-end-date" => { + call = call.min_end_date(value.unwrap_or("")); + }, + "max-start-date" => { + call = call.max_start_date(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "max-end-date" => { + call = call.max_end_date(value.unwrap_or("")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "group-ids" => { + call = call.add_group_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "content-category-ids" => { + call = call.add_content_category_ids(value.unwrap_or("")); + }, + "compatibilities" => { + call = call.add_compatibilities(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "archived" => { + call = call.archived(arg_from_str(value.unwrap_or("false"), err, "archived", "boolean")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["site-ids", "payment-source", "pricing-types", "campaign-ids", "archived", "advertiser-ids", "size-ids", "page-token", "max-start-date", "sort-order", "max-end-date", "placement-strategy-ids", "content-category-ids", "max-results", "min-start-date", "compatibilities", "search-string", "min-end-date", "directory-site-ids", "sort-field", "ids", "group-ids"].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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _placements_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()[..] { + "comment" => Some(("comment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id" => Some(("campaignId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "payment-source" => Some(("paymentSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "archived" => Some(("archived", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "publisher-update-info.time" => Some(("publisherUpdateInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-formats" => Some(("tagFormats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "payment-approved" => Some(("paymentApproved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-through-urls" => Some(("tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.include-click-tracking" => Some(("tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "tag-setting.additional-key-values" => Some(("tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "tag-setting.keyword-option" => Some(("tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-category-id" => Some(("contentCategoryId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "external-id" => Some(("externalId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.width" => Some(("size.width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "size.kind" => Some(("size.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.iab" => Some(("size.iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "size.id" => Some(("size.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "size.height" => Some(("size.height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ssl-required" => Some(("sslRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.kind" => Some(("campaignIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.value" => Some(("campaignIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.dimension-name" => Some(("campaignIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.etag" => Some(("campaignIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.match-type" => Some(("campaignIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "campaign-id-dimension-value.id" => Some(("campaignIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "primary" => Some(("primary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "placement-group-id" => Some(("placementGroupId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-info.time" => Some(("createInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id" => Some(("siteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.kind" => Some(("siteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.value" => Some(("siteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.dimension-name" => Some(("siteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.etag" => Some(("siteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.match-type" => Some(("siteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-id-dimension-value.id" => Some(("siteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "compatibility" => Some(("compatibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-strategy-id" => Some(("placementStrategyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.kind" => Some(("placementGroupIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.value" => Some(("placementGroupIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.dimension-name" => Some(("placementGroupIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.etag" => Some(("placementGroupIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.match-type" => Some(("placementGroupIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "placement-group-id-dimension-value.id" => Some(("placementGroupIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "lookback-configuration.click-duration" => Some(("lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "lookback-configuration.post-impression-activities-duration" => Some(("lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "last-modified-info.time" => Some(("lastModifiedInfo.time", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.start-date" => Some(("pricingSchedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.end-date" => Some(("pricingSchedule.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.flighted" => Some(("pricingSchedule.flighted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.disregard-overdelivery" => Some(("pricingSchedule.disregardOverdelivery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "pricing-schedule.pricing-type" => Some(("pricingSchedule.pricingType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.cap-cost-option" => Some(("pricingSchedule.capCostOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.testing-start-date" => Some(("pricingSchedule.testingStartDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "pricing-schedule.floodlight-activity-id" => Some(("pricingSchedule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "additional-key-values", "advertiser-id", "advertiser-id-dimension-value", "archived", "campaign-id", "campaign-id-dimension-value", "cap-cost-option", "click-duration", "comment", "compatibility", "content-category-id", "create-info", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disregard-overdelivery", "end-date", "etag", "external-id", "flighted", "floodlight-activity-id", "height", "iab", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "last-modified-info", "lookback-configuration", "match-type", "name", "payment-approved", "payment-source", "placement-group-id", "placement-group-id-dimension-value", "placement-strategy-id", "post-impression-activities-duration", "pricing-schedule", "pricing-type", "primary", "publisher-update-info", "site-id", "site-id-dimension-value", "size", "ssl-required", "start-date", "status", "subaccount-id", "tag-formats", "tag-setting", "testing-start-date", "time", "value", "width"]); + 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::Placement = json::value::from_value(object).unwrap(); + let mut call = self.hub.placements().update(request, opt.value_of("profile-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 _platform_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.platform_types().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _platform_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.platform_types().list(opt.value_of("profile-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 _postal_codes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.postal_codes().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("code").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 _postal_codes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.postal_codes().list(opt.value_of("profile-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_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.projects().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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(["search-string", "sort-field", "advertiser-ids", "ids", "max-results", "page-token", "sort-order"].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("profile-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 _remarketing_list_shares_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_list_shares().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("remarketing-list-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 _remarketing_list_shares_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()[..] { + "shared-advertiser-ids" => Some(("sharedAdvertiserIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-id" => Some(("remarketingListId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "shared-account-ids" => Some(("sharedAccountIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "remarketing-list-id", "shared-account-ids", "shared-advertiser-ids"]); + 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::RemarketingListShare = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_list_shares().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("remarketing-list-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 _remarketing_list_shares_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()[..] { + "shared-advertiser-ids" => Some(("sharedAdvertiserIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "remarketing-list-id" => Some(("remarketingListId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "shared-account-ids" => Some(("sharedAccountIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["kind", "remarketing-list-id", "shared-account-ids", "shared-advertiser-ids"]); + 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::RemarketingListShare = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_list_shares().update(request, opt.value_of("profile-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 _remarketing_lists_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_lists().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().insert(request, opt.value_of("profile-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 _remarketing_lists_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.remarketing_lists().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "floodlight-activity-id" => { + call = call.floodlight_activity_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["name", "sort-field", "max-results", "page-token", "sort-order", "active", "floodlight-activity-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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _remarketing_lists_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()[..] { + "list-population-rule.floodlight-activity-name" => Some(("listPopulationRule.floodlightActivityName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-population-rule.floodlight-activity-id" => Some(("listPopulationRule.floodlightActivityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-size" => Some(("listSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "life-span" => Some(("lifeSpan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "active" => Some(("active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "list-source" => Some(("listSource", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "advertiser-id", "advertiser-id-dimension-value", "description", "dimension-name", "etag", "floodlight-activity-id", "floodlight-activity-name", "id", "kind", "life-span", "list-population-rule", "list-size", "list-source", "match-type", "name", "subaccount-id", "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::RemarketingList = json::value::from_value(object).unwrap(); + let mut call = self.hub.remarketing_lists().update(request, opt.value_of("profile-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 _reports_compatible_fields_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().compatible_fields_query(request, opt.value_of("profile-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 _reports_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _reports_files_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut download_mode = false; + let mut call = self.hub.reports().files_get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-id").unwrap_or(""), opt.value_of("file-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 _reports_files_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().files_list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "sort-order", "max-results", "page-token"].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 _reports_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().insert(request, opt.value_of("profile-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 _reports_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "scope" => { + call = call.scope(value.unwrap_or("")); + }, + "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")); + }, + _ => { + 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(["sort-field", "max-results", "sort-order", "page-token", "scope"].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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _reports_run(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.reports().run(opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 { + "synchronous" => { + call = call.synchronous(arg_from_str(value.unwrap_or("false"), err, "synchronous", "boolean")); + }, + _ => { + 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(["synchronous"].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 _reports_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()[..] { + "criteria.activities.kind" => Some(("criteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.activities.metric-names" => Some(("criteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "criteria.date-range.start-date" => Some(("criteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.kind" => Some(("criteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.end-date" => Some(("criteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.date-range.relative-date-range" => Some(("criteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.custom-rich-media-events.kind" => Some(("criteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.metric-names" => Some(("criteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "sub-account-id" => Some(("subAccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.start-date" => Some(("schedule.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.runs-on-day-of-month" => Some(("schedule.runsOnDayOfMonth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.every" => Some(("schedule.every", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "schedule.expiration-date" => Some(("schedule.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.active" => Some(("schedule.active", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "schedule.repeats" => Some(("schedule.repeats", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "schedule.repeats-on-week-days" => Some(("schedule.repeatsOnWeekDays", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "path-to-conversion-criteria.date-range.start-date" => Some(("pathToConversionCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.kind" => Some(("pathToConversionCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.end-date" => Some(("pathToConversionCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.date-range.relative-date-range" => Some(("pathToConversionCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.kind" => Some(("pathToConversionCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.value" => Some(("pathToConversionCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.dimension-name" => Some(("pathToConversionCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.etag" => Some(("pathToConversionCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.match-type" => Some(("pathToConversionCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.floodlight-config-id.id" => Some(("pathToConversionCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.clicks-lookback-window" => Some(("pathToConversionCriteria.reportProperties.clicksLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => Some(("pathToConversionCriteria.reportProperties.pivotOnInteractionPath", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.impressions-lookback-window" => Some(("pathToConversionCriteria.reportProperties.impressionsLookbackWindow", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("pathToConversionCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => Some(("pathToConversionCriteria.reportProperties.maximumInteractionGap", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => Some(("pathToConversionCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-click-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumClickInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => Some(("pathToConversionCriteria.reportProperties.maximumImpressionInteractions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "path-to-conversion-criteria.metric-names" => Some(("pathToConversionCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "format" => Some(("format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.kind" => Some(("reachCriteria.activities.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.activities.metric-names" => Some(("reachCriteria.activities.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.metric-names" => Some(("reachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.date-range.start-date" => Some(("reachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.kind" => Some(("reachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.end-date" => Some(("reachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.date-range.relative-date-range" => Some(("reachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.reach-by-frequency-metric-names" => Some(("reachCriteria.reachByFrequencyMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "reach-criteria.custom-rich-media-events.kind" => Some(("reachCriteria.customRichMediaEvents.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reach-criteria.enable-all-dimension-combinations" => Some(("reachCriteria.enableAllDimensionCombinations", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "file-name" => Some(("fileName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.message" => Some(("delivery.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner-delivery-type" => Some(("delivery.emailOwnerDeliveryType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delivery.email-owner" => Some(("delivery.emailOwner", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "owner-profile-id" => Some(("ownerProfileId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "last-modified-time" => Some(("lastModifiedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.start-date" => Some(("floodlightCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.kind" => Some(("floodlightCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.end-date" => Some(("floodlightCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.date-range.relative-date-range" => Some(("floodlightCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.kind" => Some(("floodlightCriteria.floodlightConfigId.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.value" => Some(("floodlightCriteria.floodlightConfigId.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.dimension-name" => Some(("floodlightCriteria.floodlightConfigId.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.etag" => Some(("floodlightCriteria.floodlightConfigId.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.match-type" => Some(("floodlightCriteria.floodlightConfigId.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.floodlight-config-id.id" => Some(("floodlightCriteria.floodlightConfigId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => Some(("floodlightCriteria.reportProperties.includeUnattributedCookieConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.report-properties.include-attributed-ip-conversions" => Some(("floodlightCriteria.reportProperties.includeAttributedIPConversions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "floodlight-criteria.metric-names" => Some(("floodlightCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.pivoted" => Some(("crossDimensionReachCriteria.pivoted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.start-date" => Some(("crossDimensionReachCriteria.dateRange.startDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.kind" => Some(("crossDimensionReachCriteria.dateRange.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.end-date" => Some(("crossDimensionReachCriteria.dateRange.endDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.date-range.relative-date-range" => Some(("crossDimensionReachCriteria.dateRange.relativeDateRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.dimension" => Some(("crossDimensionReachCriteria.dimension", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cross-dimension-reach-criteria.overlap-metric-names" => Some(("crossDimensionReachCriteria.overlapMetricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "cross-dimension-reach-criteria.metric-names" => Some(("crossDimensionReachCriteria.metricNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active", "activities", "clicks-lookback-window", "criteria", "cross-dimension-reach-criteria", "custom-rich-media-events", "date-range", "delivery", "dimension", "dimension-name", "email-owner", "email-owner-delivery-type", "enable-all-dimension-combinations", "end-date", "etag", "every", "expiration-date", "file-name", "floodlight-config-id", "floodlight-criteria", "format", "id", "impressions-lookback-window", "include-attributed-ip-conversions", "include-unattributed-cookie-conversions", "include-unattributed-ip-conversions", "kind", "last-modified-time", "match-type", "maximum-click-interactions", "maximum-impression-interactions", "maximum-interaction-gap", "message", "metric-names", "name", "overlap-metric-names", "owner-profile-id", "path-to-conversion-criteria", "pivot-on-interaction-path", "pivoted", "reach-by-frequency-metric-names", "reach-criteria", "relative-date-range", "repeats", "repeats-on-week-days", "report-properties", "runs-on-day-of-month", "schedule", "start-date", "sub-account-id", "type", "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::Report = json::value::from_value(object).unwrap(); + let mut call = self.hub.reports().update(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("report-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 _sites_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sites().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().insert(request, opt.value_of("profile-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 _sites_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sites().list(opt.value_of("profile-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 { + "unmapped-site" => { + call = call.unmapped_site(arg_from_str(value.unwrap_or("false"), err, "unmapped-site", "boolean")); + }, + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "directory-site-ids" => { + call = call.add_directory_site_ids(value.unwrap_or("")); + }, + "campaign-ids" => { + call = call.add_campaign_ids(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "boolean")); + }, + "ad-words-site" => { + call = call.ad_words_site(arg_from_str(value.unwrap_or("false"), err, "ad-words-site", "boolean")); + }, + "accepts-publisher-paid-placements" => { + call = call.accepts_publisher_paid_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-publisher-paid-placements", "boolean")); + }, + "accepts-interstitial-placements" => { + call = call.accepts_interstitial_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-interstitial-placements", "boolean")); + }, + "accepts-in-stream-video-placements" => { + call = call.accepts_in_stream_video_placements(arg_from_str(value.unwrap_or("false"), err, "accepts-in-stream-video-placements", "boolean")); + }, + _ => { + 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(["accepts-interstitial-placements", "accepts-publisher-paid-placements", "search-string", "subaccount-id", "directory-site-ids", "sort-field", "ids", "max-results", "page-token", "unmapped-site", "accepts-in-stream-video-placements", "ad-words-site", "campaign-ids", "approved", "sort-order"].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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sites_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.kind" => Some(("directorySiteIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.value" => Some(("directorySiteIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.dimension-name" => Some(("directorySiteIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.etag" => Some(("directorySiteIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.match-type" => Some(("directorySiteIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id-dimension-value.id" => Some(("directorySiteIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.disable-brand-safe-ads" => Some(("siteSettings.disableBrandSafeAds", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.active-view-opt-out" => Some(("siteSettings.activeViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.click-duration" => Some(("siteSettings.lookbackConfiguration.clickDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.lookback-configuration.post-impression-activities-duration" => Some(("siteSettings.lookbackConfiguration.postImpressionActivitiesDuration", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "site-settings.disable-new-cookie" => Some(("siteSettings.disableNewCookie", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-through-urls" => Some(("siteSettings.tagSetting.includeClickThroughUrls", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.include-click-tracking" => Some(("siteSettings.tagSetting.includeClickTracking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "site-settings.tag-setting.additional-key-values" => Some(("siteSettings.tagSetting.additionalKeyValues", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.tag-setting.keyword-option" => Some(("siteSettings.tagSetting.keywordOption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-header" => Some(("siteSettings.creativeSettings.iFrameHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.creative-settings.i-frame-footer" => Some(("siteSettings.creativeSettings.iFrameFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "site-settings.video-active-view-opt-out" => Some(("siteSettings.videoActiveViewOptOut", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "approved" => Some(("approved", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-dimension-value.kind" => Some(("idDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.value" => Some(("idDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.dimension-name" => Some(("idDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.etag" => Some(("idDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.match-type" => Some(("idDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id-dimension-value.id" => Some(("idDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "directory-site-id" => Some(("directorySiteId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "active-view-opt-out", "additional-key-values", "approved", "click-duration", "creative-settings", "dimension-name", "directory-site-id", "directory-site-id-dimension-value", "disable-brand-safe-ads", "disable-new-cookie", "etag", "i-frame-footer", "i-frame-header", "id", "id-dimension-value", "include-click-through-urls", "include-click-tracking", "key-name", "keyword-option", "kind", "lookback-configuration", "match-type", "name", "post-impression-activities-duration", "site-settings", "subaccount-id", "tag-setting", "value", "video-active-view-opt-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::Site = json::value::from_value(object).unwrap(); + let mut call = self.hub.sites().update(request, opt.value_of("profile-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 _sizes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sizes().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _sizes_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()[..] { + "width" => Some(("width", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "iab" => Some(("iab", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "height" => Some(("height", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["height", "iab", "id", "kind", "width"]); + 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::Size = json::value::from_value(object).unwrap(); + let mut call = self.hub.sizes().insert(request, opt.value_of("profile-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 _sizes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.sizes().list(opt.value_of("profile-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 { + "width" => { + call = call.width(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "iab-standard" => { + call = call.iab_standard(arg_from_str(value.unwrap_or("false"), err, "iab-standard", "boolean")); + }, + "height" => { + call = call.height(arg_from_str(value.unwrap_or("-0"), err, "height", "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(["iab-standard", "width", "ids", "height"].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 _subaccounts_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.subaccounts().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().insert(request, opt.value_of("profile-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 _subaccounts_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.subaccounts().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(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(["search-string", "sort-field", "ids", "max-results", "page-token", "sort-order"].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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _subaccounts_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 })), + "available-permission-ids" => Some(("availablePermissionIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "available-permission-ids", "id", "kind", "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::Subaccount = json::value::from_value(object).unwrap(); + let mut call = self.hub.subaccounts().update(request, opt.value_of("profile-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 _targetable_remarketing_lists_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targetable_remarketing_lists().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _targetable_remarketing_lists_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targetable_remarketing_lists().list(opt.value_of("profile-id").unwrap_or(""), opt.value_of("advertiser-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + _ => { + 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(["name", "sort-field", "max-results", "page-token", "sort-order", "active"].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 _targeting_templates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targeting_templates().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _targeting_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "list-targeting-expression.expression" => Some(("listTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "day-part-targeting", "days-of-week", "dimension-name", "etag", "exclude-countries", "expression", "geo-targeting", "hours-of-day", "id", "key-value-targeting-expression", "kind", "list-targeting-expression", "match-type", "name", "subaccount-id", "user-local-time", "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::TargetingTemplate = json::value::from_value(object).unwrap(); + let mut call = self.hub.targeting_templates().insert(request, opt.value_of("profile-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 _targeting_templates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.targeting_templates().list(opt.value_of("profile-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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-id" => { + call = call.advertiser_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(["search-string", "sort-field", "ids", "max-results", "advertiser-id", "page-token", "sort-order"].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 _targeting_templates_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "list-targeting-expression.expression" => Some(("listTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "day-part-targeting", "days-of-week", "dimension-name", "etag", "exclude-countries", "expression", "geo-targeting", "hours-of-day", "id", "key-value-targeting-expression", "kind", "list-targeting-expression", "match-type", "name", "subaccount-id", "user-local-time", "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::TargetingTemplate = json::value::from_value(object).unwrap(); + let mut call = self.hub.targeting_templates().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _targeting_templates_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 })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "day-part-targeting.user-local-time" => Some(("dayPartTargeting.userLocalTime", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "day-part-targeting.hours-of-day" => Some(("dayPartTargeting.hoursOfDay", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Vec })), + "day-part-targeting.days-of-week" => Some(("dayPartTargeting.daysOfWeek", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "list-targeting-expression.expression" => Some(("listTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "key-value-targeting-expression.expression" => Some(("keyValueTargetingExpression.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id" => Some(("advertiserId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "geo-targeting.exclude-countries" => Some(("geoTargeting.excludeCountries", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.kind" => Some(("advertiserIdDimensionValue.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.value" => Some(("advertiserIdDimensionValue.value", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.dimension-name" => Some(("advertiserIdDimensionValue.dimensionName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.etag" => Some(("advertiserIdDimensionValue.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.match-type" => Some(("advertiserIdDimensionValue.matchType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "advertiser-id-dimension-value.id" => Some(("advertiserIdDimensionValue.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "advertiser-id", "advertiser-id-dimension-value", "day-part-targeting", "days-of-week", "dimension-name", "etag", "exclude-countries", "expression", "geo-targeting", "hours-of-day", "id", "key-value-targeting-expression", "kind", "list-targeting-expression", "match-type", "name", "subaccount-id", "user-local-time", "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::TargetingTemplate = json::value::from_value(object).unwrap(); + let mut call = self.hub.targeting_templates().update(request, opt.value_of("profile-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 _user_profiles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().get(opt.value_of("profile-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 _user_profiles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_profiles().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 { + _ => { + 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 _user_role_permission_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permission_groups().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_role_permission_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permission_groups().list(opt.value_of("profile-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 _user_role_permissions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permissions().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_role_permissions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_role_permissions().list(opt.value_of("profile-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 { + "ids" => { + call = call.add_ids(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(["ids"].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 _user_roles_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().delete(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _user_roles_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().get(opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().insert(request, opt.value_of("profile-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 _user_roles_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.user_roles().list(opt.value_of("profile-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 { + "subaccount-id" => { + call = call.subaccount_id(value.unwrap_or("")); + }, + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "account-user-role-only" => { + call = call.account_user_role_only(arg_from_str(value.unwrap_or("false"), err, "account-user-role-only", "boolean")); + }, + _ => { + 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(["search-string", "subaccount-id", "sort-field", "ids", "max-results", "page-token", "sort-order", "account-user-role-only"].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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().patch(request, opt.value_of("profile-id").unwrap_or(""), opt.value_of("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 _user_roles_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()[..] { + "default-user-role" => Some(("defaultUserRole", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "subaccount-id" => Some(("subaccountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "parent-user-role-id" => Some(("parentUserRoleId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "account-id" => Some(("accountId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["account-id", "default-user-role", "id", "kind", "name", "parent-user-role-id", "subaccount-id"]); + 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::UserRole = json::value::from_value(object).unwrap(); + let mut call = self.hub.user_roles().update(request, opt.value_of("profile-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() { + ("account-active-ad-summaries", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_active_ad_summaries_get(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-active-ad-summaries".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-permission-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_permission_groups_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_permission_groups_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-permission-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-permissions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_permissions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_permissions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-permissions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("account-user-profiles", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._account_user_profiles_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._account_user_profiles_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._account_user_profiles_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._account_user_profiles_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._account_user_profiles_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("account-user-profiles".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("accounts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._accounts_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._accounts_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._accounts_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._accounts_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("accounts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("ads", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._ads_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._ads_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._ads_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._ads_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._ads_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("ads".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("advertiser-groups", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._advertiser_groups_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._advertiser_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._advertiser_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._advertiser_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._advertiser_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._advertiser_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("advertiser-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("advertisers", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._advertisers_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._advertisers_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._advertisers_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._advertisers_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._advertisers_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("advertisers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("browsers", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._browsers_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("browsers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("campaign-creative-associations", Some(opt)) => { + match opt.subcommand() { + ("insert", Some(opt)) => { + call_result = self._campaign_creative_associations_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._campaign_creative_associations_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("campaign-creative-associations".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("campaigns", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._campaigns_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._campaigns_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._campaigns_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._campaigns_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._campaigns_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("campaigns".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("change-logs", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._change_logs_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._change_logs_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("change-logs".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("cities", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._cities_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("cities".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("connection-types", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._connection_types_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._connection_types_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("connection-types".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("content-categories", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._content_categories_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._content_categories_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._content_categories_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._content_categories_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._content_categories_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._content_categories_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("content-categories".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("conversions", Some(opt)) => { + match opt.subcommand() { + ("batchinsert", Some(opt)) => { + call_result = self._conversions_batchinsert(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("conversions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("countries", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._countries_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._countries_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("countries".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-assets", Some(opt)) => { + match opt.subcommand() { + ("insert", Some(opt)) => { + call_result = self._creative_assets_insert(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-assets".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-field-values", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._creative_field_values_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._creative_field_values_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_field_values_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_field_values_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_field_values_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_field_values_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-field-values".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-fields", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._creative_fields_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._creative_fields_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_fields_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_fields_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_fields_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_fields_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-fields".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creative-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._creative_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creative_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creative_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creative_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creative_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creative-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("creatives", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._creatives_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._creatives_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._creatives_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._creatives_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._creatives_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("creatives".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("dimension-values", Some(opt)) => { + match opt.subcommand() { + ("query", Some(opt)) => { + call_result = self._dimension_values_query(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("dimension-values".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("directory-site-contacts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._directory_site_contacts_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._directory_site_contacts_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("directory-site-contacts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("directory-sites", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._directory_sites_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._directory_sites_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._directory_sites_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("directory-sites".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("dynamic-targeting-keys", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._dynamic_targeting_keys_delete(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._dynamic_targeting_keys_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._dynamic_targeting_keys_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("dynamic-targeting-keys".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("event-tags", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._event_tags_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._event_tags_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._event_tags_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._event_tags_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._event_tags_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._event_tags_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("event-tags".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("files", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._files_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._files_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("files".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-activities", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._floodlight_activities_delete(opt, dry_run, &mut err); + }, + ("generatetag", Some(opt)) => { + call_result = self._floodlight_activities_generatetag(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._floodlight_activities_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._floodlight_activities_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_activities_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_activities_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_activities_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-activities".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-activity-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._floodlight_activity_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._floodlight_activity_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_activity_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_activity_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_activity_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-activity-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("floodlight-configurations", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._floodlight_configurations_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._floodlight_configurations_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._floodlight_configurations_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._floodlight_configurations_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("floodlight-configurations".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("inventory-items", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._inventory_items_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._inventory_items_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("inventory-items".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("landing-pages", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._landing_pages_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._landing_pages_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._landing_pages_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._landing_pages_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._landing_pages_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._landing_pages_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("landing-pages".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("languages", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._languages_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("languages".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("metros", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._metros_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("metros".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("mobile-carriers", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._mobile_carriers_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._mobile_carriers_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("mobile-carriers".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("operating-system-versions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._operating_system_versions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._operating_system_versions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("operating-system-versions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("operating-systems", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._operating_systems_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._operating_systems_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("operating-systems".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("order-documents", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._order_documents_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._order_documents_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("order-documents".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("orders", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._orders_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._orders_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("orders".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placement-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._placement_groups_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placement_groups_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placement_groups_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placement_groups_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placement_groups_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placement-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placement-strategies", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._placement_strategies_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._placement_strategies_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placement_strategies_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placement_strategies_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placement_strategies_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placement_strategies_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placement-strategies".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("placements", Some(opt)) => { + match opt.subcommand() { + ("generatetags", Some(opt)) => { + call_result = self._placements_generatetags(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._placements_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._placements_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._placements_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._placements_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._placements_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("placements".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("platform-types", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._platform_types_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._platform_types_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("platform-types".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("postal-codes", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._postal_codes_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._postal_codes_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("postal-codes".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); + }, + ("list", Some(opt)) => { + call_result = self._projects_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("projects".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("regions", Some(opt)) => { + match opt.subcommand() { + ("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(); + } + } + }, + ("remarketing-list-shares", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._remarketing_list_shares_get(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._remarketing_list_shares_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._remarketing_list_shares_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("remarketing-list-shares".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("remarketing-lists", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._remarketing_lists_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._remarketing_lists_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._remarketing_lists_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._remarketing_lists_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._remarketing_lists_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("remarketing-lists".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("reports", Some(opt)) => { + match opt.subcommand() { + ("compatible-fields-query", Some(opt)) => { + call_result = self._reports_compatible_fields_query(opt, dry_run, &mut err); + }, + ("delete", Some(opt)) => { + call_result = self._reports_delete(opt, dry_run, &mut err); + }, + ("files-get", Some(opt)) => { + call_result = self._reports_files_get(opt, dry_run, &mut err); + }, + ("files-list", Some(opt)) => { + call_result = self._reports_files_list(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._reports_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._reports_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._reports_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._reports_patch(opt, dry_run, &mut err); + }, + ("run", Some(opt)) => { + call_result = self._reports_run(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._reports_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("reports".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("sites", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._sites_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._sites_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._sites_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._sites_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._sites_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("sites".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("sizes", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._sizes_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._sizes_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._sizes_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("sizes".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("subaccounts", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._subaccounts_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._subaccounts_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._subaccounts_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._subaccounts_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._subaccounts_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("subaccounts".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("targetable-remarketing-lists", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._targetable_remarketing_lists_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._targetable_remarketing_lists_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("targetable-remarketing-lists".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("targeting-templates", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._targeting_templates_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._targeting_templates_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._targeting_templates_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._targeting_templates_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._targeting_templates_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("targeting-templates".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-profiles", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_profiles_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_profiles_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-profiles".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-role-permission-groups", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_role_permission_groups_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_role_permission_groups_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-role-permission-groups".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-role-permissions", Some(opt)) => { + match opt.subcommand() { + ("get", Some(opt)) => { + call_result = self._user_role_permissions_get(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_role_permissions_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-role-permissions".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("user-roles", Some(opt)) => { + match opt.subcommand() { + ("delete", Some(opt)) => { + call_result = self._user_roles_delete(opt, dry_run, &mut err); + }, + ("get", Some(opt)) => { + call_result = self._user_roles_get(opt, dry_run, &mut err); + }, + ("insert", Some(opt)) => { + call_result = self._user_roles_insert(opt, dry_run, &mut err); + }, + ("list", Some(opt)) => { + call_result = self._user_roles_list(opt, dry_run, &mut err); + }, + ("patch", Some(opt)) => { + call_result = self._user_roles_patch(opt, dry_run, &mut err); + }, + ("update", Some(opt)) => { + call_result = self._user_roles_update(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("user-roles".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, "dfareporting2d6-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: "dfareporting2d6", + 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::Dfareporting::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 upload_value_names = ["mode", "file"]; + let arg_data = [ + ("account-active-ad-summaries", "methods: 'get'", vec![ + ("get", + Some(r##"Gets the account's active ad summary by account ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-active-ad-summaries_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"summary-account-id"##), + None, + Some(r##"Account ID."##), + 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)), + ]), + ]), + + ("account-permission-groups", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one account permission group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-permission-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account permission group ID."##), + 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 account permission groups."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-permission-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("account-permissions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one account permission by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-permissions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account permission ID."##), + 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 account permissions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-permissions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("account-user-profiles", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one account user profile by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-user-profiles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User profile ID."##), + 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##"Inserts a new account user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-user-profiles_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 account user profiles, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-user-profiles_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing account user profile. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-user-profiles_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User profile ID."##), + 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 existing account user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/account-user-profiles_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("accounts", "methods: 'get', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one account by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/accounts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account ID."##), + 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 accounts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/accounts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing account. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/accounts_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Account ID."##), + 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 existing account."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/accounts_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("ads", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one ad by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/ads_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Ad ID."##), + 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##"Inserts a new ad."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/ads_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 ads, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/ads_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing ad. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/ads_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Ad ID."##), + 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 existing ad."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/ads_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("advertiser-groups", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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##"Gets one advertiser group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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##"Inserts a new advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 advertiser groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing advertiser group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser group ID."##), + 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 existing advertiser group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertiser-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("advertisers", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one advertiser by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertisers_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser ID."##), + 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##"Inserts a new advertiser."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertisers_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 advertisers, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertisers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing advertiser. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertisers_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Advertiser ID."##), + 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 existing advertiser."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/advertisers_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("browsers", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of browsers."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/browsers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("campaign-creative-associations", "methods: 'insert' and 'list'", vec![ + ("insert", + Some(r##"Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaign-creative-associations_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Campaign ID in this association."##), + 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 creative IDs associated with the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaign-creative-associations_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Campaign ID in this association."##), + 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)), + ]), + ]), + + ("campaigns", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one campaign by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaigns_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Campaign ID."##), + 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##"Inserts a new campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaigns_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"default-landing-page-name"##), + None, + Some(r##"Default landing page name for this new campaign. Must be less than 256 characters long."##), + Some(true), + Some(false)), + + (Some(r##"default-landing-page-url"##), + None, + Some(r##"Default landing page URL for this new campaign."##), + 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 campaigns, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaigns_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing campaign. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaigns_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Campaign ID."##), + 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 existing campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/campaigns_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("change-logs", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one change log by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/change-logs_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Change log ID."##), + 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 change logs."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/change-logs_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("cities", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of cities, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/cities_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("connection-types", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one connection type by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/connection-types_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Connection type ID."##), + 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 connection types."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/connection-types_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("content-categories", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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##"Gets one content category by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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##"Inserts a new content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 content categories, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing content category. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Content category ID."##), + 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 existing content category."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/content-categories_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("conversions", "methods: 'batchinsert'", vec![ + ("batchinsert", + Some(r##"Inserts conversions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/conversions_batchinsert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("countries", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one country by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/countries_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"dart-id"##), + None, + Some(r##"Country DART ID."##), + 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 countries."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/countries_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creative-assets", "methods: 'insert'", vec![ + ("insert", + Some(r##"Inserts a new creative asset."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-assets_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Advertiser ID of this creative. This is a required field."##), + 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##"mode"##), + Some(r##"u"##), + Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), + 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)), + ]), + ]), + + ("creative-field-values", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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##"Gets one creative field value by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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##"Inserts a new creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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 creative field values, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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 existing creative field value. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field Value ID"##), + 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 existing creative field value."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-field-values_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"creative-field-id"##), + None, + Some(r##"Creative field ID for this creative field value."##), + 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)), + ]), + ]), + + ("creative-fields", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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##"Gets one creative field by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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##"Inserts a new creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creative fields, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative field. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative Field ID"##), + 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 existing creative field."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-fields_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creative-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one creative group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative group ID."##), + 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##"Inserts a new creative group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creative groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative group ID."##), + 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 existing creative group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creative-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("creatives", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one creative by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creatives_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative ID."##), + 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##"Inserts a new creative."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creatives_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 creatives, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creatives_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing creative. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creatives_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Creative ID."##), + 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 existing creative."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/creatives_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("dimension-values", "methods: 'query'", vec![ + ("query", + Some(r##"Retrieves list of report dimension values for a list of filters."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/dimension-values_query", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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)), + ]), + ]), + + ("directory-site-contacts", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one directory site contact by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/directory-site-contacts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Directory site contact ID."##), + 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 directory site contacts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/directory-site-contacts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("directory-sites", "methods: 'get', 'insert' and 'list'", vec![ + ("get", + Some(r##"Gets one directory site by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/directory-sites_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Directory site ID."##), + 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##"Inserts a new directory site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/directory-sites_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 directory sites, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/directory-sites_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("dynamic-targeting-keys", "methods: 'delete', 'insert' and 'list'", vec![ + ("delete", + Some(r##"Deletes an existing dynamic targeting key."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/dynamic-targeting-keys_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"object-id"##), + None, + Some(r##"ID of the object of this dynamic targeting key. This is a required field."##), + Some(true), + Some(false)), + + (Some(r##"name"##), + None, + Some(r##"Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase."##), + Some(true), + Some(false)), + + (Some(r##"object-type"##), + None, + Some(r##"Type of the object of this dynamic targeting key. This is a required field."##), + 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)), + ]), + ("insert", + Some(r##"Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/dynamic-targeting-keys_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 dynamic targeting keys."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/dynamic-targeting-keys_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("event-tags", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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##"Gets one event tag by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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##"Inserts a new event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 event tags, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing event tag. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Event tag ID."##), + 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 existing event tag."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/event-tags_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("files", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Retrieves a report file by its report ID and file ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/files_get", + vec![ + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + Some(true), + Some(false)), + + (Some(r##"file-id"##), + None, + Some(r##"The ID of the report file."##), + 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##"Lists files for a user profile."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/files_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + 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)), + ]), + ]), + + ("floodlight-activities", "methods: 'delete', 'generatetag', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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)), + ]), + ("generatetag", + Some(r##"Generates a tag for a floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_generatetag", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets one floodlight activity by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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##"Inserts a new floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 floodlight activities, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight activity. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity ID."##), + 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 existing floodlight activity."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activities_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("floodlight-activity-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one floodlight activity group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activity-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity Group ID."##), + 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##"Inserts a new floodlight activity group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activity-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 floodlight activity groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activity-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight activity group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activity-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight activity Group ID."##), + 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 existing floodlight activity group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-activity-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("floodlight-configurations", "methods: 'get', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one floodlight configuration by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-configurations_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight configuration ID."##), + 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 floodlight configurations, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-configurations_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing floodlight configuration. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-configurations_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Floodlight configuration ID."##), + 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 existing floodlight configuration."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/floodlight-configurations_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("inventory-items", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one inventory item by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/inventory-items_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Inventory item ID."##), + 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 inventory items, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/inventory-items_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + 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)), + ]), + ]), + + ("landing-pages", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing campaign landing page."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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##"Gets one campaign landing page by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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##"Inserts a new landing page for the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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 landing pages for the specified campaign."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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 existing campaign landing page. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Landing page ID."##), + 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 existing campaign landing page."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/landing-pages_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"campaign-id"##), + None, + Some(r##"Landing page campaign ID."##), + 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)), + ]), + ]), + + ("languages", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of languages."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/languages_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("metros", "methods: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of metros."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/metros_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("mobile-carriers", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one mobile carrier by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/mobile-carriers_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Mobile carrier ID."##), + 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 mobile carriers."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/mobile-carriers_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("operating-system-versions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one operating system version by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/operating-system-versions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Operating system version ID."##), + 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 operating system versions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/operating-system-versions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("operating-systems", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one operating system by DART ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/operating-systems_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"dart-id"##), + None, + Some(r##"Operating system DART ID."##), + 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 operating systems."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/operating-systems_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("order-documents", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one order document by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/order-documents_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Order document ID."##), + 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 order documents, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/order-documents_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for order documents."##), + 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)), + ]), + ]), + + ("orders", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one order by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/orders_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for orders."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Order ID."##), + 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 orders, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/orders_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"project-id"##), + None, + Some(r##"Project ID for orders."##), + 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)), + ]), + ]), + + ("placement-groups", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one placement group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement group ID."##), + 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##"Inserts a new placement group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-groups_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placement groups, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement group. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-groups_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement group ID."##), + 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 existing placement group."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-groups_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("placement-strategies", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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##"Gets one placement strategy by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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##"Inserts a new placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placement strategies, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement strategy. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement strategy ID."##), + 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 existing placement strategy."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placement-strategies_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("placements", "methods: 'generatetags', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("generatetags", + Some(r##"Generates tags for a placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_generatetags", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets one placement by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement ID."##), + 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##"Inserts a new placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 placements, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing placement. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Placement ID."##), + 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 existing placement."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/placements_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("platform-types", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one platform type by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/platform-types_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Platform type ID."##), + 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 platform types."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/platform-types_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("postal-codes", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one postal code by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/postal-codes_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"code"##), + None, + Some(r##"Postal code ID."##), + 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 postal codes."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/postal-codes_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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' and 'list'", vec![ + ("get", + Some(r##"Gets one project by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/projects_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Project ID."##), + 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 projects, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/projects_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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: 'list'", vec![ + ("list", + Some(r##"Retrieves a list of regions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/regions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("remarketing-list-shares", "methods: 'get', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one remarketing list share by remarketing list ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-list-shares_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-list-id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list share. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-list-shares_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"remarketing-list-id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list share."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-list-shares_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("remarketing-lists", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one remarketing list by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-lists_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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##"Inserts a new remarketing list."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-lists_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 remarketing lists, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-lists_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Select only remarketing lists owned by this advertiser."##), + 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 existing remarketing list. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-lists_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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 existing remarketing list."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/remarketing-lists_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("reports", "methods: 'compatible-fields-query', 'delete', 'files-get', 'files-list', 'get', 'insert', 'list', 'patch', 'run' and 'update'", vec![ + ("compatible-fields-query", + Some(r##"Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_compatible-fields-query", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 a report by its ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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)), + ]), + ("files-get", + Some(r##"Retrieves a report file."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_files-get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + Some(true), + Some(false)), + + (Some(r##"file-id"##), + None, + Some(r##"The ID of the report file."##), + 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)), + ]), + ("files-list", + Some(r##"Lists files for a report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_files-list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the parent report."##), + 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##"Retrieves a report by its ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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 report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 list of reports."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + 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 report. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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", + Some(r##"Runs a report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_run", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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 report."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/reports_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The DFA user profile ID."##), + Some(true), + Some(false)), + + (Some(r##"report-id"##), + None, + Some(r##"The ID of the report."##), + 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)), + ]), + ]), + + ("sites", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one site by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sites_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Site ID."##), + 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##"Inserts a new site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sites_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 sites, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sites_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing site. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sites_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Site ID."##), + 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 existing site."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sites_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("sizes", "methods: 'get', 'insert' and 'list'", vec![ + ("get", + Some(r##"Gets one size by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sizes_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Size ID."##), + 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##"Inserts a new size."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sizes_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 sizes, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/sizes_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("subaccounts", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one subaccount by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/subaccounts_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Subaccount ID."##), + 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##"Inserts a new subaccount."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/subaccounts_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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##"Gets a list of subaccounts, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/subaccounts_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing subaccount. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/subaccounts_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Subaccount ID."##), + 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 existing subaccount."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/subaccounts_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("targetable-remarketing-lists", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one remarketing list by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targetable-remarketing-lists_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Remarketing list ID."##), + 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 targetable remarketing lists, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targetable-remarketing-lists_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"advertiser-id"##), + None, + Some(r##"Select only targetable remarketing lists targetable by these advertisers."##), + 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)), + ]), + ]), + + ("targeting-templates", "methods: 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("get", + Some(r##"Gets one targeting template by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targeting-templates_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Targeting template ID."##), + 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##"Inserts a new targeting template."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targeting-templates_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 targeting templates, optionally filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targeting-templates_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing targeting template. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targeting-templates_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"Targeting template ID."##), + 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 existing targeting template."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/targeting-templates_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("user-profiles", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user profile by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-profiles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"The user profile ID."##), + 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 list of user profiles for a user."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-profiles_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)), + ]), + ]), + + ("user-role-permission-groups", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user role permission group by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-role-permission-groups_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role permission group ID."##), + 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##"Gets a list of all supported user role permission groups."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-role-permission-groups_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("user-role-permissions", "methods: 'get' and 'list'", vec![ + ("get", + Some(r##"Gets one user role permission by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-role-permissions_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role permission ID."##), + 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##"Gets a list of user role permissions, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-role-permissions_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ("user-roles", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![ + ("delete", + Some(r##"Deletes an existing user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_delete", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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##"Gets one user role by ID."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_get", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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##"Inserts a new user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_insert", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 user roles, possibly filtered."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_list", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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 existing user role. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_patch", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with this request."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"User role ID."##), + 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 existing user role."##), + "Details at http://byron.github.io/google-apis-rs/google_dfareporting2d6_cli/user-roles_update", + vec![ + (Some(r##"profile-id"##), + None, + Some(r##"User profile ID associated with 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)), + ]), + ]), + + ]; + + let mut app = App::new("dfareporting2d6") + .author("Sebastian Thiel ") + .version("0.3.6+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") + .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); + } + if arg_name_str == "mode" { + arg = arg.number_of_values(2); + arg = arg.value_names(&upload_value_names); + + scmd = scmd.arg(Arg::with_name("mime") + .short("m") + .requires("mode") + .required(false) + .help("The file's mime time, like 'application/octet-stream'") + .takes_value(true)); + } + 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/dfareporting2d6/Cargo.toml b/gen/dfareporting2d6/Cargo.toml new file mode 100644 index 0000000000..3212a97680 --- /dev/null +++ b/gen/dfareporting2d6/Cargo.toml @@ -0,0 +1,34 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-dfareporting2d6" +version = "0.1.14+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" +homepage = "https://developers.google.com/doubleclick-advertisers/" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d6" +license = "MIT" +keywords = ["dfareporting", "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/dfareporting2d6/LICENSE.md b/gen/dfareporting2d6/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/dfareporting2d6/LICENSE.md @@ -0,0 +1,30 @@ + +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/dfareporting2d6/README.md b/gen/dfareporting2d6/README.md new file mode 100644 index 0000000000..130b1c1726 --- /dev/null +++ b/gen/dfareporting2d6/README.md @@ -0,0 +1,312 @@ + +The `google-dfareporting2d6` library allows access to all features of the *Google dfareporting* service. + +This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. + +Everything else about the *dfareporting* *v2d6* API can be found at the +[official documentation site](https://developers.google.com/doubleclick-advertisers/). +# Features + +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Dfareporting.html) ... + +* [account active ad summaries](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountActiveAdSummary.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountActiveAdSummaryGetCall.html) +* [account permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermissionGroupListCall.html) +* [account permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPermissionListCall.html) +* [account user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfileGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfileInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfileListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfilePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUserProfileUpdateCall.html) +* [accounts](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Account.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AccountUpdateCall.html) +* [ads](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Ad.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdUpdateCall.html) +* [advertiser groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroup.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGroupUpdateCall.html) +* [advertisers](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Advertiser.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.AdvertiserUpdateCall.html) +* [browsers](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Browser.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.BrowserListCall.html) +* [campaign creative associations](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignCreativeAssociation.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignCreativeAssociationInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignCreativeAssociationListCall.html) +* [campaigns](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Campaign.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CampaignUpdateCall.html) +* [change logs](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ChangeLog.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ChangeLogGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ChangeLogListCall.html) +* [cities](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.City.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CityListCall.html) +* [connection types](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ConnectionType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ConnectionTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ConnectionTypeListCall.html) +* [content categories](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategory.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ContentCategoryUpdateCall.html) +* [conversions](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Conversion.html) + * [*batchinsert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ConversionBatchinsertCall.html) +* [countries](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Country.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CountryGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CountryListCall.html) +* [creative assets](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeAsset.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeAssetInsertCall.html) +* [creative field values](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValue.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValueDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValueGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValueInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValueListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValuePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldValueUpdateCall.html) +* [creative fields](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeField.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeFieldUpdateCall.html) +* [creative groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGroupUpdateCall.html) +* [creatives](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Creative.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeUpdateCall.html) +* [dimension values](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DimensionValue.html) + * [*query*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DimensionValueQueryCall.html) +* [directory site contacts](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteContact.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteContactGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteContactListCall.html) +* [directory sites](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySite.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DirectorySiteListCall.html) +* [dynamic targeting keys](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DynamicTargetingKey.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DynamicTargetingKeyDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DynamicTargetingKeyInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.DynamicTargetingKeyListCall.html) +* [event tags](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTag.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.EventTagUpdateCall.html) +* [files](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.File.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FileListCall.html) +* [floodlight activities](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivity.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityDeleteCall.html), [*generatetag*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityUpdateCall.html) +* [floodlight activity groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightActivityGroupUpdateCall.html) +* [floodlight configurations](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightConfiguration.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightConfigurationGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightConfigurationListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightConfigurationPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FloodlightConfigurationUpdateCall.html) +* [inventory items](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.InventoryItem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.InventoryItemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.InventoryItemListCall.html) +* [landing pages](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPage.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPageDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPageGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPageInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPageListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPagePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LandingPageUpdateCall.html) +* [languages](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Language.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.LanguageListCall.html) +* [metros](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Metro.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.MetroListCall.html) +* [mobile carriers](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.MobileCarrier.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.MobileCarrierGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.MobileCarrierListCall.html) +* [operating system versions](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystemVersion.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystemVersionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystemVersionListCall.html) +* [operating systems](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OperatingSystemListCall.html) +* [order documents](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OrderDocument.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OrderDocumentGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OrderDocumentListCall.html) +* [orders](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Order.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OrderGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.OrderListCall.html) +* [placement groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGroupUpdateCall.html) +* [placement strategies](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategy.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementStrategyUpdateCall.html) +* [placements](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Placement.html) + * [*generatetags*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlacementUpdateCall.html) +* [platform types](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlatformType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlatformTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PlatformTypeListCall.html) +* [postal codes](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PostalCode.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PostalCodeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.PostalCodeListCall.html) +* [projects](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Project.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ProjectGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ProjectListCall.html) +* [regions](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Region.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RegionListCall.html) +* [remarketing list shares](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListShare.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListShareGetCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListSharePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListShareUpdateCall.html) +* [remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.RemarketingListUpdateCall.html) +* [reports](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Report.html) + * [*compatible fields query*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportCompatibleFieldQueryCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportDeleteCall.html), [*files get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportFileGetCall.html), [*files list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportFileListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportPatchCall.html), [*run*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportRunCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportUpdateCall.html) +* [sites](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Site.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SiteInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SiteListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SitePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SiteUpdateCall.html) +* [sizes](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Size.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SizeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SizeInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SizeListCall.html) +* [subaccounts](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Subaccount.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SubaccountGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SubaccountInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SubaccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SubaccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.SubaccountUpdateCall.html) +* [targetable remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetableRemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetableRemarketingListGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetableRemarketingListListCall.html) +* [targeting templates](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplate.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplateGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplateInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplateListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplatePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.TargetingTemplateUpdateCall.html) +* [user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserProfileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserProfileListCall.html) +* [user role permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermissionGroupListCall.html) +* [user role permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePermissionListCall.html) +* [user roles](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRole.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRoleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRoleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRoleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRoleListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRolePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.UserRoleUpdateCall.html) + + +Upload supported by ... + +* [*insert creative assets*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.CreativeAssetInsertCall.html) + +Download supported by ... + +* [*get files*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.FileGetCall.html) +* [*files get reports*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.ReportFileGetCall.html) + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](http://byron.github.io/google-apis-rs/google_dfareporting2d6/struct.Dfareporting.html)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d6/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_dfareporting2d6/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_dfareporting2d6/trait.Part.html)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](http://byron.github.io/google-apis-rs/google_dfareporting2d6/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.reports().run(...).doit() +let r = hub.reports().get(...).doit() +let r = hub.reports().list(...).doit() +let r = hub.reports().delete(...).doit() +let r = hub.reports().files_list(...).doit() +let r = hub.reports().insert(...).doit() +let r = hub.reports().patch(...).doit() +let r = hub.reports().compatible_fields_query(...).doit() +let r = hub.reports().update(...).doit() +let r = hub.reports().files_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-dfareporting2d6 = "*" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate yup_oauth2 as oauth2; +extern crate google_dfareporting2d6 as dfareporting2d6; +use dfareporting2d6::{Result, Error}; +use std::default::Default; +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +use dfareporting2d6::Dfareporting; + +// 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 = Dfareporting::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.reports().list("profileId") + .sort_order("sit") + .sort_field("Stet") + .scope("sed") + .page_token("et") + .max_results(-18) + .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_dfareporting2d6/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_dfareporting2d6/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2d6/../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_dfareporting2d6/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_dfareporting2d6/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_dfareporting2d6/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_dfareporting2d6/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_dfareporting2d6/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_dfareporting2d6/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_dfareporting2d6/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_dfareporting2d6/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_dfareporting2d6/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_dfareporting2d6/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 **dfareporting2d6** 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/dfareporting2d6/src/build.rs b/gen/dfareporting2d6/src/build.rs new file mode 100644 index 0000000000..0bebaf0bf0 --- /dev/null +++ b/gen/dfareporting2d6/src/build.rs @@ -0,0 +1,25 @@ +#[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/dfareporting2d6/src/cmn.rs b/gen/dfareporting2d6/src/cmn.rs new file mode 100644 index 0000000000..d75063e466 --- /dev/null +++ b/gen/dfareporting2d6/src/cmn.rs @@ -0,0 +1,753 @@ +// 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/dfareporting2d6/src/lib.rs b/gen/dfareporting2d6/src/lib.rs new file mode 100644 index 0000000000..36694f0ca5 --- /dev/null +++ b/gen/dfareporting2d6/src/lib.rs @@ -0,0 +1,322 @@ +// DO NOT EDIT ! +// This file was generated automatically from 'src/mako/api/lib.rs.mako' +// DO NOT EDIT ! + +//! This documentation was generated from *dfareporting* crate version *0.1.14+20160803*, where *20160803* is the exact revision of the *dfareporting:v2.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! +//! Everything else about the *dfareporting* *v2d6* API can be found at the +//! [official documentation site](https://developers.google.com/doubleclick-advertisers/). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d6). +//! # Features +//! +//! Handle the following *Resources* with ease from the central [hub](struct.Dfareporting.html) ... +//! +//! * [account active ad summaries](struct.AccountActiveAdSummary.html) +//! * [*get*](struct.AccountActiveAdSummaryGetCall.html) +//! * [account permission groups](struct.AccountPermissionGroup.html) +//! * [*get*](struct.AccountPermissionGroupGetCall.html) and [*list*](struct.AccountPermissionGroupListCall.html) +//! * [account permissions](struct.AccountPermission.html) +//! * [*get*](struct.AccountPermissionGetCall.html) and [*list*](struct.AccountPermissionListCall.html) +//! * [account user profiles](struct.AccountUserProfile.html) +//! * [*get*](struct.AccountUserProfileGetCall.html), [*insert*](struct.AccountUserProfileInsertCall.html), [*list*](struct.AccountUserProfileListCall.html), [*patch*](struct.AccountUserProfilePatchCall.html) and [*update*](struct.AccountUserProfileUpdateCall.html) +//! * [accounts](struct.Account.html) +//! * [*get*](struct.AccountGetCall.html), [*list*](struct.AccountListCall.html), [*patch*](struct.AccountPatchCall.html) and [*update*](struct.AccountUpdateCall.html) +//! * [ads](struct.Ad.html) +//! * [*get*](struct.AdGetCall.html), [*insert*](struct.AdInsertCall.html), [*list*](struct.AdListCall.html), [*patch*](struct.AdPatchCall.html) and [*update*](struct.AdUpdateCall.html) +//! * [advertiser groups](struct.AdvertiserGroup.html) +//! * [*delete*](struct.AdvertiserGroupDeleteCall.html), [*get*](struct.AdvertiserGroupGetCall.html), [*insert*](struct.AdvertiserGroupInsertCall.html), [*list*](struct.AdvertiserGroupListCall.html), [*patch*](struct.AdvertiserGroupPatchCall.html) and [*update*](struct.AdvertiserGroupUpdateCall.html) +//! * [advertisers](struct.Advertiser.html) +//! * [*get*](struct.AdvertiserGetCall.html), [*insert*](struct.AdvertiserInsertCall.html), [*list*](struct.AdvertiserListCall.html), [*patch*](struct.AdvertiserPatchCall.html) and [*update*](struct.AdvertiserUpdateCall.html) +//! * [browsers](struct.Browser.html) +//! * [*list*](struct.BrowserListCall.html) +//! * [campaign creative associations](struct.CampaignCreativeAssociation.html) +//! * [*insert*](struct.CampaignCreativeAssociationInsertCall.html) and [*list*](struct.CampaignCreativeAssociationListCall.html) +//! * [campaigns](struct.Campaign.html) +//! * [*get*](struct.CampaignGetCall.html), [*insert*](struct.CampaignInsertCall.html), [*list*](struct.CampaignListCall.html), [*patch*](struct.CampaignPatchCall.html) and [*update*](struct.CampaignUpdateCall.html) +//! * [change logs](struct.ChangeLog.html) +//! * [*get*](struct.ChangeLogGetCall.html) and [*list*](struct.ChangeLogListCall.html) +//! * [cities](struct.City.html) +//! * [*list*](struct.CityListCall.html) +//! * [connection types](struct.ConnectionType.html) +//! * [*get*](struct.ConnectionTypeGetCall.html) and [*list*](struct.ConnectionTypeListCall.html) +//! * [content categories](struct.ContentCategory.html) +//! * [*delete*](struct.ContentCategoryDeleteCall.html), [*get*](struct.ContentCategoryGetCall.html), [*insert*](struct.ContentCategoryInsertCall.html), [*list*](struct.ContentCategoryListCall.html), [*patch*](struct.ContentCategoryPatchCall.html) and [*update*](struct.ContentCategoryUpdateCall.html) +//! * [conversions](struct.Conversion.html) +//! * [*batchinsert*](struct.ConversionBatchinsertCall.html) +//! * [countries](struct.Country.html) +//! * [*get*](struct.CountryGetCall.html) and [*list*](struct.CountryListCall.html) +//! * [creative assets](struct.CreativeAsset.html) +//! * [*insert*](struct.CreativeAssetInsertCall.html) +//! * [creative field values](struct.CreativeFieldValue.html) +//! * [*delete*](struct.CreativeFieldValueDeleteCall.html), [*get*](struct.CreativeFieldValueGetCall.html), [*insert*](struct.CreativeFieldValueInsertCall.html), [*list*](struct.CreativeFieldValueListCall.html), [*patch*](struct.CreativeFieldValuePatchCall.html) and [*update*](struct.CreativeFieldValueUpdateCall.html) +//! * [creative fields](struct.CreativeField.html) +//! * [*delete*](struct.CreativeFieldDeleteCall.html), [*get*](struct.CreativeFieldGetCall.html), [*insert*](struct.CreativeFieldInsertCall.html), [*list*](struct.CreativeFieldListCall.html), [*patch*](struct.CreativeFieldPatchCall.html) and [*update*](struct.CreativeFieldUpdateCall.html) +//! * [creative groups](struct.CreativeGroup.html) +//! * [*get*](struct.CreativeGroupGetCall.html), [*insert*](struct.CreativeGroupInsertCall.html), [*list*](struct.CreativeGroupListCall.html), [*patch*](struct.CreativeGroupPatchCall.html) and [*update*](struct.CreativeGroupUpdateCall.html) +//! * [creatives](struct.Creative.html) +//! * [*get*](struct.CreativeGetCall.html), [*insert*](struct.CreativeInsertCall.html), [*list*](struct.CreativeListCall.html), [*patch*](struct.CreativePatchCall.html) and [*update*](struct.CreativeUpdateCall.html) +//! * [dimension values](struct.DimensionValue.html) +//! * [*query*](struct.DimensionValueQueryCall.html) +//! * [directory site contacts](struct.DirectorySiteContact.html) +//! * [*get*](struct.DirectorySiteContactGetCall.html) and [*list*](struct.DirectorySiteContactListCall.html) +//! * [directory sites](struct.DirectorySite.html) +//! * [*get*](struct.DirectorySiteGetCall.html), [*insert*](struct.DirectorySiteInsertCall.html) and [*list*](struct.DirectorySiteListCall.html) +//! * [dynamic targeting keys](struct.DynamicTargetingKey.html) +//! * [*delete*](struct.DynamicTargetingKeyDeleteCall.html), [*insert*](struct.DynamicTargetingKeyInsertCall.html) and [*list*](struct.DynamicTargetingKeyListCall.html) +//! * [event tags](struct.EventTag.html) +//! * [*delete*](struct.EventTagDeleteCall.html), [*get*](struct.EventTagGetCall.html), [*insert*](struct.EventTagInsertCall.html), [*list*](struct.EventTagListCall.html), [*patch*](struct.EventTagPatchCall.html) and [*update*](struct.EventTagUpdateCall.html) +//! * [files](struct.File.html) +//! * [*get*](struct.FileGetCall.html) and [*list*](struct.FileListCall.html) +//! * [floodlight activities](struct.FloodlightActivity.html) +//! * [*delete*](struct.FloodlightActivityDeleteCall.html), [*generatetag*](struct.FloodlightActivityGeneratetagCall.html), [*get*](struct.FloodlightActivityGetCall.html), [*insert*](struct.FloodlightActivityInsertCall.html), [*list*](struct.FloodlightActivityListCall.html), [*patch*](struct.FloodlightActivityPatchCall.html) and [*update*](struct.FloodlightActivityUpdateCall.html) +//! * [floodlight activity groups](struct.FloodlightActivityGroup.html) +//! * [*get*](struct.FloodlightActivityGroupGetCall.html), [*insert*](struct.FloodlightActivityGroupInsertCall.html), [*list*](struct.FloodlightActivityGroupListCall.html), [*patch*](struct.FloodlightActivityGroupPatchCall.html) and [*update*](struct.FloodlightActivityGroupUpdateCall.html) +//! * [floodlight configurations](struct.FloodlightConfiguration.html) +//! * [*get*](struct.FloodlightConfigurationGetCall.html), [*list*](struct.FloodlightConfigurationListCall.html), [*patch*](struct.FloodlightConfigurationPatchCall.html) and [*update*](struct.FloodlightConfigurationUpdateCall.html) +//! * [inventory items](struct.InventoryItem.html) +//! * [*get*](struct.InventoryItemGetCall.html) and [*list*](struct.InventoryItemListCall.html) +//! * [landing pages](struct.LandingPage.html) +//! * [*delete*](struct.LandingPageDeleteCall.html), [*get*](struct.LandingPageGetCall.html), [*insert*](struct.LandingPageInsertCall.html), [*list*](struct.LandingPageListCall.html), [*patch*](struct.LandingPagePatchCall.html) and [*update*](struct.LandingPageUpdateCall.html) +//! * [languages](struct.Language.html) +//! * [*list*](struct.LanguageListCall.html) +//! * [metros](struct.Metro.html) +//! * [*list*](struct.MetroListCall.html) +//! * [mobile carriers](struct.MobileCarrier.html) +//! * [*get*](struct.MobileCarrierGetCall.html) and [*list*](struct.MobileCarrierListCall.html) +//! * [operating system versions](struct.OperatingSystemVersion.html) +//! * [*get*](struct.OperatingSystemVersionGetCall.html) and [*list*](struct.OperatingSystemVersionListCall.html) +//! * [operating systems](struct.OperatingSystem.html) +//! * [*get*](struct.OperatingSystemGetCall.html) and [*list*](struct.OperatingSystemListCall.html) +//! * [order documents](struct.OrderDocument.html) +//! * [*get*](struct.OrderDocumentGetCall.html) and [*list*](struct.OrderDocumentListCall.html) +//! * [orders](struct.Order.html) +//! * [*get*](struct.OrderGetCall.html) and [*list*](struct.OrderListCall.html) +//! * [placement groups](struct.PlacementGroup.html) +//! * [*get*](struct.PlacementGroupGetCall.html), [*insert*](struct.PlacementGroupInsertCall.html), [*list*](struct.PlacementGroupListCall.html), [*patch*](struct.PlacementGroupPatchCall.html) and [*update*](struct.PlacementGroupUpdateCall.html) +//! * [placement strategies](struct.PlacementStrategy.html) +//! * [*delete*](struct.PlacementStrategyDeleteCall.html), [*get*](struct.PlacementStrategyGetCall.html), [*insert*](struct.PlacementStrategyInsertCall.html), [*list*](struct.PlacementStrategyListCall.html), [*patch*](struct.PlacementStrategyPatchCall.html) and [*update*](struct.PlacementStrategyUpdateCall.html) +//! * [placements](struct.Placement.html) +//! * [*generatetags*](struct.PlacementGeneratetagCall.html), [*get*](struct.PlacementGetCall.html), [*insert*](struct.PlacementInsertCall.html), [*list*](struct.PlacementListCall.html), [*patch*](struct.PlacementPatchCall.html) and [*update*](struct.PlacementUpdateCall.html) +//! * [platform types](struct.PlatformType.html) +//! * [*get*](struct.PlatformTypeGetCall.html) and [*list*](struct.PlatformTypeListCall.html) +//! * [postal codes](struct.PostalCode.html) +//! * [*get*](struct.PostalCodeGetCall.html) and [*list*](struct.PostalCodeListCall.html) +//! * [projects](struct.Project.html) +//! * [*get*](struct.ProjectGetCall.html) and [*list*](struct.ProjectListCall.html) +//! * [regions](struct.Region.html) +//! * [*list*](struct.RegionListCall.html) +//! * [remarketing list shares](struct.RemarketingListShare.html) +//! * [*get*](struct.RemarketingListShareGetCall.html), [*patch*](struct.RemarketingListSharePatchCall.html) and [*update*](struct.RemarketingListShareUpdateCall.html) +//! * [remarketing lists](struct.RemarketingList.html) +//! * [*get*](struct.RemarketingListGetCall.html), [*insert*](struct.RemarketingListInsertCall.html), [*list*](struct.RemarketingListListCall.html), [*patch*](struct.RemarketingListPatchCall.html) and [*update*](struct.RemarketingListUpdateCall.html) +//! * [reports](struct.Report.html) +//! * [*compatible fields query*](struct.ReportCompatibleFieldQueryCall.html), [*delete*](struct.ReportDeleteCall.html), [*files get*](struct.ReportFileGetCall.html), [*files list*](struct.ReportFileListCall.html), [*get*](struct.ReportGetCall.html), [*insert*](struct.ReportInsertCall.html), [*list*](struct.ReportListCall.html), [*patch*](struct.ReportPatchCall.html), [*run*](struct.ReportRunCall.html) and [*update*](struct.ReportUpdateCall.html) +//! * [sites](struct.Site.html) +//! * [*get*](struct.SiteGetCall.html), [*insert*](struct.SiteInsertCall.html), [*list*](struct.SiteListCall.html), [*patch*](struct.SitePatchCall.html) and [*update*](struct.SiteUpdateCall.html) +//! * [sizes](struct.Size.html) +//! * [*get*](struct.SizeGetCall.html), [*insert*](struct.SizeInsertCall.html) and [*list*](struct.SizeListCall.html) +//! * [subaccounts](struct.Subaccount.html) +//! * [*get*](struct.SubaccountGetCall.html), [*insert*](struct.SubaccountInsertCall.html), [*list*](struct.SubaccountListCall.html), [*patch*](struct.SubaccountPatchCall.html) and [*update*](struct.SubaccountUpdateCall.html) +//! * [targetable remarketing lists](struct.TargetableRemarketingList.html) +//! * [*get*](struct.TargetableRemarketingListGetCall.html) and [*list*](struct.TargetableRemarketingListListCall.html) +//! * [targeting templates](struct.TargetingTemplate.html) +//! * [*get*](struct.TargetingTemplateGetCall.html), [*insert*](struct.TargetingTemplateInsertCall.html), [*list*](struct.TargetingTemplateListCall.html), [*patch*](struct.TargetingTemplatePatchCall.html) and [*update*](struct.TargetingTemplateUpdateCall.html) +//! * [user profiles](struct.UserProfile.html) +//! * [*get*](struct.UserProfileGetCall.html) and [*list*](struct.UserProfileListCall.html) +//! * [user role permission groups](struct.UserRolePermissionGroup.html) +//! * [*get*](struct.UserRolePermissionGroupGetCall.html) and [*list*](struct.UserRolePermissionGroupListCall.html) +//! * [user role permissions](struct.UserRolePermission.html) +//! * [*get*](struct.UserRolePermissionGetCall.html) and [*list*](struct.UserRolePermissionListCall.html) +//! * [user roles](struct.UserRole.html) +//! * [*delete*](struct.UserRoleDeleteCall.html), [*get*](struct.UserRoleGetCall.html), [*insert*](struct.UserRoleInsertCall.html), [*list*](struct.UserRoleListCall.html), [*patch*](struct.UserRolePatchCall.html) and [*update*](struct.UserRoleUpdateCall.html) +//! +//! +//! Upload supported by ... +//! +//! * [*insert creative assets*](struct.CreativeAssetInsertCall.html) +//! +//! Download supported by ... +//! +//! * [*get files*](struct.FileGetCall.html) +//! * [*files get reports*](struct.ReportFileGetCall.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.Dfareporting.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.reports().run(...).doit() +//! let r = hub.reports().get(...).doit() +//! let r = hub.reports().list(...).doit() +//! let r = hub.reports().delete(...).doit() +//! let r = hub.reports().files_list(...).doit() +//! let r = hub.reports().insert(...).doit() +//! let r = hub.reports().patch(...).doit() +//! let r = hub.reports().compatible_fields_query(...).doit() +//! let r = hub.reports().update(...).doit() +//! let r = hub.reports().files_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-dfareporting2d6 = "*" +//! ``` +//! +//! ## A complete example +//! +//! ```test_harness,no_run +//! extern crate hyper; +//! extern crate yup_oauth2 as oauth2; +//! extern crate google_dfareporting2d6 as dfareporting2d6; +//! use dfareporting2d6::{Result, Error}; +//! # #[test] fn egal() { +//! use std::default::Default; +//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +//! use dfareporting2d6::Dfareporting; +//! +//! // 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 = Dfareporting::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.reports().list("profileId") +//! .sort_order("dolor") +//! .sort_field("et") +//! .scope("ipsum") +//! .page_token("gubergren") +//! .max_results(-32) +//! .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/dfareporting2d6/src/lib.rs.in b/gen/dfareporting2d6/src/lib.rs.in new file mode 100644 index 0000000000..41f0d34b26 --- /dev/null +++ b/gen/dfareporting2d6/src/lib.rs.in @@ -0,0 +1,69482 @@ +// 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 DoubleClick Campaign Manager's (DCM) display ad campaigns + Dfatrafficking, + + /// View and manage DoubleClick for Advertisers reports + Full, + + /// Manage DoubleClick Digital Marketing conversions + Ddmconversion, +} + +impl AsRef for Scope { + fn as_ref(&self) -> &str { + match *self { + Scope::Dfatrafficking => "https://www.googleapis.com/auth/dfatrafficking", + Scope::Full => "https://www.googleapis.com/auth/dfareporting", + Scope::Ddmconversion => "https://www.googleapis.com/auth/ddmconversions", + } + } +} + +impl Default for Scope { + fn default() -> Scope { + Scope::Full + } +} + + + +// ######## +// HUB ### +// ###### + +/// Central instance to access all Dfareporting related resource activities +/// +/// # Examples +/// +/// Instantiate a new hub +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::{Result, Error}; +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// // 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 = Dfareporting::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.reports().list("profileId") +/// .sort_order("accusam") +/// .sort_field("takimata") +/// .scope("justo") +/// .page_token("amet.") +/// .max_results(-81) +/// .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 Dfareporting { + client: RefCell, + auth: RefCell, + _user_agent: String, +} + +impl<'a, C, A> Hub for Dfareporting {} + +impl<'a, C, A> Dfareporting + where C: BorrowMut, A: oauth2::GetToken { + + pub fn new(client: C, authenticator: A) -> Dfareporting { + Dfareporting { + client: RefCell::new(client), + auth: RefCell::new(authenticator), + _user_agent: "google-api-rust-client/0.1.14".to_string(), + } + } + + pub fn account_active_ad_summaries(&'a self) -> AccountActiveAdSummaryMethods<'a, C, A> { + AccountActiveAdSummaryMethods { hub: &self } + } + pub fn account_permission_groups(&'a self) -> AccountPermissionGroupMethods<'a, C, A> { + AccountPermissionGroupMethods { hub: &self } + } + pub fn account_permissions(&'a self) -> AccountPermissionMethods<'a, C, A> { + AccountPermissionMethods { hub: &self } + } + pub fn account_user_profiles(&'a self) -> AccountUserProfileMethods<'a, C, A> { + AccountUserProfileMethods { hub: &self } + } + pub fn accounts(&'a self) -> AccountMethods<'a, C, A> { + AccountMethods { hub: &self } + } + pub fn ads(&'a self) -> AdMethods<'a, C, A> { + AdMethods { hub: &self } + } + pub fn advertiser_groups(&'a self) -> AdvertiserGroupMethods<'a, C, A> { + AdvertiserGroupMethods { hub: &self } + } + pub fn advertisers(&'a self) -> AdvertiserMethods<'a, C, A> { + AdvertiserMethods { hub: &self } + } + pub fn browsers(&'a self) -> BrowserMethods<'a, C, A> { + BrowserMethods { hub: &self } + } + pub fn campaign_creative_associations(&'a self) -> CampaignCreativeAssociationMethods<'a, C, A> { + CampaignCreativeAssociationMethods { hub: &self } + } + pub fn campaigns(&'a self) -> CampaignMethods<'a, C, A> { + CampaignMethods { hub: &self } + } + pub fn change_logs(&'a self) -> ChangeLogMethods<'a, C, A> { + ChangeLogMethods { hub: &self } + } + pub fn cities(&'a self) -> CityMethods<'a, C, A> { + CityMethods { hub: &self } + } + pub fn connection_types(&'a self) -> ConnectionTypeMethods<'a, C, A> { + ConnectionTypeMethods { hub: &self } + } + pub fn content_categories(&'a self) -> ContentCategoryMethods<'a, C, A> { + ContentCategoryMethods { hub: &self } + } + pub fn conversions(&'a self) -> ConversionMethods<'a, C, A> { + ConversionMethods { hub: &self } + } + pub fn countries(&'a self) -> CountryMethods<'a, C, A> { + CountryMethods { hub: &self } + } + pub fn creative_assets(&'a self) -> CreativeAssetMethods<'a, C, A> { + CreativeAssetMethods { hub: &self } + } + pub fn creative_field_values(&'a self) -> CreativeFieldValueMethods<'a, C, A> { + CreativeFieldValueMethods { hub: &self } + } + pub fn creative_fields(&'a self) -> CreativeFieldMethods<'a, C, A> { + CreativeFieldMethods { hub: &self } + } + pub fn creative_groups(&'a self) -> CreativeGroupMethods<'a, C, A> { + CreativeGroupMethods { hub: &self } + } + pub fn creatives(&'a self) -> CreativeMethods<'a, C, A> { + CreativeMethods { hub: &self } + } + pub fn dimension_values(&'a self) -> DimensionValueMethods<'a, C, A> { + DimensionValueMethods { hub: &self } + } + pub fn directory_site_contacts(&'a self) -> DirectorySiteContactMethods<'a, C, A> { + DirectorySiteContactMethods { hub: &self } + } + pub fn directory_sites(&'a self) -> DirectorySiteMethods<'a, C, A> { + DirectorySiteMethods { hub: &self } + } + pub fn dynamic_targeting_keys(&'a self) -> DynamicTargetingKeyMethods<'a, C, A> { + DynamicTargetingKeyMethods { hub: &self } + } + pub fn event_tags(&'a self) -> EventTagMethods<'a, C, A> { + EventTagMethods { hub: &self } + } + pub fn files(&'a self) -> FileMethods<'a, C, A> { + FileMethods { hub: &self } + } + pub fn floodlight_activities(&'a self) -> FloodlightActivityMethods<'a, C, A> { + FloodlightActivityMethods { hub: &self } + } + pub fn floodlight_activity_groups(&'a self) -> FloodlightActivityGroupMethods<'a, C, A> { + FloodlightActivityGroupMethods { hub: &self } + } + pub fn floodlight_configurations(&'a self) -> FloodlightConfigurationMethods<'a, C, A> { + FloodlightConfigurationMethods { hub: &self } + } + pub fn inventory_items(&'a self) -> InventoryItemMethods<'a, C, A> { + InventoryItemMethods { hub: &self } + } + pub fn landing_pages(&'a self) -> LandingPageMethods<'a, C, A> { + LandingPageMethods { hub: &self } + } + pub fn languages(&'a self) -> LanguageMethods<'a, C, A> { + LanguageMethods { hub: &self } + } + pub fn metros(&'a self) -> MetroMethods<'a, C, A> { + MetroMethods { hub: &self } + } + pub fn mobile_carriers(&'a self) -> MobileCarrierMethods<'a, C, A> { + MobileCarrierMethods { hub: &self } + } + pub fn operating_system_versions(&'a self) -> OperatingSystemVersionMethods<'a, C, A> { + OperatingSystemVersionMethods { hub: &self } + } + pub fn operating_systems(&'a self) -> OperatingSystemMethods<'a, C, A> { + OperatingSystemMethods { hub: &self } + } + pub fn order_documents(&'a self) -> OrderDocumentMethods<'a, C, A> { + OrderDocumentMethods { hub: &self } + } + pub fn orders(&'a self) -> OrderMethods<'a, C, A> { + OrderMethods { hub: &self } + } + pub fn placement_groups(&'a self) -> PlacementGroupMethods<'a, C, A> { + PlacementGroupMethods { hub: &self } + } + pub fn placement_strategies(&'a self) -> PlacementStrategyMethods<'a, C, A> { + PlacementStrategyMethods { hub: &self } + } + pub fn placements(&'a self) -> PlacementMethods<'a, C, A> { + PlacementMethods { hub: &self } + } + pub fn platform_types(&'a self) -> PlatformTypeMethods<'a, C, A> { + PlatformTypeMethods { hub: &self } + } + pub fn postal_codes(&'a self) -> PostalCodeMethods<'a, C, A> { + PostalCodeMethods { hub: &self } + } + pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { + ProjectMethods { hub: &self } + } + pub fn regions(&'a self) -> RegionMethods<'a, C, A> { + RegionMethods { hub: &self } + } + pub fn remarketing_list_shares(&'a self) -> RemarketingListShareMethods<'a, C, A> { + RemarketingListShareMethods { hub: &self } + } + pub fn remarketing_lists(&'a self) -> RemarketingListMethods<'a, C, A> { + RemarketingListMethods { hub: &self } + } + pub fn reports(&'a self) -> ReportMethods<'a, C, A> { + ReportMethods { hub: &self } + } + pub fn sites(&'a self) -> SiteMethods<'a, C, A> { + SiteMethods { hub: &self } + } + pub fn sizes(&'a self) -> SizeMethods<'a, C, A> { + SizeMethods { hub: &self } + } + pub fn subaccounts(&'a self) -> SubaccountMethods<'a, C, A> { + SubaccountMethods { hub: &self } + } + pub fn targetable_remarketing_lists(&'a self) -> TargetableRemarketingListMethods<'a, C, A> { + TargetableRemarketingListMethods { hub: &self } + } + pub fn targeting_templates(&'a self) -> TargetingTemplateMethods<'a, C, A> { + TargetingTemplateMethods { hub: &self } + } + pub fn user_profiles(&'a self) -> UserProfileMethods<'a, C, A> { + UserProfileMethods { hub: &self } + } + pub fn user_role_permission_groups(&'a self) -> UserRolePermissionGroupMethods<'a, C, A> { + UserRolePermissionGroupMethods { hub: &self } + } + pub fn user_role_permissions(&'a self) -> UserRolePermissionMethods<'a, C, A> { + UserRolePermissionMethods { hub: &self } + } + pub fn user_roles(&'a self) -> UserRoleMethods<'a, C, A> { + UserRoleMethods { 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 ### +// ########## +/// Operating System List Response +/// +/// # 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 operating systems](struct.OperatingSystemListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemsListResponse". + pub kind: Option, + /// Operating system collection. + #[serde(rename="operatingSystems")] + pub operating_systems: Option>, +} + +impl ResponseResult for OperatingSystemsListResponse {} + + +/// A Conversion represents when a user successfully performs a desired action after seeing an ad. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Conversion { + /// The ordinal of the conversion. Use this field to control how conversions of the same user and day are de-duplicated. This is a required field. + pub ordinal: Option, + /// The timestamp of conversion, in Unix epoch micros. This is a required field. + #[serde(rename="timestampMicros")] + pub timestamp_micros: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversion". + pub kind: Option, + /// Whether the conversion was directed toward children. + #[serde(rename="childDirectedTreatment")] + pub child_directed_treatment: Option, + /// The alphanumeric encrypted user ID. When set, encryptionInfo should also be specified. This field is mutually exclusive with encryptedUserIdCandidates[] and mobileDeviceId. This or encryptedUserIdCandidates[] or mobileDeviceId is a required field. + #[serde(rename="encryptedUserId")] + pub encrypted_user_id: Option, + /// Custom floodlight variables. + #[serde(rename="customVariables")] + pub custom_variables: Option>, + /// Floodlight Configuration ID of this conversion. This is a required field. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// A list of the alphanumeric encrypted user IDs. Any user ID with exposure prior to the conversion timestamp will be used in the inserted conversion. If no such user ID is found then the conversion will be rejected with NO_COOKIE_MATCH_FOUND error. When set, encryptionInfo should also be specified. This field should only be used when calling conversions.batchinsert. This field is mutually exclusive with encryptedUserId and mobileDeviceId. This or encryptedUserId or mobileDeviceId is a required field. + #[serde(rename="encryptedUserIdCandidates")] + pub encrypted_user_id_candidates: Option>, + /// The value of the conversion. + pub value: Option, + /// Whether the user has Limit Ad Tracking set. + #[serde(rename="limitAdTracking")] + pub limit_ad_tracking: Option, + /// The quantity of the conversion. + pub quantity: Option, + /// Floodlight Activity ID of this conversion. This is a required field. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// The mobile device ID. This field is mutually exclusive with encryptedUserId and encryptedUserIdCandidates[]. This or encryptedUserId or encryptedUserIdCandidates[] is a required field. + #[serde(rename="mobileDeviceId")] + pub mobile_device_id: Option, +} + +impl Resource for Conversion {} + + +/// Contains information about a mobile carrier that can be targeted by ads. +/// +/// # 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 mobile carriers](struct.MobileCarrierListCall.html) (none) +/// * [get mobile carriers](struct.MobileCarrierGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MobileCarrier { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarrier". + pub kind: Option, + /// DART ID of the country to which this mobile carrier belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// ID of this mobile carrier. + pub id: Option, + /// Country code of the country to which this mobile carrier belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Name of this mobile carrier. + pub name: Option, +} + +impl Resource for MobileCarrier {} +impl ResponseResult for MobileCarrier {} + + +/// Contains properties of a DCM subaccount. +/// +/// # 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 subaccounts](struct.SubaccountGetCall.html) (response) +/// * [update subaccounts](struct.SubaccountUpdateCall.html) (request|response) +/// * [patch subaccounts](struct.SubaccountPatchCall.html) (request|response) +/// * [list subaccounts](struct.SubaccountListCall.html) (none) +/// * [insert subaccounts](struct.SubaccountInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Subaccount { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccount". + pub kind: Option, + /// ID of the account that contains this subaccount. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// IDs of the available user role permissions for this subaccount. + #[serde(rename="availablePermissionIds")] + pub available_permission_ids: Option>, + /// ID of this subaccount. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this subaccount. This is a required field. Must be less than 128 characters long and be unique among subaccounts of the same account. + pub name: Option, +} + +impl RequestValue for Subaccount {} +impl Resource for Subaccount {} +impl ResponseResult for Subaccount {} + + +/// AccountPermissionGroups contains a mapping of permission group IDs to names. A permission group is a grouping of account permissions. +/// +/// # 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 account permission groups](struct.AccountPermissionGroupListCall.html) (none) +/// * [get account permission groups](struct.AccountPermissionGroupGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroup". + pub kind: Option, + /// ID of this account permission group. + pub id: Option, + /// Name of this account permission group. + pub name: Option, +} + +impl Resource for AccountPermissionGroup {} +impl ResponseResult for AccountPermissionGroup {} + + +/// Represents the list of DimensionValue 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValueList { + /// Continuation token used to page through dimension values. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The dimension values returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#dimensionValueList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for DimensionValueList {} + + +/// Campaign Creative Association List Response +/// +/// # 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 campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignCreativeAssociationsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Campaign creative association collection + #[serde(rename="campaignCreativeAssociations")] + pub campaign_creative_associations: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociationsListResponse". + pub kind: Option, +} + +impl ResponseResult for CampaignCreativeAssociationsListResponse {} + + +/// Directory Site Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteSettings { + /// Whether this site accepts interstitial ads. + #[serde(rename="interstitialPlacementAccepted")] + pub interstitial_placement_accepted: Option, + /// Whether this directory site has disabled Nielsen OCR reach ratings. + #[serde(rename="nielsenOcrOptOut")] + pub nielsen_ocr_opt_out: Option, + /// Whether this directory site has disabled active view creatives. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Whether this directory site has disabled active view for in-stream video creatives. + #[serde(rename="videoActiveViewOptOut")] + pub video_active_view_opt_out: Option, + /// Directory site DFP settings. + pub dfp_settings: Option, + /// Whether this directory site has disabled generation of Verification ins tags. + #[serde(rename="verificationTagOptOut")] + pub verification_tag_opt_out: Option, + /// Whether this site accepts in-stream video ads. + pub instream_video_placement_accepted: Option, +} + +impl Part for DirectorySiteSettings {} + + +/// User Role Permission Group List Response +/// +/// # 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 user role permission groups](struct.UserRolePermissionGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionGroupsListResponse { + /// User role permission group collection. + #[serde(rename="userRolePermissionGroups")] + pub user_role_permission_groups: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse". + pub kind: Option, +} + +impl ResponseResult for UserRolePermissionGroupsListResponse {} + + +/// Represents the list of File 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 files](struct.FileListCall.html) (response) +/// * [files list reports](struct.ReportFileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FileList { + /// Continuation token used to page through files. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The files returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#fileList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for FileList {} + + +/// Represents a Custom Rich Media Events group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CustomRichMediaEvents { + /// The kind of resource this is, in this case dfareporting#customRichMediaEvents. + pub kind: Option, + /// List of custom rich media event IDs. Dimension values must be all of type dfa:richMediaEventTypeIdAndName. + #[serde(rename="filteredEventIds")] + pub filtered_event_ids: Option>, +} + +impl Part for CustomRichMediaEvents {} + + +/// Event tag override information. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTagOverride { + /// Whether this override is enabled. + pub enabled: Option, + /// ID of this event tag override. This is a read-only, auto-generated field. + pub id: Option, +} + +impl Part for EventTagOverride {} + + +/// Change Log List Response +/// +/// # 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 change logs](struct.ChangeLogListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChangeLogsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLogsListResponse". + pub kind: Option, + /// Change log collection. + #[serde(rename="changeLogs")] + pub change_logs: Option>, +} + +impl ResponseResult for ChangeLogsListResponse {} + + +/// Gets a summary of active ads in an account. +/// +/// # 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 account active ad summaries](struct.AccountActiveAdSummaryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountActiveAdSummary { + /// Ads that can be activated for the account. + #[serde(rename="availableAds")] + pub available_ads: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountActiveAdSummary". + pub kind: Option, + /// ID of the account. + #[serde(rename="accountId")] + pub account_id: Option, + /// Ads that have been activated for the account + #[serde(rename="activeAds")] + pub active_ads: Option, + /// Maximum number of active ads allowed for the account. + #[serde(rename="activeAdsLimitTier")] + pub active_ads_limit_tier: Option, +} + +impl ResponseResult for AccountActiveAdSummary {} + + +/// Lookback configuration settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LookbackConfiguration { + /// Lookback window, in days, from the last time a given user clicked on one of your ads. If you enter 0, clicks will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. + #[serde(rename="clickDuration")] + pub click_duration: Option, + /// Lookback window, in days, from the last time a given user viewed one of your ads. If you enter 0, impressions will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. + #[serde(rename="postImpressionActivitiesDuration")] + pub post_impression_activities_duration: Option, +} + +impl Part for LookbackConfiguration {} + + +/// Floodlight Activity GenerateTag Response +/// +/// # 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*). +/// +/// * [generatetag floodlight activities](struct.FloodlightActivityGeneratetagCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivitiesGenerateTagResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesGenerateTagResponse". + pub kind: Option, + /// Generated tag for this floodlight activity. + #[serde(rename="floodlightActivityTag")] + pub floodlight_activity_tag: Option, +} + +impl ResponseResult for FloodlightActivitiesGenerateTagResponse {} + + +/// Remarketing List Population Rule Term. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationTerm { + /// ID of the list in question. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option, + /// Will be true if the term should check if the user is in the list and false if the term should check if the user is not in the list. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. False by default. + pub contains: Option, + /// Whether to negate the comparison result of this term during rule evaluation. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub negation: Option, + /// Literal to compare the variable to. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub value: Option, + /// Friendly name of this term's variable. This is a read-only, auto-generated field. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM. + #[serde(rename="variableFriendlyName")] + pub variable_friendly_name: Option, + /// Comparison operator of this term. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub operator: Option, + /// List population term type determines the applicable fields in this object. If left unset or set to CUSTOM_VARIABLE_TERM, then variableName, variableFriendlyName, operator, value, and negation are applicable. If set to LIST_MEMBERSHIP_TERM then remarketingListId and contains are applicable. If set to REFERRER_TERM then operator, value, and negation are applicable. + #[serde(rename="type")] + pub type_: Option, + /// Name of the variable (U1, U2, etc.) being compared in this term. This field is only relevant when type is set to null, CUSTOM_VARIABLE_TERM or REFERRER_TERM. + #[serde(rename="variableName")] + pub variable_name: Option, +} + +impl Part for ListPopulationTerm {} + + +/// Site Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SiteSettings { + /// Whether brand safe ads are disabled for this site. + #[serde(rename="disableBrandSafeAds")] + pub disable_brand_safe_ads: Option, + /// Site-wide creative settings. + #[serde(rename="creativeSettings")] + pub creative_settings: Option, + /// Whether active view creatives are disabled for this site. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Lookback window settings for this site. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Whether new cookies are disabled for this site. + #[serde(rename="disableNewCookie")] + pub disable_new_cookie: Option, + /// Whether Verification and ActiveView are disabled for in-stream video creatives on this site. The same setting videoActiveViewOptOut exists on the directory site level -- the opt out occurs if either of these settings are true. These settings are distinct from DirectorySites.settings.activeViewOptOut or Sites.siteSettings.activeViewOptOut which only apply to display ads. However, Accounts.activeViewOptOut opts out both video traffic, as well as display ads, from Verification and ActiveView. + #[serde(rename="videoActiveViewOptOut")] + pub video_active_view_opt_out: Option, + /// Configuration settings for dynamic and image floodlight tags. + #[serde(rename="tagSetting")] + pub tag_setting: Option, +} + +impl Part for SiteSettings {} + + +/// AccountUserProfiles contains properties of a DCM user profile. This resource is specifically for managing user profiles, whereas UserProfiles is for accessing the API. +/// +/// # 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 account user profiles](struct.AccountUserProfilePatchCall.html) (request|response) +/// * [list account user profiles](struct.AccountUserProfileListCall.html) (none) +/// * [insert account user profiles](struct.AccountUserProfileInsertCall.html) (request|response) +/// * [get account user profiles](struct.AccountUserProfileGetCall.html) (response) +/// * [update account user profiles](struct.AccountUserProfileUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountUserProfile { + /// Locale of the user profile. This is a required field. + /// Acceptable values are: + /// - "cs" (Czech) + /// - "de" (German) + /// - "en" (English) + /// - "en-GB" (English United Kingdom) + /// - "es" (Spanish) + /// - "fr" (French) + /// - "it" (Italian) + /// - "ja" (Japanese) + /// - "ko" (Korean) + /// - "pl" (Polish) + /// - "pt-BR" (Portuguese Brazil) + /// - "ru" (Russian) + /// - "sv" (Swedish) + /// - "tr" (Turkish) + /// - "zh-CN" (Chinese Simplified) + /// - "zh-TW" (Chinese Traditional) + pub locale: Option, + /// Filter that describes which sites are visible to the user profile. + #[serde(rename="siteFilter")] + pub site_filter: Option, + /// Filter that describes which campaigns are visible to the user profile. + #[serde(rename="campaignFilter")] + pub campaign_filter: Option, + /// User role ID of the user profile. This is a required field. + #[serde(rename="userRoleId")] + pub user_role_id: Option, + /// User type of the user profile. This is a read-only field that can be left blank. + #[serde(rename="userAccessType")] + pub user_access_type: Option, + /// Whether this user profile is active. This defaults to false, and must be set true on insert for the user profile to be usable. + pub active: Option, + /// ID of the user profile. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of the user profile. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfile". + pub kind: Option, + /// Subaccount ID of the user profile. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Filter that describes which user roles are visible to the user profile. + #[serde(rename="userRoleFilter")] + pub user_role_filter: Option, + /// Trafficker type of this user profile. + #[serde(rename="traffickerType")] + pub trafficker_type: Option, + /// Comments for this user profile. + pub comments: Option, + /// Name of the user profile. This is a required field. Must be less than 64 characters long, must be globally unique, and cannot contain whitespace or any of the following characters: "&;"#%,". + pub name: Option, + /// Filter that describes which advertisers are visible to the user profile. + #[serde(rename="advertiserFilter")] + pub advertiser_filter: Option, + /// Email of the user profile. The email addresss must be linked to a Google Account. This field is required on insertion and is read-only after insertion. + pub email: Option, +} + +impl RequestValue for AccountUserProfile {} +impl Resource for AccountUserProfile {} +impl ResponseResult for AccountUserProfile {} + + +/// Dynamic and Image Tag Settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagSettings { + /// Whether dynamic floodlight tags are enabled. + #[serde(rename="dynamicTagEnabled")] + pub dynamic_tag_enabled: Option, + /// Whether image tags are enabled. + #[serde(rename="imageTagEnabled")] + pub image_tag_enabled: Option, +} + +impl Part for TagSettings {} + + +/// Contains properties of a targetable remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource is a read-only view of a remarketing list to be used to faciliate targeting ads to specific lists. Remarketing lists that are owned by your advertisers and those that are shared to your advertisers or account are accessible via this resource. To manage remarketing lists that are owned by your advertisers, use the RemarketingLists 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 targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (none) +/// * [get targetable remarketing lists](struct.TargetableRemarketingListGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingList { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingList". + pub kind: Option, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Targetable remarketing list description. + pub description: Option, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option, + /// Number of days that a user should remain in the targetable remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option, + /// Dimension value for the advertiser ID that owns this targetable remarketing list. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Product from which this targetable remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option, + /// Whether this targetable remarketing list is active. + pub active: Option, + /// Dimension value for the ID of the advertiser. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option, + /// Targetable remarketing list ID. + pub id: Option, + /// Name of the targetable remarketing list. Is no greater than 128 characters long. + pub name: Option, +} + +impl Resource for TargetableRemarketingList {} +impl ResponseResult for TargetableRemarketingList {} + + +/// Contains information about a particular version of an operating system that can be targeted by ads. +/// +/// # 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 operating system versions](struct.OperatingSystemVersionGetCall.html) (response) +/// * [list operating system versions](struct.OperatingSystemVersionListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemVersion { + /// Major version (leftmost number) of this operating system version. + #[serde(rename="majorVersion")] + pub major_version: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersion". + pub kind: Option, + /// Minor version (number after the first dot) of this operating system version. + #[serde(rename="minorVersion")] + pub minor_version: Option, + /// Name of this operating system version. + pub name: Option, + /// Operating system of this operating system version. + #[serde(rename="operatingSystem")] + pub operating_system: Option, + /// ID of this operating system version. + pub id: Option, +} + +impl Resource for OperatingSystemVersion {} +impl ResponseResult for OperatingSystemVersion {} + + +/// Remarketing list response +/// +/// # 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 remarketing lists](struct.RemarketingListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Remarketing list collection. + #[serde(rename="remarketingLists")] + pub remarketing_lists: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListsListResponse". + pub kind: Option, +} + +impl ResponseResult for RemarketingListsListResponse {} + + +/// Creative Field Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldAssignment { + /// ID of the creative field. + #[serde(rename="creativeFieldId")] + pub creative_field_id: Option, + /// ID of the creative field value. + #[serde(rename="creativeFieldValueId")] + pub creative_field_value_id: Option, +} + +impl Part for CreativeFieldAssignment {} + + +/// Remarketing List Population Rule. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationRule { + /// Floodlight activity ID associated with this rule. This field can be left blank. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// Name of floodlight activity associated with this rule. This is a read-only, auto-generated field. + #[serde(rename="floodlightActivityName")] + pub floodlight_activity_name: Option, + /// Clauses that make up this list population rule. Clauses are joined by ANDs, and the clauses themselves are made up of list population terms which are joined by ORs. + #[serde(rename="listPopulationClauses")] + pub list_population_clauses: Option>, +} + +impl Part for ListPopulationRule {} + + +/// Contains properties of a DCM account. +/// +/// # 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 accounts](struct.AccountUpdateCall.html) (request|response) +/// * [list accounts](struct.AccountListCall.html) (none) +/// * [get accounts](struct.AccountGetCall.html) (response) +/// * [patch accounts](struct.AccountPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Account { + /// File size limit in kilobytes of Rich Media teaser creatives. Must be between 1 and 10240. + #[serde(rename="teaserSizeLimit")] + pub teaser_size_limit: Option, + /// User role permissions available to the user roles of this account. + #[serde(rename="availablePermissionIds")] + pub available_permission_ids: Option>, + /// Description of this account. + pub description: Option, + /// Locale of this account. + /// Acceptable values are: + /// - "cs" (Czech) + /// - "de" (German) + /// - "en" (English) + /// - "en-GB" (English United Kingdom) + /// - "es" (Spanish) + /// - "fr" (French) + /// - "it" (Italian) + /// - "ja" (Japanese) + /// - "ko" (Korean) + /// - "pl" (Polish) + /// - "pt-BR" (Portuguese Brazil) + /// - "ru" (Russian) + /// - "sv" (Swedish) + /// - "tr" (Turkish) + /// - "zh-CN" (Chinese Simplified) + /// - "zh-TW" (Chinese Traditional) + pub locale: Option, + /// Profile for this account. This is a read-only field that can be left blank. + #[serde(rename="accountProfile")] + pub account_profile: Option, + /// Whether this account is active. + pub active: Option, + /// Whether to serve creatives with Active View tags. If disabled, viewability data will not be available for any impressions. + #[serde(rename="activeViewOptOut")] + pub active_view_opt_out: Option, + /// Share Path to Conversion reports with Twitter. + #[serde(rename="shareReportsWithTwitter")] + pub share_reports_with_twitter: Option, + /// ID of this account. This is a read-only, auto-generated field. + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#account". + pub kind: Option, + /// ID of the country associated with this account. + #[serde(rename="countryId")] + pub country_id: Option, + /// Name of this account. This is a required field, and must be less than 128 characters long and be globally unique. + pub name: Option, + /// Maximum image size allowed for this account. + #[serde(rename="maximumImageSize")] + pub maximum_image_size: Option, + /// Whether campaigns created in this account will be enabled for Nielsen OCR reach ratings by default. + #[serde(rename="nielsenOcrEnabled")] + pub nielsen_ocr_enabled: Option, + /// Default placement dimensions for this account. + #[serde(rename="defaultCreativeSizeId")] + pub default_creative_size_id: Option, + /// Account permissions assigned to this account. + #[serde(rename="accountPermissionIds")] + pub account_permission_ids: Option>, + /// ID of currency associated with this account. This is a required field. + /// Acceptable values are: + /// - "1" for USD + /// - "2" for GBP + /// - "3" for ESP + /// - "4" for SEK + /// - "5" for CAD + /// - "6" for JPY + /// - "7" for DEM + /// - "8" for AUD + /// - "9" for FRF + /// - "10" for ITL + /// - "11" for DKK + /// - "12" for NOK + /// - "13" for FIM + /// - "14" for ZAR + /// - "15" for IEP + /// - "16" for NLG + /// - "17" for EUR + /// - "18" for KRW + /// - "19" for TWD + /// - "20" for SGD + /// - "21" for CNY + /// - "22" for HKD + /// - "23" for NZD + /// - "24" for MYR + /// - "25" for BRL + /// - "26" for PTE + /// - "27" for MXP + /// - "28" for CLP + /// - "29" for TRY + /// - "30" for ARS + /// - "31" for PEN + /// - "32" for ILS + /// - "33" for CHF + /// - "34" for VEF + /// - "35" for COP + /// - "36" for GTQ + /// - "37" for PLN + /// - "39" for INR + /// - "40" for THB + /// - "41" for IDR + /// - "42" for CZK + /// - "43" for RON + /// - "44" for HUF + /// - "45" for RUB + /// - "46" for AED + /// - "47" for BGN + /// - "48" for HRK + #[serde(rename="currencyId")] + pub currency_id: Option, + /// Reporting configuration of this account. + #[serde(rename="reportsConfiguration")] + pub reports_configuration: Option, + /// Maximum number of active ads allowed for this account. + #[serde(rename="activeAdsLimitTier")] + pub active_ads_limit_tier: Option, +} + +impl RequestValue for Account {} +impl Resource for Account {} +impl ResponseResult for Account {} + + +/// Day Part Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DayPartTargeting { + /// Days of the week when the ad will serve. + /// + /// Acceptable values are: + /// - "SUNDAY" + /// - "MONDAY" + /// - "TUESDAY" + /// - "WEDNESDAY" + /// - "THURSDAY" + /// - "FRIDAY" + /// - "SATURDAY" + #[serde(rename="daysOfWeek")] + pub days_of_week: Option>, + /// Hours of the day when the ad will serve. Must be an integer between 0 and 23 (inclusive), where 0 is midnight to 1 AM, and 23 is 11 PM to midnight. Can be specified with days of week, in which case the ad would serve during these hours on the specified days. For example, if Monday, Wednesday, Friday are the days of week specified and 9-10am, 3-5pm (hours 9, 15, and 16) is specified, the ad would serve Monday, Wednesdays, and Fridays at 9-10am and 3-5pm. + #[serde(rename="hoursOfDay")] + pub hours_of_day: Option>, + /// Whether or not to use the user's local time. If false, the America/New York time zone applies. + #[serde(rename="userLocalTime")] + pub user_local_time: Option, +} + +impl Part for DayPartTargeting {} + + +/// Represents a response to the queryCompatibleFields method. +/// +/// # 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*). +/// +/// * [compatible fields query reports](struct.ReportCompatibleFieldQueryCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CompatibleFields { + /// The kind of resource this is, in this case dfareporting#compatibleFields. + pub kind: Option, + /// Contains items that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". + #[serde(rename="crossDimensionReachReportCompatibleFields")] + pub cross_dimension_reach_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "REACH". + #[serde(rename="reachReportCompatibleFields")] + pub reach_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "PATH_TO_CONVERSION". + #[serde(rename="pathToConversionReportCompatibleFields")] + pub path_to_conversion_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "FLOODLIGHT". + #[serde(rename="floodlightReportCompatibleFields")] + pub floodlight_report_compatible_fields: Option, + /// Contains items that are compatible to be selected for a report of type "STANDARD". + #[serde(rename="reportCompatibleFields")] + pub report_compatible_fields: Option, +} + +impl ResponseResult for CompatibleFields {} + + +/// Contains information about a region that can be targeted by ads. +/// +/// # 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) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Region { + /// Region code. + #[serde(rename="regionCode")] + pub region_code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#region". + pub kind: Option, + /// DART ID of the country to which this region belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this region. + pub name: Option, + /// Country code of the country to which this region belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// DART ID of this region. + #[serde(rename="dartId")] + pub dart_id: Option, +} + +impl Resource for Region {} + + +/// The report criteria for a report of type "STANDARD". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCriteria { + /// Activity group. + pub activities: Option, + /// The list of standard dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range for which this report should be run. + #[serde(rename="dateRange")] + pub date_range: Option, + /// Custom Rich Media Events group. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl NestedType for ReportCriteria {} +impl Part for ReportCriteria {} + + +/// Order List Response +/// +/// # 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 orders](struct.OrderListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrdersListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ordersListResponse". + pub kind: Option, + /// Order collection. + pub orders: Option>, +} + +impl ResponseResult for OrdersListResponse {} + + +/// Represents fields that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CrossDimensionReachReportCompatibleFields { + /// Dimensions which are compatible to be selected in the "breakdown" section of the report. + pub breakdown: Option>, + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#crossDimensionReachReportCompatibleFields. + pub kind: Option, + /// Metrics which are compatible to be selected in the "overlapMetricNames" section of the report. + #[serde(rename="overlapMetrics")] + pub overlap_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl Part for CrossDimensionReachReportCompatibleFields {} + + +/// The error code and description for a conversion that failed to insert or update. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionError { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionError". + pub kind: Option, + /// The error code. + pub code: Option, + /// A description of the error. + pub message: Option, +} + +impl Part for ConversionError {} + + +/// Event Tag List Response +/// +/// # 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 event tags](struct.EventTagListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTagsListResponse { + /// Event tag collection. + #[serde(rename="eventTags")] + pub event_tags: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTagsListResponse". + pub kind: Option, +} + +impl ResponseResult for EventTagsListResponse {} + + +/// Contains properties of a Floodlight activity group. +/// +/// # 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 floodlight activity groups](struct.FloodlightActivityGroupListCall.html) (none) +/// * [get floodlight activity groups](struct.FloodlightActivityGroupGetCall.html) (response) +/// * [insert floodlight activity groups](struct.FloodlightActivityGroupInsertCall.html) (request|response) +/// * [patch floodlight activity groups](struct.FloodlightActivityGroupPatchCall.html) (request|response) +/// * [update floodlight activity groups](struct.FloodlightActivityGroupUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroup". + pub kind: Option, + /// Subaccount ID of this floodlight activity group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this floodlight activity group. This is a required field. Must be less than 65 characters long and cannot contain quotes. + pub name: Option, + /// Floodlight configuration ID of this floodlight activity group. This is a required field. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// Advertiser ID of this floodlight activity group. If this field is left blank, the value will be copied over either from the floodlight configuration's advertiser or from the existing activity group's advertiser. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Dimension value for the ID of this floodlight activity group. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Value of the type= parameter in the floodlight tag, which the ad servers use to identify the activity group that the activity belongs to. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activity groups of the same floodlight configuration. This field is read-only after insertion. + #[serde(rename="tagString")] + pub tag_string: Option, + /// Type of the floodlight activity group. This is a required field that is read-only after insertion. + #[serde(rename="type")] + pub type_: Option, + /// ID of this floodlight activity group. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this floodlight activity group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for FloodlightActivityGroup {} +impl Resource for FloodlightActivityGroup {} +impl ResponseResult for FloodlightActivityGroup {} + + +/// Audience Segment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AudienceSegment { + /// Weight allocated to this segment. Must be between 1 and 1000. The weight assigned will be understood in proportion to the weights assigned to other segments in the same segment group. + pub allocation: Option, + /// ID of this audience segment. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this audience segment. This is a required field and must be less than 65 characters long. + pub name: Option, +} + +impl Part for AudienceSegment {} + + +/// Contains properties of a DCM campaign. +/// +/// # 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 campaigns](struct.CampaignInsertCall.html) (request|response) +/// * [update campaigns](struct.CampaignUpdateCall.html) (request|response) +/// * [patch campaigns](struct.CampaignPatchCall.html) (request|response) +/// * [get campaigns](struct.CampaignGetCall.html) (response) +/// * [list campaigns](struct.CampaignListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Campaign { + /// Arbitrary comments about this campaign. Must be less than 256 characters long. + pub comment: Option, + /// Date on which the campaign starts running. The start date can be any date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This is a required field. + #[serde(rename="startDate")] + pub start_date: Option, + /// Date on which the campaign will stop running. On insert, the end date must be today or a future date. The end date must be later than or be the same as the start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective campaign run date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This is a required field. + #[serde(rename="endDate")] + pub end_date: Option, + /// Click-through URL suffix override properties for this campaign. + #[serde(rename="clickThroughUrlSuffixProperties")] + pub click_through_url_suffix_properties: Option, + /// Whether this campaign has been archived. + pub archived: Option, + /// Additional creative optimization configurations for the campaign. + #[serde(rename="additionalCreativeOptimizationConfigurations")] + pub additional_creative_optimization_configurations: Option>, + /// Advertiser ID of this campaign. This is a required field. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Audience segment groups assigned to this campaign. Cannot have more than 300 segment groups. + #[serde(rename="audienceSegmentGroups")] + pub audience_segment_groups: Option>, + /// Information about the creation of this campaign. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Click-through event tag ID override properties for this campaign. + #[serde(rename="defaultClickThroughEventTagProperties")] + pub default_click_through_event_tag_properties: Option, + /// Dimension value for the advertiser ID of this campaign. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Overrides that can be used to activate or deactivate advertiser event tags. + #[serde(rename="eventTagOverrides")] + pub event_tag_overrides: Option>, + /// Creative optimization configuration for the campaign. + #[serde(rename="creativeOptimizationConfiguration")] + pub creative_optimization_configuration: Option, + /// ID of this campaign. This is a read-only auto-generated field. + pub id: Option, + /// Account ID of this campaign. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Campaign trafficker contact emails. + #[serde(rename="traffickerEmails")] + pub trafficker_emails: Option>, + /// List of creative group IDs that are assigned to the campaign. + #[serde(rename="creativeGroupIds")] + pub creative_group_ids: Option>, + /// Subaccount ID of this campaign. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this campaign. This is a required field and must be less than 256 characters long and unique among campaigns of the same advertiser. + pub name: Option, + /// Lookback window settings for the campaign. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Whether Nielsen reports are enabled for this campaign. + #[serde(rename="nielsenOcrEnabled")] + pub nielsen_ocr_enabled: Option, + /// Information about the most recent modification of this campaign. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaign". + pub kind: Option, + /// External ID for this campaign. + #[serde(rename="externalId")] + pub external_id: Option, + /// Advertiser group ID of the associated advertiser. + #[serde(rename="advertiserGroupId")] + pub advertiser_group_id: Option, + /// Dimension value for the ID of this campaign. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Billing invoice code included in the DCM client billing invoices associated with the campaign. + #[serde(rename="billingInvoiceCode")] + pub billing_invoice_code: Option, +} + +impl RequestValue for Campaign {} +impl Resource for Campaign {} +impl ResponseResult for Campaign {} + + +/// Describes a change that a user has made to a 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 change logs](struct.ChangeLogListCall.html) (none) +/// * [get change logs](struct.ChangeLogGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChangeLog { + /// Time when the object was modified. + #[serde(rename="changeTime")] + pub change_time: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLog". + pub kind: Option, + /// Subaccount ID of the modified object. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Old value of the object field. + #[serde(rename="oldValue")] + pub old_value: Option, + /// ID of the object of this change log. The object could be a campaign, placement, ad, or other type. + #[serde(rename="objectId")] + pub object_id: Option, + /// ID of this change log. + pub id: Option, + /// User profile name of the user who modified the object. + #[serde(rename="userProfileName")] + pub user_profile_name: Option, + /// Field name of the object which changed. + #[serde(rename="fieldName")] + pub field_name: Option, + /// ID of the user who modified the object. + #[serde(rename="userProfileId")] + pub user_profile_id: Option, + /// Action which caused the change. + pub action: Option, + /// Transaction ID of this change log. When a single API call results in many changes, each change will have a separate ID in the change log but will share the same transactionId. + #[serde(rename="transactionId")] + pub transaction_id: Option, + /// Account ID of the modified object. + #[serde(rename="accountId")] + pub account_id: Option, + /// New value of the object field. + #[serde(rename="newValue")] + pub new_value: Option, + /// Object type of the change log. + #[serde(rename="objectType")] + pub object_type: Option, +} + +impl Resource for ChangeLog {} +impl ResponseResult for ChangeLog {} + + +/// Represents a File resource. A file contains the metadata for a report run. It shows the status of the run and holds the URLs to the generated report data if the run is finished and the status is "REPORT_AVAILABLE". +/// +/// # 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 files](struct.FileGetCall.html) (response) +/// * [list files](struct.FileListCall.html) (none) +/// * [files get reports](struct.ReportFileGetCall.html) (response) +/// * [run reports](struct.ReportRunCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct File { + /// The status of the report file. + pub status: Option, + /// The kind of resource this is, in this case dfareporting#file. + pub kind: Option, + /// The output format of the report. Only available once the file is available. + pub format: Option, + /// The date range for which the file has report data. The date range will always be the absolute date range for which the report is run. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The filename of the file. + #[serde(rename="fileName")] + pub file_name: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The ID of the report this file was generated from. + #[serde(rename="reportId")] + pub report_id: Option, + /// The URLs where the completed report file can be downloaded. + pub urls: Option, + /// The timestamp in milliseconds since epoch when this file was last modified. + #[serde(rename="lastModifiedTime")] + pub last_modified_time: Option, + /// The unique ID of this report file. + pub id: Option, +} + +impl Resource for File {} +impl ResponseResult for File {} + + +/// Key Value Targeting Expression. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct KeyValueTargetingExpression { + /// Keyword expression being targeted by the ad. + pub expression: Option, +} + +impl Part for KeyValueTargetingExpression {} + + +/// The report criteria for a report of type "CROSS_DIMENSION_REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCrossDimensionReachCriteria { + /// The list of dimensions the report should include. + pub breakdown: Option>, + /// Whether the report is pivoted or not. Defaults to true. + pub pivoted: Option, + /// The list of names of overlap metrics the report should include. + #[serde(rename="overlapMetricNames")] + pub overlap_metric_names: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of filters on which dimensions are filtered. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The dimension option. + pub dimension: Option, +} + +impl NestedType for ReportCrossDimensionReachCriteria {} +impl Part for ReportCrossDimensionReachCriteria {} + + +/// Contains properties of a placement. +/// +/// # 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*). +/// +/// * [generatetags placements](struct.PlacementGeneratetagCall.html) (none) +/// * [insert placements](struct.PlacementInsertCall.html) (request|response) +/// * [update placements](struct.PlacementUpdateCall.html) (request|response) +/// * [list placements](struct.PlacementListCall.html) (none) +/// * [get placements](struct.PlacementGetCall.html) (response) +/// * [patch placements](struct.PlacementPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Placement { + /// Comments for this placement. + pub comment: Option, + /// Campaign ID of this placement. This field is a required field on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Payment source for this placement. This is a required field that is read-only after insertion. + #[serde(rename="paymentSource")] + pub payment_source: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Advertiser ID of this placement. This field can be left blank. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Key name of this placement. This is a read-only, auto-generated field. + #[serde(rename="keyName")] + pub key_name: Option, + /// Directory site ID of this placement. On insert, you must set either this field or the siteId field to specify the site associated with this placement. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of the content category assigned to this placement. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// Size associated with this placement. When inserting or updating a placement, only the size ID field is used. This field is required on insertion. + pub size: Option, + /// Whether this placement is archived. + pub archived: Option, + /// Information about the last publisher update. This is a read-only field. + #[serde(rename="publisherUpdateInfo")] + pub publisher_update_info: Option, + /// Tag formats to generate for this placement. This field is required on insertion. + /// Acceptable values are: + /// - "PLACEMENT_TAG_STANDARD" + /// - "PLACEMENT_TAG_IFRAME_JAVASCRIPT" + /// - "PLACEMENT_TAG_IFRAME_ILAYER" + /// - "PLACEMENT_TAG_INTERNAL_REDIRECT" + /// - "PLACEMENT_TAG_JAVASCRIPT" + /// - "PLACEMENT_TAG_INTERSTITIAL_IFRAME_JAVASCRIPT" + /// - "PLACEMENT_TAG_INTERSTITIAL_INTERNAL_REDIRECT" + /// - "PLACEMENT_TAG_INTERSTITIAL_JAVASCRIPT" + /// - "PLACEMENT_TAG_CLICK_COMMANDS" + /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH" + /// - "PLACEMENT_TAG_TRACKING" + /// - "PLACEMENT_TAG_TRACKING_IFRAME" + /// - "PLACEMENT_TAG_TRACKING_JAVASCRIPT" + #[serde(rename="tagFormats")] + pub tag_formats: Option>, + /// Whether payment was approved for this placement. This is a read-only field relevant only to publisher-paid placements. + #[serde(rename="paymentApproved")] + pub payment_approved: Option, + /// Tag settings for this placement. + #[serde(rename="tagSetting")] + pub tag_setting: Option, + /// ID of this placement. This is a read-only, auto-generated field. + pub id: Option, + /// External ID for this placement. + #[serde(rename="externalId")] + pub external_id: Option, + /// Dimension value for the ID of this placement. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Account ID of this placement. This field can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Whether creatives assigned to this placement must be SSL-compliant. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Third-party placement status. + pub status: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Whether this placement is the primary placement of a roadblock (placement group). You cannot change this field from true to false. Setting this field to true will automatically set the primary field on the original primary placement of the roadblock to false, and it will automatically set the roadblock's primaryPlacementId field to the ID of this placement. + pub primary: Option, + /// ID of this placement's group, if applicable. + #[serde(rename="placementGroupId")] + pub placement_group_id: Option, + /// Information about the creation of this placement. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Site ID associated with this placement. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement. This is a required field that is read-only after insertion. + #[serde(rename="siteId")] + pub site_id: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Placement compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering on desktop, on mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are no longer allowed for new placement insertions. Instead, use DISPLAY or DISPLAY_INTERSTITIAL. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. This field is required on insertion. + pub compatibility: Option, + /// ID of the placement strategy assigned to this placement. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Dimension value for the ID of the placement group. This is a read-only, auto-generated field. + #[serde(rename="placementGroupIdDimensionValue")] + pub placement_group_id_dimension_value: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placement". + pub kind: Option, + /// Subaccount ID of this placement. This field can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this placement.This is a required field and must be less than 256 characters long. + pub name: Option, + /// Lookback window settings for this placement. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Information about the most recent modification of this placement. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Pricing schedule of this placement. This field is required on insertion, specifically subfields startDate, endDate and pricingType. + #[serde(rename="pricingSchedule")] + pub pricing_schedule: Option, +} + +impl RequestValue for Placement {} +impl Resource for Placement {} +impl ResponseResult for Placement {} + + +/// Inventory item List Response +/// +/// # 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 inventory items](struct.InventoryItemListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItemsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItemsListResponse". + pub kind: Option, + /// Inventory item collection + #[serde(rename="inventoryItems")] + pub inventory_items: Option>, +} + +impl ResponseResult for InventoryItemsListResponse {} + + +/// Audience Segment Group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AudienceSegmentGroup { + /// Audience segments assigned to this group. The number of segments must be between 2 and 100. + #[serde(rename="audienceSegments")] + pub audience_segments: Option>, + /// ID of this audience segment group. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this audience segment group. This is a required field and must be less than 65 characters long. + pub name: Option, +} + +impl Part for AudienceSegmentGroup {} + + +/// Contains properties of a placement strategy. +/// +/// # 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 placement strategies](struct.PlacementStrategyPatchCall.html) (request|response) +/// * [insert placement strategies](struct.PlacementStrategyInsertCall.html) (request|response) +/// * [get placement strategies](struct.PlacementStrategyGetCall.html) (response) +/// * [update placement strategies](struct.PlacementStrategyUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementStrategy { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy". + pub kind: Option, + /// Account ID of this placement strategy.This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this placement strategy. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this placement strategy. This is a required field. It must be less than 256 characters long and unique among placement strategies of the same account. + pub name: Option, +} + +impl RequestValue for PlacementStrategy {} +impl ResponseResult for PlacementStrategy {} + + +/// Creative optimization activity. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OptimizationActivity { + /// Floodlight activity ID of this optimization activity. This is a required field. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, + /// Dimension value for the ID of the floodlight activity. This is a read-only, auto-generated field. + #[serde(rename="floodlightActivityIdDimensionValue")] + pub floodlight_activity_id_dimension_value: Option, + /// Weight associated with this optimization. Must be greater than 1. The weight assigned will be understood in proportion to the weights assigned to the other optimization activities. + pub weight: Option, +} + +impl Part for OptimizationActivity {} + + +/// Placement Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementTag { + /// Tags generated for this placement. + #[serde(rename="tagDatas")] + pub tag_datas: Option>, + /// Placement ID + #[serde(rename="placementId")] + pub placement_id: Option, +} + +impl Part for PlacementTag {} + + +/// Country List Response +/// +/// # 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 countries](struct.CountryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CountriesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse". + pub kind: Option, + /// Country collection. + pub countries: Option>, +} + +impl ResponseResult for CountriesListResponse {} + + +/// Click-through 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 ClickThroughUrl { + /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows: + /// - If defaultLandingPage is enabled then the campaign's default landing page URL is assigned to this field. + /// - If defaultLandingPage is not enabled and a landingPageId is specified then that landing page's URL is assigned to this field. + /// - If neither of the above cases apply, then the customClickThroughUrl is assigned to this field. + #[serde(rename="computedClickThroughUrl")] + pub computed_click_through_url: Option, + /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset. + #[serde(rename="customClickThroughUrl")] + pub custom_click_through_url: Option, + /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false. + #[serde(rename="landingPageId")] + pub landing_page_id: Option, + /// Whether the campaign default landing page is used. + #[serde(rename="defaultLandingPage")] + pub default_landing_page: Option, +} + +impl Part for ClickThroughUrl {} + + +/// Companion Click-through override. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CompanionClickThroughOverride { + /// Click-through URL of this companion click-through override. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// ID of the creative for this companion click-through override. + #[serde(rename="creativeId")] + pub creative_id: Option, +} + +impl Part for CompanionClickThroughOverride {} + + +/// Frequency Cap. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FrequencyCap { + /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days in seconds, or 7,776,000. + pub duration: Option, + /// Number of times an individual user can be served the ad within the specified duration. The maximum allowed is 15. + pub impressions: Option, +} + +impl Part for FrequencyCap {} + + +/// Identifies a creative which has been associated with a given campaign. +/// +/// # 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 campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (none) +/// * [insert campaign creative associations](struct.CampaignCreativeAssociationInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignCreativeAssociation { + /// ID of the creative associated with the campaign. This is a required field. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation". + pub kind: Option, +} + +impl RequestValue for CampaignCreativeAssociation {} +impl Resource for CampaignCreativeAssociation {} +impl ResponseResult for CampaignCreativeAssociation {} + + +/// Contains properties of a remarketing list's sharing information. Sharing allows other accounts or advertisers to target to your remarketing lists. This resource can be used to manage remarketing list sharing to other accounts and advertisers. +/// +/// # 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 remarketing list shares](struct.RemarketingListShareGetCall.html) (response) +/// * [patch remarketing list shares](struct.RemarketingListSharePatchCall.html) (request|response) +/// * [update remarketing list shares](struct.RemarketingListShareUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingListShare { + /// Advertisers that the remarketing list is shared with. + #[serde(rename="sharedAdvertiserIds")] + pub shared_advertiser_ids: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListShare". + pub kind: Option, + /// Remarketing list ID. This is a read-only, auto-generated field. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option, + /// Accounts that the remarketing list is shared with. + #[serde(rename="sharedAccountIds")] + pub shared_account_ids: Option>, +} + +impl RequestValue for RemarketingListShare {} +impl Resource for RemarketingListShare {} +impl ResponseResult for RemarketingListShare {} + + +/// Operating System Version List Response +/// +/// # 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 operating system versions](struct.OperatingSystemVersionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemVersionsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse". + pub kind: Option, + /// Operating system version collection. + #[serde(rename="operatingSystemVersions")] + pub operating_system_versions: Option>, +} + +impl ResponseResult for OperatingSystemVersionsListResponse {} + + +/// Organizes placements according to the contents of their associated webpages. +/// +/// # 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 content categories](struct.ContentCategoryPatchCall.html) (request|response) +/// * [insert content categories](struct.ContentCategoryInsertCall.html) (request|response) +/// * [update content categories](struct.ContentCategoryUpdateCall.html) (request|response) +/// * [get content categories](struct.ContentCategoryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentCategory { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory". + pub kind: Option, + /// Account ID of this content category. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this content category. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this content category. This is a required field and must be less than 256 characters long and unique among content categories of the same account. + pub name: Option, +} + +impl RequestValue for ContentCategory {} +impl ResponseResult for ContentCategory {} + + +/// Targetable remarketing list response +/// +/// # 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 targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingListsListResponse". + pub kind: Option, + /// Targetable remarketing list collection. + #[serde(rename="targetableRemarketingLists")] + pub targetable_remarketing_lists: Option>, +} + +impl ResponseResult for TargetableRemarketingListsListResponse {} + + +/// Represents a buy from the DoubleClick Planning inventory store. +/// +/// # 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 inventory items](struct.InventoryItemGetCall.html) (response) +/// * [list inventory items](struct.InventoryItemListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItem { + /// Order ID of this inventory item. + #[serde(rename="orderId")] + pub order_id: Option, + /// Advertiser ID of this inventory item. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// ID of the site this inventory item is associated with. + #[serde(rename="siteId")] + pub site_id: Option, + /// Ad slots of this inventory item. If this inventory item represents a standalone placement, there will be exactly one ad slot. If this inventory item represents a placement group, there will be more than one ad slot, each representing one child placement in that placement group. + #[serde(rename="adSlots")] + pub ad_slots: Option>, + /// RFP ID of this inventory item. + #[serde(rename="rfpId")] + pub rfp_id: Option, + /// Content category ID of this inventory item. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// Placement strategy ID of this inventory item. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Account ID of this inventory item. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItem". + pub kind: Option, + /// Negotiation channel ID of this inventory item. + #[serde(rename="negotiationChannelId")] + pub negotiation_channel_id: Option, + /// Subaccount ID of this inventory item. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this inventory item. For standalone inventory items, this is the same name as that of its only ad slot. For group inventory items, this can differ from the name of any of its ad slots. + pub name: Option, + /// Estimated click-through rate of this inventory item. + #[serde(rename="estimatedClickThroughRate")] + pub estimated_click_through_rate: Option, + /// Information about the most recent modification of this inventory item. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Estimated conversion rate of this inventory item. + #[serde(rename="estimatedConversionRate")] + pub estimated_conversion_rate: Option, + /// Whether this inventory item is in plan. + #[serde(rename="inPlan")] + pub in_plan: Option, + /// ID of this inventory item. + pub id: Option, + /// Project ID of this inventory item. + #[serde(rename="projectId")] + pub project_id: Option, + /// Type of inventory item. + #[serde(rename="type")] + pub type_: Option, + /// Pricing of this inventory item. + pub pricing: Option, +} + +impl Resource for InventoryItem {} +impl ResponseResult for InventoryItem {} + + +/// Represents fields that are compatible to be selected for a report of type "FlOODLIGHT". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#floodlightReportCompatibleFields. + pub kind: Option, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, +} + +impl Part for FloodlightReportCompatibleFields {} + + +/// Creative Asset ID. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssetId { + /// Type of asset to upload. This is a required field. FLASH and IMAGE are no longer supported for new uploads. All image assets should use HTML_IMAGE. + #[serde(rename="type")] + pub type_: Option, + /// Name of the creative asset. This is a required field while inserting an asset. After insertion, this assetIdentifier is used to identify the uploaded asset. Characters in the name must be alphanumeric or one of the following: ".-_ ". Spaces are allowed. + pub name: Option, +} + +impl Part for CreativeAssetId {} + + +/// Directory Site Contact Assignment +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContactAssignment { + /// ID of this directory site contact. This is a read-only, auto-generated field. + #[serde(rename="contactId")] + pub contact_id: Option, + /// Visibility of this directory site contact assignment. When set to PUBLIC this contact assignment is visible to all account and agency users; when set to PRIVATE it is visible only to the site. + pub visibility: Option, +} + +impl Part for DirectorySiteContactAssignment {} + + +/// Creative Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssignment { + /// Weight of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_RANDOM. + pub weight: Option, + /// Sequence number of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_SEQUENTIAL. + pub sequence: Option, + /// Click-through URL of the creative assignment. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// Rich media exit overrides for this creative assignment. + /// Applicable when the creative type is any of the following: + /// - RICH_MEDIA_INPAGE + /// - RICH_MEDIA_INPAGE_FLOATING + /// - RICH_MEDIA_IM_EXPAND + /// - RICH_MEDIA_EXPANDING + /// - RICH_MEDIA_INTERSTITIAL_FLOAT + /// - RICH_MEDIA_MOBILE_IN_APP + /// - RICH_MEDIA_MULTI_FLOATING + /// - RICH_MEDIA_PEEL_DOWN + /// - ADVANCED_BANNER + /// - VPAID_LINEAR + /// - VPAID_NON_LINEAR + #[serde(rename="richMediaExitOverrides")] + pub rich_media_exit_overrides: Option>, + /// Whether applicable event tags should fire when this creative assignment is rendered. If this value is unset when the ad is inserted or updated, it will default to true for all creative types EXCEPT for INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO. + #[serde(rename="applyEventTags")] + pub apply_event_tags: Option, + /// Creative group assignments for this creative assignment. Only one assignment per creative group number is allowed for a maximum of two assignments. + #[serde(rename="creativeGroupAssignments")] + pub creative_group_assignments: Option>, + /// Companion creative overrides for this creative assignment. Applicable to video ads. + #[serde(rename="companionCreativeOverrides")] + pub companion_creative_overrides: Option>, + /// Date and time that the assigned creative should start serving. + #[serde(rename="startTime")] + pub start_time: Option, + /// Whether the creative to be assigned is SSL-compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Whether this creative assignment is active. When true, the creative will be included in the ad's rotation. + pub active: Option, + /// ID of the creative to be assigned. This is a required field. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Date and time that the assigned creative should stop serving. Must be later than the start time. + #[serde(rename="endTime")] + pub end_time: Option, + /// Dimension value for the ID of the creative. This is a read-only, auto-generated field. + #[serde(rename="creativeIdDimensionValue")] + pub creative_id_dimension_value: Option, +} + +impl Part for CreativeAssignment {} + + +/// Represents a DimensionValuesRequest. +/// +/// # 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValueRequest { + /// The name of the dimension for which values should be requested. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The start date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". + #[serde(rename="startDate")] + pub start_date: Option, + /// The kind of request this is, in this case dfareporting#dimensionValueRequest. + pub kind: Option, + /// The end date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". + #[serde(rename="endDate")] + pub end_date: Option, + /// The list of filters by which to filter values. The filters are ANDed. + pub filters: Option>, +} + +impl RequestValue for DimensionValueRequest {} + + +/// Ad Slot +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdSlot { + /// Comment for this ad slot. + pub comment: Option, + /// ID of the placement from an external platform that is linked to this ad slot. + #[serde(rename="linkedPlacementId")] + pub linked_placement_id: Option, + /// Name of this ad slot. + pub name: Option, + /// Primary ad slot of a roadblock inventory item. + pub primary: Option, + /// Height of this ad slot. + pub height: Option, + /// Width of this ad slot. + pub width: Option, + /// Payment source type of this ad slot. + #[serde(rename="paymentSourceType")] + pub payment_source_type: Option, + /// Ad slot compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop, mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. + pub compatibility: Option, +} + +impl Part for AdSlot {} + + +/// Properties of inheriting and overriding the default click-through event tag. A campaign may override the event tag defined at the advertiser level, and an ad may also override the campaign's setting further. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DefaultClickThroughEventTagProperties { + /// Whether this entity should override the inherited default click-through event tag with its own defined value. + #[serde(rename="overrideInheritedEventTag")] + pub override_inherited_event_tag: Option, + /// ID of the click-through event tag to apply to all ads in this entity's scope. + #[serde(rename="defaultClickThroughEventTagId")] + pub default_click_through_event_tag_id: Option, +} + +impl Part for DefaultClickThroughEventTagProperties {} + + +/// Represents the list of user profiles. +/// +/// # 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 user profiles](struct.UserProfileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserProfileList { + /// The user profiles returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#userProfileList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for UserProfileList {} + + +/// Subaccount List Response +/// +/// # 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 subaccounts](struct.SubaccountListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SubaccountsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccountsListResponse". + pub kind: Option, + /// Subaccount collection. + pub subaccounts: Option>, +} + +impl ResponseResult for SubaccountsListResponse {} + + +/// Contains properties of a DoubleClick Planning order document. +/// +/// # 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 order documents](struct.OrderDocumentGetCall.html) (response) +/// * [list order documents](struct.OrderDocumentListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocument { + /// ID of the order from which this order document is created. + #[serde(rename="orderId")] + pub order_id: Option, + /// Timestamp of the last email sent with this order document. + #[serde(rename="lastSentTime")] + pub last_sent_time: Option, + /// The amended order document ID of this order document. An order document can be created by optionally amending another order document so that the change history can be preserved. + #[serde(rename="amendedOrderDocumentId")] + pub amended_order_document_id: Option, + /// List of email addresses that received the last sent document. + #[serde(rename="lastSentRecipients")] + pub last_sent_recipients: Option>, + /// IDs of users who have approved this order document. + #[serde(rename="approvedByUserProfileIds")] + pub approved_by_user_profile_ids: Option>, + /// ID of this order document. + pub id: Option, + /// Account ID of this order document. + #[serde(rename="accountId")] + pub account_id: Option, + /// Advertiser ID of this order document. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocument". + pub kind: Option, + /// Subaccount ID of this order document. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Effective date of this order document. + #[serde(rename="effectiveDate")] + pub effective_date: Option, + /// Title of this order document. + pub title: Option, + /// Project ID of this order document. + #[serde(rename="projectId")] + pub project_id: Option, + /// Whether this order document has been signed. + pub signed: Option, + /// Information about the creation of this order document. + #[serde(rename="createdInfo")] + pub created_info: Option, + /// Whether this order document is cancelled. + pub cancelled: Option, + /// Type of this order document + #[serde(rename="type")] + pub type_: Option, +} + +impl Resource for OrderDocument {} +impl ResponseResult for OrderDocument {} + + +/// Represents a Report 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*). +/// +/// * [run reports](struct.ReportRunCall.html) (none) +/// * [get reports](struct.ReportGetCall.html) (response) +/// * [list reports](struct.ReportListCall.html) (none) +/// * [delete reports](struct.ReportDeleteCall.html) (none) +/// * [files list reports](struct.ReportFileListCall.html) (none) +/// * [insert reports](struct.ReportInsertCall.html) (request|response) +/// * [patch reports](struct.ReportPatchCall.html) (request|response) +/// * [compatible fields query reports](struct.ReportCompatibleFieldQueryCall.html) (request) +/// * [update reports](struct.ReportUpdateCall.html) (request|response) +/// * [files get reports](struct.ReportFileGetCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Report { + /// The user profile id of the owner of this report. + #[serde(rename="ownerProfileId")] + pub owner_profile_id: Option, + /// The subaccount ID to which this report belongs if applicable. + #[serde(rename="subAccountId")] + pub sub_account_id: Option, + /// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY". + pub schedule: Option, + /// The report criteria for a report of type "PATH_TO_CONVERSION". + #[serde(rename="pathToConversionCriteria")] + pub path_to_conversion_criteria: Option, + /// The report criteria for a report of type "REACH". + #[serde(rename="reachCriteria")] + pub reach_criteria: Option, + /// The report criteria for a report of type "FLOODLIGHT". + #[serde(rename="floodlightCriteria")] + pub floodlight_criteria: Option, + /// The filename used when generating report files for this report. + #[serde(rename="fileName")] + pub file_name: Option, + /// The report's email delivery settings. + pub delivery: Option, + /// The timestamp (in milliseconds since epoch) of when this report was last modified. + #[serde(rename="lastModifiedTime")] + pub last_modified_time: Option, + /// The report criteria for a report of type "CROSS_DIMENSION_REACH". + #[serde(rename="crossDimensionReachCriteria")] + pub cross_dimension_reach_criteria: Option, + /// The account ID to which this report belongs. + #[serde(rename="accountId")] + pub account_id: Option, + /// The kind of resource this is, in this case dfareporting#report. + pub kind: Option, + /// The name of the report. + pub name: Option, + /// The output format of the report. If not specified, default format is "CSV". Note that the actual format in the completed report file might differ if for instance the report's size exceeds the format's capabilities. "CSV" will then be the fallback format. + pub format: Option, + /// The unique ID identifying this report resource. + pub id: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The report criteria for a report of type "STANDARD". + pub criteria: Option, + /// The type of the report. + #[serde(rename="type")] + pub type_: Option, +} + +impl RequestValue for Report {} +impl Resource for Report {} +impl ResponseResult for Report {} + + +/// Contains information about a platform type that can be targeted by ads. +/// +/// # 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 platform types](struct.PlatformTypeGetCall.html) (response) +/// * [list platform types](struct.PlatformTypeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlatformType { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformType". + pub kind: Option, + /// ID of this platform type. + pub id: Option, + /// Name of this platform type. + pub name: Option, +} + +impl Resource for PlatformType {} +impl ResponseResult for PlatformType {} + + +/// Advertiser List Response +/// +/// # 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 advertisers](struct.AdvertiserListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertisersListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Advertiser collection. + pub advertisers: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertisersListResponse". + pub kind: Option, +} + +impl ResponseResult for AdvertisersListResponse {} + + +/// Creative Asset. +/// +/// # 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 creative assets](struct.CreativeAssetInsertCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAsset { + /// Detected MIME type for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// Artwork type of rich media creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Offset left unit for an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="positionLeftUnit")] + pub position_left_unit: Option, + /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. + #[serde(rename="collapsedSize")] + pub collapsed_size: Option, + /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="flashVersion")] + pub flash_version: Option, + /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. + pub pushdown: Option, + /// Whether to hide Flash objects flag for an asset. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="hideFlashObjects")] + pub hide_flash_objects: Option, + /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="detectedFeatures")] + pub detected_features: Option>, + /// List of companion creatives assigned to an in-stream video creative asset. Acceptable values include IDs of existing flash and image creatives. Applicable to INSTREAM_VIDEO creative type with dynamicAssetSelection set to true. + #[serde(rename="companionCreativeIds")] + pub companion_creative_ids: Option>, + /// Duration in seconds for which an asset will be displayed. Applicable to the following creative types: INSTREAM_VIDEO and VPAID_LINEAR_VIDEO. + pub duration: Option, + /// Offset top unit for an asset. This is a read-only field if the asset displayType is ASSET_DISPLAY_TYPE_OVERLAY. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="positionTopUnit")] + pub position_top_unit: Option, + /// Numeric ID of this creative asset. This is a required field and should not be modified. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + pub id: Option, + /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_DISPLAY_MULTI_FLOATING_INTERSTITIAL. + pub alignment: Option, + /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE, creatives if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + pub size: Option, + /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="horizontallyLocked")] + pub horizontally_locked: Option, + /// Initial wait time type before making the asset visible. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="startTimeType")] + pub start_time_type: Option, + /// Type of rich media asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="displayType")] + pub display_type: Option, + /// Detected expanded dimension for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="expandedDimension")] + pub expanded_dimension: Option, + /// Whether the asset is vertically locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="verticallyLocked")] + pub vertically_locked: Option, + /// Dimension value for the ID of the asset. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Role of the asset in relation to creative. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. This is a required field. + /// PRIMARY applies to DISPLAY, FLASH_INPAGE, HTML5_BANNER, IMAGE, DISPLAY_IMAGE_GALLERY, all RICH_MEDIA (which may contain multiple primary assets), and all VPAID creatives. + /// BACKUP_IMAGE applies to FLASH_INPAGE, HTML5_BANNER, all RICH_MEDIA, and all VPAID creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + /// ADDITIONAL_IMAGE and ADDITIONAL_FLASH apply to FLASH_INPAGE creatives. + /// OTHER refers to assets from sources other than DCM, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. + /// PARENT_VIDEO refers to videos uploaded by the user in DCM and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. + /// TRANSCODED_VIDEO refers to videos transcoded by DCM from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. + /// ALTERNATE_VIDEO refers to the DCM representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within DCM. + /// For VPAID_LINEAR_VIDEO creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR_VIDEO creative. + pub role: Option, + /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="zipFilesize")] + pub zip_filesize: Option, + /// Detected bit-rate for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="bitRate")] + pub bit_rate: Option, + /// Window mode options for flash assets. Applicable to the following creative types: FLASH_INPAGE, RICH_MEDIA_DISPLAY_EXPANDING, RICH_MEDIA_IM_EXPAND, RICH_MEDIA_DISPLAY_BANNER, and RICH_MEDIA_INPAGE_FLOATING. + #[serde(rename="windowMode")] + pub window_mode: Option, + /// Progressive URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="progressiveServingUrl")] + pub progressive_serving_url: Option, + /// Duration type for which an asset will be displayed. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="durationType")] + pub duration_type: Option, + /// Detected video duration for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="videoDuration")] + pub video_duration: Option, + /// File size associated with this creative asset. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="fileSize")] + pub file_size: Option, + /// Offset position for an asset in collapsed mode. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, only applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN. + pub offset: Option, + /// Whether the video asset is active. This is a read-only field for VPAID_NON_LINEAR_VIDEO assets. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + pub active: Option, + /// Whether the backup asset is original or changed by the user in DCM. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="originalBackup")] + pub original_backup: Option, + /// Whether to hide selection boxes flag for an asset. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="hideSelectionBoxes")] + pub hide_selection_boxes: Option, + /// Streaming URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. + #[serde(rename="streamingServingUrl")] + pub streaming_serving_url: Option, + /// zIndex value of an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable to assets whose displayType is NOT one of the following types: ASSET_DISPLAY_TYPE_INPAGE or ASSET_DISPLAY_TYPE_OVERLAY. + #[serde(rename="zIndex")] + pub z_index: Option, + /// Rich media child asset type. This is a read-only field. Applicable to the following creative types: all VPAID. + #[serde(rename="childAssetType")] + pub child_asset_type: Option, + /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="backupImageExit")] + pub backup_image_exit: Option, + /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="actionScript3")] + pub action_script3: Option, + /// Pushdown duration in seconds for an asset. Must be between 0 and 9.99. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. + #[serde(rename="pushdownDuration")] + pub pushdown_duration: Option, + /// Identifier of this asset. This is the same identifier returned during creative asset insert operation. This is a required field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="assetIdentifier")] + pub asset_identifier: Option, + /// Whether the asset is transparent. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable to HTML5 assets. + pub transparency: Option, + /// Whether the asset is SSL-compliant. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Offset position for an asset. Applicable to the following creative types: all RICH_MEDIA. + pub position: Option, + /// Custom start time in seconds for making the asset visible. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="customStartTimeValue")] + pub custom_start_time_value: Option, + /// File name of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="zipFilename")] + pub zip_filename: Option, +} + +impl Resource for CreativeAsset {} + + +/// Directory Site List Response +/// +/// # 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 directory sites](struct.DirectorySiteListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySitesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySitesListResponse". + pub kind: Option, + /// Directory site collection. + #[serde(rename="directorySites")] + pub directory_sites: Option>, +} + +impl ResponseResult for DirectorySitesListResponse {} + + +/// Modification timestamp. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LastModifiedInfo { + /// Timestamp of the last change in milliseconds since epoch. + pub time: Option, +} + +impl Part for LastModifiedInfo {} + + +/// Region List Response +/// +/// # 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 RegionsListResponse { + /// Region collection. + pub regions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#regionsListResponse". + pub kind: Option, +} + +impl ResponseResult for RegionsListResponse {} + + +/// Represents a grouping of related user role permissions. +/// +/// # 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 user role permission groups](struct.UserRolePermissionGroupListCall.html) (none) +/// * [get user role permission groups](struct.UserRolePermissionGroupGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroup". + pub kind: Option, + /// ID of this user role permission. + pub id: Option, + /// Name of this user role permission group. + pub name: Option, +} + +impl Resource for UserRolePermissionGroup {} +impl ResponseResult for UserRolePermissionGroup {} + + +/// Creative Click Tag. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClickTag { + /// Advertiser event name associated with the click tag. This field is used by DISPLAY_IMAGE_GALLERY and HTML5_BANNER creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="eventName")] + pub event_name: Option, + /// Parameter name for the specified click tag. For DISPLAY_IMAGE_GALLERY creative assets, this field must match the value of the creative asset's creativeAssetId.name field. + pub name: Option, + /// Parameter value for the specified click tag. This field contains a click-through url. + pub value: Option, +} + +impl Part for ClickTag {} + + +/// Contains information about an internet connection type that can be targeted by ads. Clients can use the connection type to target mobile vs. broadband users. +/// +/// # 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 connection types](struct.ConnectionTypeGetCall.html) (response) +/// * [list connection types](struct.ConnectionTypeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConnectionType { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionType". + pub kind: Option, + /// ID of this connection type. + pub id: Option, + /// Name of this connection type. + pub name: Option, +} + +impl Resource for ConnectionType {} +impl ResponseResult for ConnectionType {} + + +/// Browser List Response +/// +/// # 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 browsers](struct.BrowserListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct BrowsersListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browsersListResponse". + pub kind: Option, + /// Browser collection. + pub browsers: Option>, +} + +impl ResponseResult for BrowsersListResponse {} + + +/// Object Filter. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ObjectFilter { + /// Applicable when status is ASSIGNED. The user has access to objects with these object IDs. + #[serde(rename="objectIds")] + pub object_ids: Option>, + /// Status of the filter. NONE means the user has access to none of the objects. ALL means the user has access to all objects. ASSIGNED means the user has access to the objects with IDs in the objectIds list. + pub status: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#objectFilter". + pub kind: Option, +} + +impl Part for ObjectFilter {} + + +/// Creative Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeSettings { + /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. + #[serde(rename="iFrameHeader")] + pub i_frame_header: Option, + /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. + #[serde(rename="iFrameFooter")] + pub i_frame_footer: Option, +} + +impl Part for CreativeSettings {} + + +/// Represents a dimension. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Dimension { + /// The kind of resource this is, in this case dfareporting#dimension. + pub kind: Option, + /// The dimension name, e.g. dfa:advertiser + pub name: Option, +} + +impl Part for Dimension {} + + +/// Contact of an order. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderContact { + /// Type of this contact. + #[serde(rename="contactType")] + pub contact_type: Option, + /// Title of this contact. + #[serde(rename="contactTitle")] + pub contact_title: Option, + /// Free-form information about this contact. It could be any information related to this contact in addition to type, title, name, and signature user profile ID. + #[serde(rename="contactInfo")] + pub contact_info: Option, + /// Name of this contact. + #[serde(rename="contactName")] + pub contact_name: Option, + /// ID of the user profile containing the signature that will be embedded into order documents. + #[serde(rename="signatureUserProfileId")] + pub signature_user_profile_id: Option, +} + +impl Part for OrderContact {} + + +/// DirectorySites contains properties of a website from the Site Directory. Sites need to be added to an account via the Sites resource before they can be assigned to a placement. +/// +/// # 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 directory sites](struct.DirectorySiteGetCall.html) (response) +/// * [list directory sites](struct.DirectorySiteListCall.html) (none) +/// * [insert directory sites](struct.DirectorySiteInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySite { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySite". + pub kind: Option, + /// Country ID of this directory site. + #[serde(rename="countryId")] + pub country_id: Option, + /// Description of this directory site. + pub description: Option, + /// Directory site settings. + pub settings: Option, + /// Currency ID of this directory site. + /// Possible values are: + /// - "1" for USD + /// - "2" for GBP + /// - "3" for ESP + /// - "4" for SEK + /// - "5" for CAD + /// - "6" for JPY + /// - "7" for DEM + /// - "8" for AUD + /// - "9" for FRF + /// - "10" for ITL + /// - "11" for DKK + /// - "12" for NOK + /// - "13" for FIM + /// - "14" for ZAR + /// - "15" for IEP + /// - "16" for NLG + /// - "17" for EUR + /// - "18" for KRW + /// - "19" for TWD + /// - "20" for SGD + /// - "21" for CNY + /// - "22" for HKD + /// - "23" for NZD + /// - "24" for MYR + /// - "25" for BRL + /// - "26" for PTE + /// - "27" for MXP + /// - "28" for CLP + /// - "29" for TRY + /// - "30" for ARS + /// - "31" for PEN + /// - "32" for ILS + /// - "33" for CHF + /// - "34" for VEF + /// - "35" for COP + /// - "36" for GTQ + /// - "37" for PLN + /// - "39" for INR + /// - "40" for THB + /// - "41" for IDR + /// - "42" for CZK + /// - "43" for RON + /// - "44" for HUF + /// - "45" for RUB + /// - "46" for AED + /// - "47" for BGN + /// - "48" for HRK + #[serde(rename="currencyId")] + pub currency_id: Option, + /// Tag types for regular placements. + /// + /// Acceptable values are: + /// - "STANDARD" + /// - "IFRAME_JAVASCRIPT_INPAGE" + /// - "INTERNAL_REDIRECT_INPAGE" + /// - "JAVASCRIPT_INPAGE" + #[serde(rename="inpageTagFormats")] + pub inpage_tag_formats: Option>, + /// URL of this directory site. + pub url: Option, + /// Directory site contacts. + #[serde(rename="contactAssignments")] + pub contact_assignments: Option>, + /// Parent directory site ID. + #[serde(rename="parentId")] + pub parent_id: Option, + /// Tag types for interstitial placements. + /// + /// Acceptable values are: + /// - "IFRAME_JAVASCRIPT_INTERSTITIAL" + /// - "INTERNAL_REDIRECT_INTERSTITIAL" + /// - "JAVASCRIPT_INTERSTITIAL" + #[serde(rename="interstitialTagFormats")] + pub interstitial_tag_formats: Option>, + /// Dimension value for the ID of this directory site. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether this directory site is active. + pub active: Option, + /// ID of this directory site. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this directory site. + pub name: Option, +} + +impl RequestValue for DirectorySite {} +impl Resource for DirectorySite {} +impl ResponseResult for DirectorySite {} + + +/// City List Response +/// +/// # 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 cities](struct.CityListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CitiesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#citiesListResponse". + pub kind: Option, + /// City collection. + pub cities: Option>, +} + +impl ResponseResult for CitiesListResponse {} + + +/// Contains properties of a creative group. +/// +/// # 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 creative groups](struct.CreativeGroupGetCall.html) (response) +/// * [update creative groups](struct.CreativeGroupUpdateCall.html) (request|response) +/// * [patch creative groups](struct.CreativeGroupPatchCall.html) (request|response) +/// * [list creative groups](struct.CreativeGroupListCall.html) (none) +/// * [insert creative groups](struct.CreativeGroupInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroup". + pub kind: Option, + /// Subaccount ID of this creative group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this creative group. This is a required field and must be less than 256 characters long and unique among creative groups of the same advertiser. + pub name: Option, + /// Subgroup of the creative group. Assign your creative groups to one of the following subgroups in order to filter or manage them more easily. This field is required on insertion and is read-only after insertion. + /// Acceptable values are: + /// - 1 + /// - 2 + #[serde(rename="groupNumber")] + pub group_number: Option, + /// Advertiser ID of this creative group. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this creative group. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this creative group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for CreativeGroup {} +impl Resource for CreativeGroup {} +impl ResponseResult for CreativeGroup {} + + +/// Represents a metric. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Metric { + /// The kind of resource this is, in this case dfareporting#metric. + pub kind: Option, + /// The metric name, e.g. dfa:impressions + pub name: Option, +} + +impl Part for Metric {} + + +/// Rich Media Exit Override. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RichMediaExitOverride { + /// Click-through URL of this rich media exit override. Applicable if the enabled field is set to true. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// Whether to use the clickThroughUrl. If false, the creative-level exit will be used. + pub enabled: Option, + /// ID for the override to refer to a specific exit in the creative. + #[serde(rename="exitId")] + pub exit_id: Option, +} + +impl Part for RichMediaExitOverride {} + + +/// Account Permission List Response +/// +/// # 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 account permissions](struct.AccountPermissionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionsListResponse { + /// Account permission collection. + #[serde(rename="accountPermissions")] + pub account_permissions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionsListResponse". + pub kind: Option, +} + +impl ResponseResult for AccountPermissionsListResponse {} + + +/// Placement GenerateTags Response +/// +/// # 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*). +/// +/// * [generatetags placements](struct.PlacementGeneratetagCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementsGenerateTagsResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsGenerateTagsResponse". + pub kind: Option, + /// Set of generated tags for the specified placements. + #[serde(rename="placementTags")] + pub placement_tags: Option>, +} + +impl ResponseResult for PlacementsGenerateTagsResponse {} + + +/// Contains properties of a creative field value. +/// +/// # 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 creative field values](struct.CreativeFieldValueInsertCall.html) (request|response) +/// * [get creative field values](struct.CreativeFieldValueGetCall.html) (response) +/// * [update creative field values](struct.CreativeFieldValueUpdateCall.html) (request|response) +/// * [patch creative field values](struct.CreativeFieldValuePatchCall.html) (request|response) +/// * [list creative field values](struct.CreativeFieldValueListCall.html) (none) +/// * [delete creative field values](struct.CreativeFieldValueDeleteCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldValue { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValue". + pub kind: Option, + /// ID of this creative field value. This is a read-only, auto-generated field. + pub id: Option, + /// Value of this creative field value. It needs to be less than 256 characters in length and unique per creative field. + pub value: Option, +} + +impl RequestValue for CreativeFieldValue {} +impl Resource for CreativeFieldValue {} +impl ResponseResult for CreativeFieldValue {} + + +/// Floodlight Activity Group List Response +/// +/// # 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 floodlight activity groups](struct.FloodlightActivityGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroupsListResponse". + pub kind: Option, + /// Floodlight activity group collection. + #[serde(rename="floodlightActivityGroups")] + pub floodlight_activity_groups: Option>, +} + +impl ResponseResult for FloodlightActivityGroupsListResponse {} + + +/// Directory Site Contact List Response +/// +/// # 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 directory site contacts](struct.DirectorySiteContactListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContactsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Directory site contact collection + #[serde(rename="directorySiteContacts")] + pub directory_site_contacts: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContactsListResponse". + pub kind: Option, +} + +impl ResponseResult for DirectorySiteContactsListResponse {} + + +/// Creative Custom Event. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeCustomEvent { + /// Target type used by the event. + #[serde(rename="targetType")] + pub target_type: Option, + /// Artwork type used by the creative.This is a read-only field. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Video reporting ID, used to differentiate multiple videos in a single creative. This is a read-only field. + #[serde(rename="videoReportingId")] + pub video_reporting_id: Option, + /// Properties for rich media popup windows. This field is used only for exit events. + #[serde(rename="popupWindowProperties")] + pub popup_window_properties: Option, + /// Unique ID of this event used by DDM Reporting and Data Transfer. This is a read-only field. + #[serde(rename="advertiserCustomEventId")] + pub advertiser_custom_event_id: Option, + /// Artwork label column, used to link events in DCM back to events in Studio. This is a required field and should not be modified after insertion. + #[serde(rename="artworkLabel")] + pub artwork_label: Option, + /// Type of the event. This is a read-only field. + #[serde(rename="advertiserCustomEventType")] + pub advertiser_custom_event_type: Option, + /// Exit URL of the event. This field is used only for exit events. + #[serde(rename="exitUrl")] + pub exit_url: Option, + /// ID of this event. This is a required field and should not be modified after insertion. + pub id: Option, + /// User-entered name for the event. + #[serde(rename="advertiserCustomEventName")] + pub advertiser_custom_event_name: Option, +} + +impl Part for CreativeCustomEvent {} + + +/// Creative List Response +/// +/// # 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 creatives](struct.CreativeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativesListResponse". + pub kind: Option, + /// Creative collection. + pub creatives: Option>, +} + +impl ResponseResult for CreativesListResponse {} + + +/// Omniture Integration Settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OmnitureSettings { + /// Whether placement cost data will be sent to Omniture. This property can be enabled only if omnitureIntegrationEnabled is true. + #[serde(rename="omnitureCostDataEnabled")] + pub omniture_cost_data_enabled: Option, + /// Whether Omniture integration is enabled. This property can be enabled only when the "Advanced Ad Serving" account setting is enabled. + #[serde(rename="omnitureIntegrationEnabled")] + pub omniture_integration_enabled: Option, +} + +impl Part for OmnitureSettings {} + + +/// Represents fields that are compatible to be selected for a report of type "PATH_TO_CONVERSION". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PathToConversionReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// Per-interaction dimensions which are compatible to be selected in the "perInteractionDimensions" section of the report. + #[serde(rename="perInteractionDimensions")] + pub per_interaction_dimensions: Option>, + /// The kind of resource this is, in this case dfareporting#pathToConversionReportCompatibleFields. + pub kind: Option, + /// Conversion dimensions which are compatible to be selected in the "conversionDimensions" section of the report. + #[serde(rename="conversionDimensions")] + pub conversion_dimensions: Option>, + /// Custom floodlight variables which are compatible to be selected in the "customFloodlightVariables" section of the report. + #[serde(rename="customFloodlightVariables")] + pub custom_floodlight_variables: Option>, +} + +impl Part for PathToConversionReportCompatibleFields {} + + +/// Mobile Carrier List Response +/// +/// # 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 mobile carriers](struct.MobileCarrierListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MobileCarriersListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarriersListResponse". + pub kind: Option, + /// Mobile carrier collection. + #[serde(rename="mobileCarriers")] + pub mobile_carriers: Option>, +} + +impl ResponseResult for MobileCarriersListResponse {} + + +/// Dynamic Targeting Key List Response +/// +/// # 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 dynamic targeting keys](struct.DynamicTargetingKeyListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DynamicTargetingKeysListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKeysListResponse". + pub kind: Option, + /// Dynamic targeting key collection. + #[serde(rename="dynamicTargetingKeys")] + pub dynamic_targeting_keys: Option>, +} + +impl ResponseResult for DynamicTargetingKeysListResponse {} + + +/// Dynamic Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityDynamicTag { + /// Tag code. + pub tag: Option, + /// ID of this dynamic tag. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this tag. + pub name: Option, +} + +impl Part for FloodlightActivityDynamicTag {} + + +/// Contains properties of a Creative. +/// +/// # 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 creatives](struct.CreativeInsertCall.html) (request|response) +/// * [get creatives](struct.CreativeGetCall.html) (response) +/// * [list creatives](struct.CreativeListCall.html) (none) +/// * [update creatives](struct.CreativeUpdateCall.html) (request|response) +/// * [patch creatives](struct.CreativePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Creative { + /// Type of artwork used for the creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="artworkType")] + pub artwork_type: Option, + /// Latest Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="latestTraffickedCreativeId")] + pub latest_trafficked_creative_id: Option, + /// List of counter events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. + #[serde(rename="counterCustomEvents")] + pub counter_custom_events: Option>, + /// Advertiser ID of this creative. This is a required field. Applicable to all creative types. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Whether the creative is active. Applicable to all creative types. + pub active: Option, + /// List of timer events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset is not HTML_IMAGE. + #[serde(rename="timerCustomEvents")] + pub timer_custom_events: Option>, + /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. + #[serde(rename="renderingIdDimensionValue")] + pub rendering_id_dimension_value: Option, + /// OpenWindow FSCommand of this creative. This lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. This is only triggered if allowScriptAccess field is true. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="fsCommand")] + pub fs_command: Option, + /// Set this to true to enable the use of rules to target individual assets in this creative. When set to true creativeAssetSelection must be set. This also controls asset-level companions. When this is true, companion creatives should be assigned to creative assets. Learn more. Applicable to INSTREAM_VIDEO creatives. + #[serde(rename="dynamicAssetSelection")] + pub dynamic_asset_selection: Option, + /// ID of this creative. This is a read-only, auto-generated field. Applicable to all creative types. + pub id: Option, + /// Account ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types. + #[serde(rename="accountId")] + pub account_id: Option, + /// Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioTraffickedCreativeId")] + pub studio_trafficked_creative_id: Option, + /// Whether the creative is archived. Applicable to all creative types. + pub archived: Option, + /// Override CSS value for rich media creatives. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="overrideCss")] + pub override_css: Option, + /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types. + #[serde(rename="authoringSource")] + pub authoring_source: Option, + /// The internal Flash version for this creative as calculated by DoubleClick Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="requiredFlashVersion")] + pub required_flash_version: Option, + /// List of exit events configured for the creative. For DISPLAY and DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags, For DISPLAY, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="exitCustomEvents")] + pub exit_custom_events: Option>, + /// ID of current rendering version. This is a read-only field. Applicable to all creative types. + #[serde(rename="renderingId")] + pub rendering_id: Option, + /// Description of the video ad. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="videoDescription")] + pub video_description: Option, + /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="thirdPartyBackupImageImpressionsUrl")] + pub third_party_backup_image_impressions_url: Option, + /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types. + pub version: Option, + /// Creative field assignments for this creative. Applicable to all creative types. + #[serde(rename="creativeFieldAssignments")] + pub creative_field_assignments: Option>, + /// The 6-character HTML color code, beginning with #, for the background of the window area where the Flash file is displayed. Default is white. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="backgroundColor")] + pub background_color: Option, + /// Custom key-values for a Rich Media creative. Key-values let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use key-values to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="customKeyValues")] + pub custom_key_values: Option>, + /// Dimension value for the ID of this creative. This is a read-only field. Applicable to all creative types. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether images are automatically advanced for image gallery creatives. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY. + pub auto_advance_images: Option, + /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE, FLASH_INPAGE creatives, and for DISPLAY creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: DISPLAY, DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. + pub size: Option, + /// Type of this creative. This is a required field. Applicable to all creative types. + /// + /// Note: FLASH_INPAGE, HTML5_BANNER, and IMAGE are only used for existing creatives. New creatives should use DISPLAY as a replacement for these types. + #[serde(rename="type")] + pub type_: Option, + /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="totalFileSize")] + pub total_file_size: Option, + /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. + #[serde(rename="thirdPartyRichMediaImpressionsUrl")] + pub third_party_rich_media_impressions_url: Option, + /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioAdvertiserId")] + pub studio_advertiser_id: Option, + /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT + #[serde(rename="creativeAssets")] + pub creative_assets: Option>, + /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by DCM for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageFeatures")] + pub backup_image_features: Option>, + /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. + #[serde(rename="videoDuration")] + pub video_duration: Option, + /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: DISPLAY_REDIRECT, INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO_REDIRECT + #[serde(rename="redirectUrl")] + pub redirect_url: Option, + /// Click tags of the creative. For DISPLAY, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For DISPLAY_IMAGE_GALLERY creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="clickTags")] + pub click_tags: Option>, + /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageTargetWindow")] + pub backup_image_target_window: Option, + /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="requiredFlashPluginVersion")] + pub required_flash_plugin_version: Option, + /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageReportingLabel")] + pub backup_image_reporting_label: Option, + /// Compatibilities associated with this creative. This is a read-only field. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. Only pre-existing creatives may have these compatibilities since new creatives will either be assigned DISPLAY or DISPLAY_INTERSTITIAL instead. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. Applicable to all creative types. + /// + /// Acceptable values are: + /// - "APP" + /// - "APP_INTERSTITIAL" + /// - "IN_STREAM_VIDEO" + /// - "DISPLAY" + /// - "DISPLAY_INTERSTITIAL" + pub compatibility: Option>, + /// Ad parameters user for VPAID creative. This is a read-only field. Applicable to the following creative types: all VPAID. + #[serde(rename="adParameters")] + pub ad_parameters: Option, + /// Whether HTML code is DCM-generated or manually entered. Set to true to ignore changes to htmlCode. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. + #[serde(rename="htmlCodeLocked")] + pub html_code_locked: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creative". + pub kind: Option, + /// Subaccount ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of the creative. This is a required field and must be less than 256 characters long. Applicable to all creative types. + pub name: Option, + /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="adTagKeys")] + pub ad_tag_keys: Option>, + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="convertFlashToHtml5")] + pub convert_flash_to_html5: Option, + /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. + #[serde(rename="sslOverride")] + pub ssl_override: Option, + /// Creative last modification information. This is a read-only field. Applicable to all creative types. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Click-through URL for backup image. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE. + #[serde(rename="backupImageClickThroughUrl")] + pub backup_image_click_through_url: Option, + /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. + #[serde(rename="studioCreativeId")] + pub studio_creative_id: Option, + /// Authoring tool for HTML5 banner creatives. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. + #[serde(rename="authoringTool")] + pub authoring_tool: Option, + /// Third-party URLs for tracking in-stream video creative events. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="thirdPartyUrls")] + pub third_party_urls: Option>, + /// List of companion creatives assigned to an in-Stream videocreative. Acceptable values include IDs of existing flash and image creatives. Applicable to the following creative types: all VPAID and all INSTREAM_VIDEO with dynamicAssetSelection set to false. + #[serde(rename="companionCreatives")] + pub companion_creatives: Option>, + /// Required if dynamicAssetSelection is true. + #[serde(rename="creativeAssetSelection")] + pub creative_asset_selection: Option, + /// HTML code for the creative. This is a required field when applicable. This field is ignored if htmlCodeLocked is false. Applicable to the following creative types: all CUSTOM, FLASH_INPAGE, and HTML5_BANNER, and all RICH_MEDIA. + #[serde(rename="htmlCode")] + pub html_code: Option, + /// Whether the creative is SSL-compliant. This is a read-only field. Applicable to all creative types. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Industry standard ID assigned to creative for reach and frequency. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + #[serde(rename="commercialId")] + pub commercial_id: Option, + /// Whether the user can choose to skip the creative. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. + pub skippable: Option, + /// Whether script access is allowed for this creative. This is a read-only and deprecated field which will automatically be set to true on update. Applicable to the following creative types: FLASH_INPAGE. + #[serde(rename="allowScriptAccess")] + pub allow_script_access: Option, +} + +impl RequestValue for Creative {} +impl Resource for Creative {} +impl ResponseResult for Creative {} + + +/// Reporting 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 ReportsConfiguration { + /// Whether the exposure to conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting. + #[serde(rename="exposureToConversionEnabled")] + pub exposure_to_conversion_enabled: Option, + /// Report generation time zone ID of this account. This is a required field that can only be changed by a superuser. + /// Acceptable values are: + /// + /// - "1" for "America/New_York" + /// - "2" for "Europe/London" + /// - "3" for "Europe/Paris" + /// - "4" for "Africa/Johannesburg" + /// - "5" for "Asia/Jerusalem" + /// - "6" for "Asia/Shanghai" + /// - "7" for "Asia/Hong_Kong" + /// - "8" for "Asia/Tokyo" + /// - "9" for "Australia/Sydney" + /// - "10" for "Asia/Dubai" + /// - "11" for "America/Los_Angeles" + /// - "12" for "Pacific/Auckland" + /// - "13" for "America/Sao_Paulo" + #[serde(rename="reportGenerationTimeZoneId")] + pub report_generation_time_zone_id: Option, + /// Default lookback windows for new advertisers in this account. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, +} + +impl Part for ReportsConfiguration {} + + +/// Campaign List Response +/// +/// # 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 campaigns](struct.CampaignListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignsListResponse { + /// Campaign collection. + pub campaigns: Option>, + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignsListResponse". + pub kind: Option, +} + +impl ResponseResult for CampaignsListResponse {} + + +/// User Role Permission List Response +/// +/// # 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 user role permissions](struct.UserRolePermissionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermissionsListResponse { + /// User role permission collection. + #[serde(rename="userRolePermissions")] + pub user_role_permissions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionsListResponse". + pub kind: Option, +} + +impl ResponseResult for UserRolePermissionsListResponse {} + + +/// Represents a UserProfile 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 user profiles](struct.UserProfileListCall.html) (none) +/// * [get user profiles](struct.UserProfileGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserProfile { + /// The user name. + #[serde(rename="userName")] + pub user_name: Option, + /// The kind of resource this is, in this case dfareporting#userProfile. + pub kind: Option, + /// The sub account ID this profile belongs to if applicable. + #[serde(rename="subAccountId")] + pub sub_account_id: Option, + /// The account name this profile belongs to. + #[serde(rename="accountName")] + pub account_name: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// The sub account name this profile belongs to if applicable. + #[serde(rename="subAccountName")] + pub sub_account_name: Option, + /// The unique ID of the user profile. + #[serde(rename="profileId")] + pub profile_id: Option, + /// The account ID to which this profile belongs. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl Resource for UserProfile {} +impl ResponseResult for UserProfile {} + + +/// Creative Group Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroupAssignment { + /// ID of the creative group to be assigned. + #[serde(rename="creativeGroupId")] + pub creative_group_id: Option, + /// Creative group number of the creative group assignment. + #[serde(rename="creativeGroupNumber")] + pub creative_group_number: Option, +} + +impl Part for CreativeGroupAssignment {} + + +/// The report criteria for a report of type "PATH_TO_CONVERSION". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportPathToConversionCriteria { + /// The list of conversion dimensions the report should include. + #[serde(rename="conversionDimensions")] + pub conversion_dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of custom floodlight variables the report should include. + #[serde(rename="customFloodlightVariables")] + pub custom_floodlight_variables: Option>, + /// The list of 'dfa:activity' values to filter on. + #[serde(rename="activityFilters")] + pub activity_filters: Option>, + /// The list of custom rich media events to include. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option>, + /// The list of per interaction dimensions the report should include. + #[serde(rename="perInteractionDimensions")] + pub per_interaction_dimensions: Option>, + /// The properties of the report. + #[serde(rename="reportProperties")] + pub report_properties: Option, + /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. + #[serde(rename="floodlightConfigId")] + pub floodlight_config_id: Option, +} + +impl NestedType for ReportPathToConversionCriteria {} +impl Part for ReportPathToConversionCriteria {} + + +/// Creative Field List Response +/// +/// # 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 creative fields](struct.CreativeFieldListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Creative field collection. + #[serde(rename="creativeFields")] + pub creative_fields: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse". + pub kind: Option, +} + +impl ResponseResult for CreativeFieldsListResponse {} + + +/// The report's email delivery settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportDelivery { + /// The message to be sent with each email. + pub message: Option, + /// The type of delivery for the owner to receive, if enabled. + #[serde(rename="emailOwnerDeliveryType")] + pub email_owner_delivery_type: Option, + /// The list of recipients to which to email the report. + pub recipients: Option>, + /// Whether the report should be emailed to the report owner. + #[serde(rename="emailOwner")] + pub email_owner: Option, +} + +impl NestedType for ReportDelivery {} +impl Part for ReportDelivery {} + + +/// Project List Response +/// +/// # 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 projects](struct.ProjectListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProjectsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#projectsListResponse". + pub kind: Option, + /// Project collection. + pub projects: Option>, +} + +impl ResponseResult for ProjectsListResponse {} + + +/// Contains properties of a dynamic targeting key. Dynamic targeting keys are unique, user-friendly labels, created at the advertiser level in DCM, that can be assigned to ads, creatives, and placements and used for targeting with DoubleClick Studio dynamic creatives. Use these labels instead of numeric DCM IDs (such as placement IDs) to save time and avoid errors in your dynamic feeds. +/// +/// # 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 dynamic targeting keys](struct.DynamicTargetingKeyListCall.html) (none) +/// * [delete dynamic targeting keys](struct.DynamicTargetingKeyDeleteCall.html) (none) +/// * [insert dynamic targeting keys](struct.DynamicTargetingKeyInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DynamicTargetingKey { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKey". + pub kind: Option, + /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + pub name: Option, + /// ID of the object of this dynamic targeting key. This is a required field. + #[serde(rename="objectId")] + pub object_id: Option, + /// Type of the object of this dynamic targeting key. This is a required field. + #[serde(rename="objectType")] + pub object_type: Option, +} + +impl RequestValue for DynamicTargetingKey {} +impl Resource for DynamicTargetingKey {} +impl ResponseResult for DynamicTargetingKey {} + + +/// Geographical Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GeoTargeting { + /// Regions to be targeted. For each region only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a region, do not target or exclude the country of the region. + pub regions: Option>, + /// Countries to be targeted or excluded from targeting, depending on the setting of the excludeCountries field. For each country only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting or excluding a country, do not target regions, cities, metros, or postal codes in the same country. + pub countries: Option>, + /// Metros to be targeted. For each metro only dmaId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a metro, do not target or exclude the country of the metro. + pub metros: Option>, + /// Cities to be targeted. For each city only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a city, do not target or exclude the country of the city, and do not target the metro or region of the city. + pub cities: Option>, + /// Whether or not to exclude the countries in the countries field from targeting. If false, the countries field refers to countries which will be targeted by the ad. + #[serde(rename="excludeCountries")] + pub exclude_countries: Option, + /// Postal codes to be targeted. For each postal code only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a postal code, do not target or exclude the country of the postal code. + #[serde(rename="postalCodes")] + pub postal_codes: Option>, +} + +impl Part for GeoTargeting {} + + +/// Contains properties of a targeting template. A targeting template encapsulates targeting information which can be reused across multiple ads. +/// +/// # 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 targeting templates](struct.TargetingTemplateInsertCall.html) (request|response) +/// * [update targeting templates](struct.TargetingTemplateUpdateCall.html) (request|response) +/// * [get targeting templates](struct.TargetingTemplateGetCall.html) (response) +/// * [list targeting templates](struct.TargetingTemplateListCall.html) (none) +/// * [patch targeting templates](struct.TargetingTemplatePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetingTemplate { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplate". + pub kind: Option, + /// Subaccount ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this targeting template. This field is required. It must be less than 256 characters long and unique within an advertiser. + pub name: Option, + /// Time and day targeting criteria. + #[serde(rename="dayPartTargeting")] + pub day_part_targeting: Option, + /// Key-value targeting criteria. + #[serde(rename="keyValueTargetingExpression")] + pub key_value_targeting_expression: Option, + /// Remarketing list targeting criteria. + #[serde(rename="listTargetingExpression")] + pub list_targeting_expression: Option, + /// Language targeting criteria. + #[serde(rename="languageTargeting")] + pub language_targeting: Option, + /// Advertiser ID of this targeting template. This is a required field on insert and is read-only after insert. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Geographical targeting criteria. + #[serde(rename="geoTargeting")] + pub geo_targeting: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Technology platform targeting criteria. + #[serde(rename="technologyTargeting")] + pub technology_targeting: Option, + /// ID of this targeting template. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for TargetingTemplate {} +impl Resource for TargetingTemplate {} +impl ResponseResult for TargetingTemplate {} + + +/// Delivery Schedule. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DeliverySchedule { + /// Serving priority of an ad, with respect to other ads. The lower the priority number, the greater the priority with which it is served. + pub priority: Option, + /// Whether or not hard cutoff is enabled. If true, the ad will not serve after the end date and time. Otherwise the ad will continue to be served until it has reached its delivery goals. + #[serde(rename="hardCutoff")] + pub hard_cutoff: Option, + /// Limit on the number of times an individual user can be served the ad within a specified period of time. + #[serde(rename="frequencyCap")] + pub frequency_cap: Option, + /// Impression ratio for this ad. This ratio determines how often each ad is served relative to the others. For example, if ad A has an impression ratio of 1 and ad B has an impression ratio of 3, then DCM will serve ad B three times as often as ad A. Must be between 1 and 10. + #[serde(rename="impressionRatio")] + pub impression_ratio: Option, +} + +impl Part for DeliverySchedule {} + + +/// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportSchedule { + /// Start date of date range for which scheduled reports should be run. + #[serde(rename="startDate")] + pub start_date: Option, + /// Enum to define for "MONTHLY" scheduled reports whether reports should be repeated on the same day of the month as "startDate" or the same day of the week of the month. + /// Example: If 'startDate' is Monday, April 2nd 2012 (2012-04-02), "DAY_OF_MONTH" would run subsequent reports on the 2nd of every Month, and "WEEK_OF_MONTH" would run subsequent reports on the first Monday of the month. + #[serde(rename="runsOnDayOfMonth")] + pub runs_on_day_of_month: Option, + /// The expiration date when the scheduled report stops running. + #[serde(rename="expirationDate")] + pub expiration_date: Option, + /// Whether the schedule is active or not. Must be set to either true or false. + pub active: Option, + /// Defines every how many days, weeks or months the report should be run. Needs to be set when "repeats" is either "DAILY", "WEEKLY" or "MONTHLY". + pub every: Option, + /// The interval for which the report is repeated. Note: + /// - "DAILY" also requires field "every" to be set. + /// - "WEEKLY" also requires fields "every" and "repeatsOnWeekDays" to be set. + /// - "MONTHLY" also requires fields "every" and "runsOnDayOfMonth" to be set. + pub repeats: Option, + /// List of week days "WEEKLY" on which scheduled reports should run. + #[serde(rename="repeatsOnWeekDays")] + pub repeats_on_week_days: Option>, +} + +impl NestedType for ReportSchedule {} +impl Part for ReportSchedule {} + + +/// Represents a recipient. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Recipient { + /// The kind of resource this is, in this case dfareporting#recipient. + pub kind: Option, + /// The delivery type for the recipient. + #[serde(rename="deliveryType")] + pub delivery_type: Option, + /// The email address of the recipient. + pub email: Option, +} + +impl Part for Recipient {} + + +/// Represents fields that are compatible to be selected for a report of type "STANDARD". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#reportCompatibleFields. + pub kind: Option, + /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. + #[serde(rename="pivotedActivityMetrics")] + pub pivoted_activity_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, +} + +impl Part for ReportCompatibleFields {} + + +/// Advertiser Group List Response +/// +/// # 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 advertiser groups](struct.AdvertiserGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertiserGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroupsListResponse". + pub kind: Option, + /// Advertiser group collection. + #[serde(rename="advertiserGroups")] + pub advertiser_groups: Option>, +} + +impl ResponseResult for AdvertiserGroupsListResponse {} + + +/// Placement Group List Response +/// +/// # 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 placement groups](struct.PlacementGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse". + pub kind: Option, + /// Placement group collection. + #[serde(rename="placementGroups")] + pub placement_groups: Option>, +} + +impl ResponseResult for PlacementGroupsListResponse {} + + +/// The properties of the report. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportPathToConversionCriteriaReportProperties { + /// DFA checks to see if a click interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. + #[serde(rename="clicksLookbackWindow")] + pub clicks_lookback_window: Option, + /// Enable pivoting on interaction path. + #[serde(rename="pivotOnInteractionPath")] + pub pivot_on_interaction_path: Option, + /// DFA checks to see if an impression interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. + #[serde(rename="impressionsLookbackWindow")] + pub impressions_lookback_window: Option, + /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. + #[serde(rename="includeUnattributedIPConversions")] + pub include_unattributed_ip_conversions: Option, + /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. + #[serde(rename="includeUnattributedCookieConversions")] + pub include_unattributed_cookie_conversions: Option, + /// The maximum amount of time that can take place between interactions (clicks or impressions) by the same user. Valid values: 1-90. + #[serde(rename="maximumInteractionGap")] + pub maximum_interaction_gap: Option, + /// Deprecated: has no effect. + #[serde(rename="includeAttributedIPConversions")] + pub include_attributed_ip_conversions: Option, + /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. + #[serde(rename="maximumClickInteractions")] + pub maximum_click_interactions: Option, + /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. + #[serde(rename="maximumImpressionInteractions")] + pub maximum_impression_interactions: Option, +} + +impl NestedType for ReportPathToConversionCriteriaReportProperties {} +impl Part for ReportPathToConversionCriteriaReportProperties {} + + +/// Technology Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TechnologyTargeting { + /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated. + pub browsers: Option>, + /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. + #[serde(rename="operatingSystems")] + pub operating_systems: Option>, + /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. + #[serde(rename="mobileCarriers")] + pub mobile_carriers: Option>, + /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated. + #[serde(rename="connectionTypes")] + pub connection_types: Option>, + /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. + #[serde(rename="platformTypes")] + pub platform_types: Option>, + /// Operating system versions that this ad targets. To target all versions, use operatingSystems. For each operating system version, only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system version, do not set targeting for the corresponding operating system in operatingSystems. + #[serde(rename="operatingSystemVersions")] + pub operating_system_versions: Option>, +} + +impl Part for TechnologyTargeting {} + + +/// Language List Response +/// +/// # 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 languages](struct.LanguageListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LanguagesListResponse { + /// Language collection. + pub languages: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#languagesListResponse". + pub kind: Option, +} + +impl ResponseResult for LanguagesListResponse {} + + +/// Contains information about a language that can be targeted by ads. +/// +/// # 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 languages](struct.LanguageListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Language { + /// Format of language code is an ISO 639 two-letter language code optionally followed by an underscore followed by an ISO 3166 code. Examples are "en" for English or "zh_CN" for Simplified Chinese. + #[serde(rename="languageCode")] + pub language_code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#language". + pub kind: Option, + /// Language ID of this language. This is the ID used for targeting and generating reports. + pub id: Option, + /// Name of this language. + pub name: Option, +} + +impl Resource for Language {} + + +/// Represents the list of reports. +/// +/// # 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 reports](struct.ReportListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportList { + /// Continuation token used to page through reports. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The reports returned in this response. + pub items: Option>, + /// The kind of list this is, in this case dfareporting#reportList. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, +} + +impl ResponseResult for ReportList {} + + +/// Remarketing List Targeting Expression. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListTargetingExpression { + /// Expression describing which lists are being targeted by the ad. + pub expression: Option, +} + +impl Part for ListTargetingExpression {} + + +/// CreativeAssets contains properties of a creative asset file which will be uploaded or has already been uploaded. Refer to the creative sample code for how to upload assets and insert a creative. +/// +/// # 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 creative assets](struct.CreativeAssetInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssetMetadata { + /// Dimension value for the numeric ID of the asset. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeAssetMetadata". + pub kind: Option, + /// List of feature dependencies for the creative asset that are detected by DCM. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. + #[serde(rename="detectedFeatures")] + pub detected_features: Option>, + /// List of detected click tags for assets. This is a read-only auto-generated field. + #[serde(rename="clickTags")] + pub click_tags: Option>, + /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. + /// + /// Possible values are: + /// - "ADMOB_REFERENCED" + /// - "ASSET_FORMAT_UNSUPPORTED_DCM" + /// - "ASSET_INVALID" + /// - "CLICK_TAG_HARD_CODED" + /// - "CLICK_TAG_INVALID" + /// - "CLICK_TAG_IN_GWD" + /// - "CLICK_TAG_MISSING" + /// - "CLICK_TAG_MORE_THAN_ONE" + /// - "CLICK_TAG_NON_TOP_LEVEL" + /// - "COMPONENT_UNSUPPORTED_DCM" + /// - "ENABLER_UNSUPPORTED_METHOD_DCM" + /// - "EXTERNAL_FILE_REFERENCED" + /// - "FILE_DETAIL_EMPTY" + /// - "FILE_TYPE_INVALID" + /// - "GWD_PROPERTIES_INVALID" + /// - "HTML5_FEATURE_UNSUPPORTED" + /// - "LINKED_FILE_NOT_FOUND" + /// - "MAX_FLASH_VERSION_11" + /// - "MRAID_REFERENCED" + /// - "NOT_SSL_COMPLIANT" + /// - "ORPHANED_ASSET" + /// - "PRIMARY_HTML_MISSING" + /// - "SVG_INVALID" + /// - "ZIP_INVALID" + #[serde(rename="warnedValidationRules")] + pub warned_validation_rules: Option>, + /// ID of the creative asset. This is a required field. + #[serde(rename="assetIdentifier")] + pub asset_identifier: Option, + /// Numeric ID of the asset. This is a read-only, auto-generated field. + pub id: Option, +} + +impl RequestValue for CreativeAssetMetadata {} +impl ResponseResult for CreativeAssetMetadata {} + + +/// A rule associates an asset with a targeting template for asset-level targeting. Applicable to INSTREAM_VIDEO creatives. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Rule { + /// A creativeAssets[].id. This should refer to one of the parent assets in this creative. This is a required field. + #[serde(rename="assetId")] + pub asset_id: Option, + /// A targeting template ID. The targeting from the targeting template will be used to determine whether this asset should be served. This is a required field. + #[serde(rename="targetingTemplateId")] + pub targeting_template_id: Option, + /// A user-friendly name for this rule. This is a required field. + pub name: Option, +} + +impl Part for Rule {} + + +/// Placement Tag Data +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagData { + /// Tag string to record a click. + #[serde(rename="clickTag")] + pub click_tag: Option, + /// Tag string for serving an ad. + #[serde(rename="impressionTag")] + pub impression_tag: Option, + /// Creative associated with this placement tag. + #[serde(rename="creativeId")] + pub creative_id: Option, + /// Ad associated with this placement tag. + #[serde(rename="adId")] + pub ad_id: Option, + /// TagData tag format of this tag. + pub format: Option, +} + +impl Part for TagData {} + + +/// The report criteria for a report of type "FLOODLIGHT". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportFloodlightCriteria { + /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. + #[serde(rename="floodlightConfigId")] + pub floodlight_config_id: Option, + /// The list of dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of custom rich media events to include. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option>, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The properties of the report. + #[serde(rename="reportProperties")] + pub report_properties: Option, +} + +impl NestedType for ReportFloodlightCriteria {} +impl Part for ReportFloodlightCriteria {} + + +/// Landing Page List Response +/// +/// # 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 landing pages](struct.LandingPageListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LandingPagesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPagesListResponse". + pub kind: Option, + /// Landing page collection + #[serde(rename="landingPages")] + pub landing_pages: Option>, +} + +impl ResponseResult for LandingPagesListResponse {} + + +/// Encapsulates the list of rules for asset selection and a default asset in case none of the rules match. Applicable to INSTREAM_VIDEO creatives. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeAssetSelection { + /// Rules determine which asset will be served to a viewer. Rules will be evaluated in the order in which they are stored in this list. This list must contain at least one rule. Applicable to INSTREAM_VIDEO creatives. + pub rules: Option>, + /// A creativeAssets[].id. This should refer to one of the parent assets in this creative, and will be served if none of the rules match. This is a required field. + #[serde(rename="defaultAssetId")] + pub default_asset_id: Option, +} + +impl Part for CreativeAssetSelection {} + + +/// Site List Response +/// +/// # 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 sites](struct.SiteListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SitesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sitesListResponse". + pub kind: Option, + /// Site collection. + pub sites: Option>, +} + +impl ResponseResult for SitesListResponse {} + + +/// Represents a dimension filter. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionFilter { + /// The name of the dimension to filter. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The kind of resource this is, in this case dfareporting#dimensionFilter. + pub kind: Option, + /// The value of the dimension to filter. + pub value: Option, +} + +impl Part for DimensionFilter {} + + +/// Contains information about a postal code that can be targeted by ads. +/// +/// # 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 postal codes](struct.PostalCodeGetCall.html) (response) +/// * [list postal codes](struct.PostalCodeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PostalCode { + /// Postal code. This is equivalent to the id field. + pub code: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCode". + pub kind: Option, + /// DART ID of the country to which this postal code belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// ID of this postal code. + pub id: Option, + /// Country code of the country to which this postal code belongs. + #[serde(rename="countryCode")] + pub country_code: Option, +} + +impl Resource for PostalCode {} +impl ResponseResult for PostalCode {} + + +/// Contains properties of a remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource can be used to manage remarketing lists that are owned by your advertisers. To see all remarketing lists that are visible to your advertisers, including those that are shared to your advertiser or account, use the TargetableRemarketingLists 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 remarketing lists](struct.RemarketingListInsertCall.html) (request|response) +/// * [get remarketing lists](struct.RemarketingListGetCall.html) (response) +/// * [update remarketing lists](struct.RemarketingListUpdateCall.html) (request|response) +/// * [list remarketing lists](struct.RemarketingListListCall.html) (none) +/// * [patch remarketing lists](struct.RemarketingListPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingList { + /// Rule used to populate the remarketing list with users. + #[serde(rename="listPopulationRule")] + pub list_population_rule: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingList". + pub kind: Option, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Remarketing list description. + pub description: Option, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option, + /// Number of days that a user should remain in the remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option, + /// Dimension value for the advertiser ID that owns this remarketing list. This is a required field. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Product from which this remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option, + /// Whether this remarketing list is active. + pub active: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option, + /// Remarketing list ID. This is a read-only, auto-generated field. + pub id: Option, + /// Name of the remarketing list. This is a required field. Must be no greater than 128 characters long. + pub name: Option, +} + +impl RequestValue for RemarketingList {} +impl Resource for RemarketingList {} +impl ResponseResult for RemarketingList {} + + +/// Contains properties of a Floodlight activity. +/// +/// # 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 floodlight activities](struct.FloodlightActivityGetCall.html) (response) +/// * [insert floodlight activities](struct.FloodlightActivityInsertCall.html) (request|response) +/// * [patch floodlight activities](struct.FloodlightActivityPatchCall.html) (request|response) +/// * [update floodlight activities](struct.FloodlightActivityUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivity { + /// Whether this tag should use SSL. + pub secure: Option, + /// Dimension value for the ID of this floodlight activity. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Name of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupName")] + pub floodlight_activity_group_name: Option, + /// Whether the image tag is enabled for this activity. + #[serde(rename="imageTagEnabled")] + pub image_tag_enabled: Option, + /// Advertiser ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's advertiser or the existing activity's advertiser. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Code type used for cache busting in the generated tag. + #[serde(rename="cacheBustingType")] + pub cache_busting_type: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Floodlight activity group ID of this floodlight activity. This is a required field. + #[serde(rename="floodlightActivityGroupId")] + pub floodlight_activity_group_id: Option, + /// List of the user-defined variables used by this conversion tag. These map to the "u[1-20]=" in the tags. Each of these can have a user defined type. + /// Acceptable values are: + /// - "U1" + /// - "U2" + /// - "U3" + /// - "U4" + /// - "U5" + /// - "U6" + /// - "U7" + /// - "U8" + /// - "U9" + /// - "U10" + /// - "U11" + /// - "U12" + /// - "U13" + /// - "U14" + /// - "U15" + /// - "U16" + /// - "U17" + /// - "U18" + /// - "U19" + /// - "U20" + #[serde(rename="userDefinedVariableTypes")] + pub user_defined_variable_types: Option>, + /// Value of the cat= paramter in the floodlight tag, which the ad servers use to identify the activity. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activities of the same activity group. This field is read-only after insertion. + #[serde(rename="tagString")] + pub tag_string: Option, + /// Tag string of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupTagString")] + pub floodlight_activity_group_tag_string: Option, + /// URL where this tag will be deployed. If specified, must be less than 256 characters long. + #[serde(rename="expectedUrl")] + pub expected_url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivity". + pub kind: Option, + /// Subaccount ID of this floodlight activity. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this floodlight activity. This is a required field. Must be less than 129 characters long and cannot contain quotes. + pub name: Option, + /// Publisher dynamic floodlight tags. + #[serde(rename="publisherTags")] + pub publisher_tags: Option>, + /// Whether the floodlight activity is SSL-compliant. This is a read-only field, its value detected by the system from the floodlight tags. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// General notes or implementation instructions for the tag. + pub notes: Option, + /// Floodlight configuration ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's floodlight configuration or from the existing activity's floodlight configuration. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// ID of this floodlight activity. This is a read-only, auto-generated field. + pub id: Option, + /// Counting method for conversions for this floodlight activity. This is a required field. + #[serde(rename="countingMethod")] + pub counting_method: Option, + /// Dynamic floodlight tags. + #[serde(rename="defaultTags")] + pub default_tags: Option>, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Tag format type for the floodlight activity. If left blank, the tag format will default to HTML. + #[serde(rename="tagFormat")] + pub tag_format: Option, + /// Whether this activity is archived. + pub hidden: Option, + /// Account ID of this floodlight activity. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Whether this floodlight activity must be SSL-compliant. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Type of the associated floodlight activity group. This is a read-only field. + #[serde(rename="floodlightActivityGroupType")] + pub floodlight_activity_group_type: Option, +} + +impl RequestValue for FloodlightActivity {} +impl ResponseResult for FloodlightActivity {} + + +/// Contains information about a browser that can be targeted by ads. +/// +/// # 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 browsers](struct.BrowserListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Browser { + /// Major version number (leftmost number) of this browser. For example, for Chrome 5.0.376.86 beta, this field should be set to 5. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is. + #[serde(rename="majorVersion")] + pub major_version: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browser". + pub kind: Option, + /// ID referring to this grouping of browser and version numbers. This is the ID used for targeting. + #[serde(rename="browserVersionId")] + pub browser_version_id: Option, + /// Name of this browser. + pub name: Option, + /// DART ID of this browser. This is the ID used when generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Minor version number (number after first dot on left) of this browser. For example, for Chrome 5.0.375.86 beta, this field should be set to 0. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is. + #[serde(rename="minorVersion")] + pub minor_version: Option, +} + +impl Resource for Browser {} + + +/// Account User Profile List Response +/// +/// # 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 account user profiles](struct.AccountUserProfileListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountUserProfilesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Account user profile collection. + #[serde(rename="accountUserProfiles")] + pub account_user_profiles: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfilesListResponse". + pub kind: Option, +} + +impl ResponseResult for AccountUserProfilesListResponse {} + + +/// Contains properties of a DCM advertiser. +/// +/// # 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 advertisers](struct.AdvertiserGetCall.html) (response) +/// * [update advertisers](struct.AdvertiserUpdateCall.html) (request|response) +/// * [patch advertisers](struct.AdvertiserPatchCall.html) (request|response) +/// * [list advertisers](struct.AdvertiserListCall.html) (none) +/// * [insert advertisers](struct.AdvertiserInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Advertiser { + /// Status of this advertiser. + pub status: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiser". + pub kind: Option, + /// Subaccount ID of this advertiser.This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this advertiser. This is a required field and must be less than 256 characters long and unique among advertisers of the same account. + pub name: Option, + /// ID of the click-through event tag to apply by default to the landing pages of this advertiser's campaigns. + #[serde(rename="defaultClickThroughEventTagId")] + pub default_click_through_event_tag_id: Option, + /// Original floodlight configuration before any sharing occurred. Set the floodlightConfigurationId of this advertiser to originalFloodlightConfigurationId to unshare the advertiser's current floodlight configuration. You cannot unshare an advertiser's floodlight configuration if the shared configuration has activities associated with any campaign or placement. + #[serde(rename="originalFloodlightConfigurationId")] + pub original_floodlight_configuration_id: Option, + /// Suffix added to click-through URL of ad creative associations under this advertiser. Must be less than 129 characters long. + #[serde(rename="clickThroughUrlSuffix")] + pub click_through_url_suffix: Option, + /// Floodlight configuration ID of this advertiser. The floodlight configuration ID will be created automatically, so on insert this field should be left blank. This field can be set to another advertiser's floodlight configuration ID in order to share that advertiser's floodlight configuration with this advertiser, so long as: + /// - This advertiser's original floodlight configuration is not already associated with floodlight activities or floodlight activity groups. + /// - This advertiser's original floodlight configuration is not already shared with another advertiser. + #[serde(rename="floodlightConfigurationId")] + pub floodlight_configuration_id: Option, + /// ID of the advertiser group this advertiser belongs to. You can group advertisers for reporting purposes, allowing you to see aggregated information for all advertisers in each group. + #[serde(rename="advertiserGroupId")] + pub advertiser_group_id: Option, + /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="floodlightConfigurationIdDimensionValue")] + pub floodlight_configuration_id_dimension_value: Option, + /// Suspension status of this advertiser. + pub suspended: Option, + /// Dimension value for the ID of this advertiser. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Default email address used in sender field for tag emails. + #[serde(rename="defaultEmail")] + pub default_email: Option, + /// ID of this advertiser. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this advertiser.This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for Advertiser {} +impl Resource for Advertiser {} +impl ResponseResult for Advertiser {} + + +/// Platform Type List Response +/// +/// # 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 platform types](struct.PlatformTypeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlatformTypesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformTypesListResponse". + pub kind: Option, + /// Platform type collection. + #[serde(rename="platformTypes")] + pub platform_types: Option>, +} + +impl ResponseResult for PlatformTypesListResponse {} + + +/// A description of how user IDs are encrypted. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EncryptionInfo { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#encryptionInfo". + pub kind: Option, + /// The encryption entity ID. This should match the encryption configuration for ad serving or Data Transfer. + #[serde(rename="encryptionEntityId")] + pub encryption_entity_id: Option, + /// Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer. + #[serde(rename="encryptionSource")] + pub encryption_source: Option, + /// The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. + #[serde(rename="encryptionEntityType")] + pub encryption_entity_type: Option, +} + +impl Part for EncryptionInfo {} + + +/// Placement List Response +/// +/// # 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 placements](struct.PlacementListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsListResponse". + pub kind: Option, + /// Placement collection. + pub placements: Option>, +} + +impl ResponseResult for PlacementsListResponse {} + + +/// Ad List Response +/// +/// # 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 ads](struct.AdListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#adsListResponse". + pub kind: Option, + /// Ad collection. + pub ads: Option>, +} + +impl ResponseResult for AdsListResponse {} + + +/// The report criteria for a report of type "REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportReachCriteria { + /// Activity group. + pub activities: Option, + /// The list of dimensions the report should include. + pub dimensions: Option>, + /// The list of names of metrics the report should include. + #[serde(rename="metricNames")] + pub metric_names: Option>, + /// The date range this report should be run for. + #[serde(rename="dateRange")] + pub date_range: Option, + /// The list of filters on which dimensions are filtered. + /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// The list of names of Reach By Frequency metrics the report should include. + #[serde(rename="reachByFrequencyMetricNames")] + pub reach_by_frequency_metric_names: Option>, + /// Custom Rich Media Events group. + #[serde(rename="customRichMediaEvents")] + pub custom_rich_media_events: Option, + /// Whether to enable all reach dimension combinations in the report. Defaults to false. If enabled, the date range of the report should be within the last three months. + #[serde(rename="enableAllDimensionCombinations")] + pub enable_all_dimension_combinations: Option, +} + +impl NestedType for ReportReachCriteria {} +impl Part for ReportReachCriteria {} + + +/// The URLs where the completed report file can be downloaded. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FileUrls { + /// The URL for downloading the report data through a browser. + #[serde(rename="browserUrl")] + pub browser_url: Option, + /// The URL for downloading the report data through the API. + #[serde(rename="apiUrl")] + pub api_url: Option, +} + +impl NestedType for FileUrls {} +impl Part for FileUrls {} + + +/// Order document List Response +/// +/// # 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 order documents](struct.OrderDocumentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocumentsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocumentsListResponse". + pub kind: Option, + /// Order document collection + #[serde(rename="orderDocuments")] + pub order_documents: Option>, +} + +impl ResponseResult for OrderDocumentsListResponse {} + + +/// User Defined Variable 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 UserDefinedVariableConfiguration { + /// Data type for the variable. This is a required field. + #[serde(rename="dataType")] + pub data_type: Option, + /// User-friendly name for the variable which will appear in reports. This is a required field, must be less than 64 characters long, and cannot contain the following characters: ""<>". + #[serde(rename="reportName")] + pub report_name: Option, + /// Variable name in the tag. This is a required field. + #[serde(rename="variableType")] + pub variable_type: Option, +} + +impl Part for UserDefinedVariableConfiguration {} + + +/// Pricing Information +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Pricing { + /// Group type of this inventory item if it represents a placement group. Is null otherwise. There are two type of placement groups: PLANNING_PLACEMENT_GROUP_TYPE_PACKAGE is a simple group of inventory items that acts as a single pricing point for a group of tags. PLANNING_PLACEMENT_GROUP_TYPE_ROADBLOCK is a group of inventory items that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned inventory items to be marked as primary. + #[serde(rename="groupType")] + pub group_type: Option, + /// Start date of this inventory item. + #[serde(rename="startDate")] + pub start_date: Option, + /// Flights of this inventory item. A flight (a.k.a. pricing period) represents the inventory item pricing information for a specific period of time. + pub flights: Option>, + /// End date of this inventory item. + #[serde(rename="endDate")] + pub end_date: Option, + /// Pricing type of this inventory item. + #[serde(rename="pricingType")] + pub pricing_type: Option, + /// Cap cost type of this inventory item. + #[serde(rename="capCostType")] + pub cap_cost_type: Option, +} + +impl Part for Pricing {} + + +/// Publisher Dynamic Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivityPublisherDynamicTag { + /// Whether this tag is applicable only for view-throughs. + #[serde(rename="viewThrough")] + pub view_through: Option, + /// Site ID of this dynamic tag. + #[serde(rename="siteId")] + pub site_id: Option, + /// Whether this tag is applicable only for click-throughs. + #[serde(rename="clickThrough")] + pub click_through: Option, + /// Directory site ID of this dynamic tag. This is a write-only field that can be used as an alternative to the siteId field. When this resource is retrieved, only the siteId field will be populated. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Dynamic floodlight tag. + #[serde(rename="dynamicTag")] + pub dynamic_tag: Option, +} + +impl Part for FloodlightActivityPublisherDynamicTag {} + + +/// Contains information about where a user's browser is taken after the user clicks an ad. +/// +/// # 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 landing pages](struct.LandingPageUpdateCall.html) (request|response) +/// * [list landing pages](struct.LandingPageListCall.html) (none) +/// * [patch landing pages](struct.LandingPagePatchCall.html) (request|response) +/// * [insert landing pages](struct.LandingPageInsertCall.html) (request|response) +/// * [delete landing pages](struct.LandingPageDeleteCall.html) (none) +/// * [get landing pages](struct.LandingPageGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LandingPage { + /// Whether or not this landing page will be assigned to any ads or creatives that do not have a landing page assigned explicitly. Only one default landing page is allowed per campaign. + pub default: Option, + /// URL of this landing page. This is a required field. + pub url: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPage". + pub kind: Option, + /// ID of this landing page. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this landing page. This is a required field. It must be less than 256 characters long, and must be unique among landing pages of the same campaign. + pub name: Option, +} + +impl RequestValue for LandingPage {} +impl Resource for LandingPage {} +impl ResponseResult for LandingPage {} + + +/// Represents the dimensions of ads, placements, creatives, or creative assets. +/// +/// # 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 sizes](struct.SizeInsertCall.html) (request|response) +/// * [get sizes](struct.SizeGetCall.html) (response) +/// * [list sizes](struct.SizeListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Size { + /// Width of this size. + pub width: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#size". + pub kind: Option, + /// Height of this size. + pub height: Option, + /// ID of this size. This is a read-only, auto-generated field. + pub id: Option, + /// IAB standard size. This is a read-only, auto-generated field. + pub iab: Option, +} + +impl RequestValue for Size {} +impl Resource for Size {} +impl ResponseResult for Size {} + + +/// Contains information about a city that can be targeted by ads. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct City { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#city". + pub kind: Option, + /// DART ID of the country to which this city belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this city. + pub name: Option, + /// Country code of the country to which this city belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Metro region code of the metro region (DMA) to which this city belongs. + #[serde(rename="metroCode")] + pub metro_code: Option, + /// Region code of the region to which this city belongs. + #[serde(rename="regionCode")] + pub region_code: Option, + /// ID of the metro region (DMA) to which this city belongs. + #[serde(rename="metroDmaId")] + pub metro_dma_id: Option, + /// DART ID of this city. This is the ID used for targeting and generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// DART ID of the region to which this city belongs. + #[serde(rename="regionDartId")] + pub region_dart_id: Option, +} + +impl Part for City {} + + +/// Click Through URL Suffix settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClickThroughUrlSuffixProperties { + /// Click-through URL suffix to apply to all ads in this entity's scope. Must be less than 128 characters long. + #[serde(rename="clickThroughUrlSuffix")] + pub click_through_url_suffix: Option, + /// Whether this entity should override the inherited click-through URL suffix with its own defined value. + #[serde(rename="overrideInheritedSuffix")] + pub override_inherited_suffix: Option, +} + +impl Part for ClickThroughUrlSuffixProperties {} + + +/// Contains properties of a package or roadblock. +/// +/// # 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 placement groups](struct.PlacementGroupUpdateCall.html) (request|response) +/// * [patch placement groups](struct.PlacementGroupPatchCall.html) (request|response) +/// * [get placement groups](struct.PlacementGroupGetCall.html) (response) +/// * [insert placement groups](struct.PlacementGroupInsertCall.html) (request|response) +/// * [list placement groups](struct.PlacementGroupListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementGroup { + /// Comments for this placement group. + pub comment: Option, + /// ID of the primary placement, used to calculate the media cost of a roadblock (placement group). Modifying this field will automatically modify the primary field on all affected roadblock child placements. + #[serde(rename="primaryPlacementId")] + pub primary_placement_id: Option, + /// Campaign ID of this placement group. This field is required on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Dimension value for the ID of the primary placement. This is a read-only, auto-generated field. + #[serde(rename="primaryPlacementIdDimensionValue")] + pub primary_placement_id_dimension_value: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Advertiser ID of this placement group. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Directory site ID associated with this placement group. On insert, you must set either this field or the site_id field to specify the site associated with this placement group. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Information about the creation of this placement group. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Site ID associated with this placement group. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement group. This is a required field that is read-only after insertion. + #[serde(rename="siteId")] + pub site_id: Option, + /// Pricing schedule of this placement group. This field is required on insertion. + #[serde(rename="pricingSchedule")] + pub pricing_schedule: Option, + /// Dimension value for the ID of the site. This is a read-only, auto-generated field. + #[serde(rename="siteIdDimensionValue")] + pub site_id_dimension_value: Option, + /// Type of this placement group. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting. This field is required on insertion. + #[serde(rename="placementGroupType")] + pub placement_group_type: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Whether this placement group is archived. + pub archived: Option, + /// ID of this placement group. This is a read-only, auto-generated field. + pub id: Option, + /// ID of the placement strategy assigned to this placement group. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option, + /// Account ID of this placement group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Subaccount ID of this placement group. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this placement group. This is a required field and must be less than 256 characters long. + pub name: Option, + /// IDs of placements which are assigned to this placement group. This is a read-only, auto-generated field. + #[serde(rename="childPlacementIds")] + pub child_placement_ids: Option>, + /// Information about the most recent modification of this placement group. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroup". + pub kind: Option, + /// ID of the content category assigned to this placement group. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option, + /// External ID for this placement. + #[serde(rename="externalId")] + pub external_id: Option, + /// Dimension value for the ID of this placement group. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, +} + +impl RequestValue for PlacementGroup {} +impl Resource for PlacementGroup {} +impl ResponseResult for PlacementGroup {} + + +/// Third-party Tracking 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 ThirdPartyTrackingUrl { + /// URL for the specified third-party URL type. + pub url: Option, + /// Third-party URL type for in-stream video creatives. + #[serde(rename="thirdPartyUrlType")] + pub third_party_url_type: Option, +} + +impl Part for ThirdPartyTrackingUrl {} + + +/// Represents a date range. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DateRange { + /// The start date of the date range, inclusive. A string of the format: "yyyy-MM-dd". + #[serde(rename="startDate")] + pub start_date: Option, + /// The kind of resource this is, in this case dfareporting#dateRange. + pub kind: Option, + /// The end date of the date range, inclusive. A string of the format: "yyyy-MM-dd". + #[serde(rename="endDate")] + pub end_date: Option, + /// The date range relative to the date of when the report is run. + #[serde(rename="relativeDateRange")] + pub relative_date_range: Option, +} + +impl Part for DateRange {} + + +/// Metro List Response +/// +/// # 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 metros](struct.MetroListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MetrosListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metrosListResponse". + pub kind: Option, + /// Metro collection. + pub metros: Option>, +} + +impl ResponseResult for MetrosListResponse {} + + +/// Pricing Schedule +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PricingSchedule { + /// Placement start date. This date must be later than, or the same day as, the campaign start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This field is required on insertion. + #[serde(rename="startDate")] + pub start_date: Option, + /// Placement end date. This date must be later than, or the same day as, the placement start date, but not later than the campaign end date. If, for example, you set 6/25/2015 as both the start and end dates, the effective placement date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This field is required on insertion. + #[serde(rename="endDate")] + pub end_date: Option, + /// Whether this placement is flighted. If true, pricing periods will be computed automatically. + pub flighted: Option, + /// Whether cap costs are ignored by ad serving. + #[serde(rename="disregardOverdelivery")] + pub disregard_overdelivery: Option, + /// Placement cap cost option. + #[serde(rename="capCostOption")] + pub cap_cost_option: Option, + /// Pricing periods for this placement. + #[serde(rename="pricingPeriods")] + pub pricing_periods: Option>, + /// Placement pricing type. This field is required on insertion. + #[serde(rename="pricingType")] + pub pricing_type: Option, + /// Testing start date of this placement. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. + #[serde(rename="testingStartDate")] + pub testing_start_date: Option, + /// Floodlight activity ID associated with this placement. This field should be set when placement pricing type is set to PRICING_TYPE_CPA. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option, +} + +impl Part for PricingSchedule {} + + +/// Account List Response +/// +/// # 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 accounts](struct.AccountListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountsListResponse". + pub kind: Option, + /// Account collection. + pub accounts: Option>, +} + +impl ResponseResult for AccountsListResponse {} + + +/// Targeting Template List Response +/// +/// # 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 targeting templates](struct.TargetingTemplateListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetingTemplatesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplatesListResponse". + pub kind: Option, + /// Targeting template collection. + #[serde(rename="targetingTemplates")] + pub targeting_templates: Option>, +} + +impl ResponseResult for TargetingTemplatesListResponse {} + + +/// Contains information about an operating system that can be targeted by ads. +/// +/// # 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 operating systems](struct.OperatingSystemGetCall.html) (response) +/// * [list operating systems](struct.OperatingSystemListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystem { + /// Whether this operating system is for mobile. + pub mobile: Option, + /// DART ID of this operating system. This is the ID used for targeting. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Whether this operating system is for desktop. + pub desktop: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystem". + pub kind: Option, + /// Name of this operating system. + pub name: Option, +} + +impl Resource for OperatingSystem {} +impl ResponseResult for OperatingSystem {} + + +/// The original conversion that was inserted or updated and whether there were any errors. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionStatus { + /// The original conversion that was inserted or updated. + pub conversion: Option, + /// A list of errors related to this conversion. + pub errors: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionStatus". + pub kind: Option, +} + +impl Part for ConversionStatus {} + + +/// Represents an activity group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Activities { + /// The kind of resource this is, in this case dfareporting#activities. + pub kind: Option, + /// List of activity filters. The dimension values need to be all either of type "dfa:activity" or "dfa:activityGroup". + pub filters: Option>, + /// List of names of floodlight activity metrics. + #[serde(rename="metricNames")] + pub metric_names: Option>, +} + +impl Part for Activities {} + + +/// A group clause made up of list population terms representing constraints joined by ORs. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationClause { + /// Terms of this list population clause. Each clause is made up of list population terms representing constraints and are joined by ORs. + pub terms: Option>, +} + +impl Part for ListPopulationClause {} + + +/// Flight +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Flight { + /// Rate or cost of this flight. + #[serde(rename="rateOrCost")] + pub rate_or_cost: Option, + /// Inventory item flight start date. + #[serde(rename="startDate")] + pub start_date: Option, + /// Units of this flight. + pub units: Option, + /// Inventory item flight end date. + #[serde(rename="endDate")] + pub end_date: Option, +} + +impl Part for Flight {} + + +/// Represents a sorted dimension. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SortedDimension { + /// The kind of resource this is, in this case dfareporting#sortedDimension. + pub kind: Option, + /// The name of the dimension. + pub name: Option, + /// An optional sort order for the dimension column. + #[serde(rename="sortOrder")] + pub sort_order: Option, +} + +impl Part for SortedDimension {} + + +/// Placement Strategy List Response +/// +/// # 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 placement strategies](struct.PlacementStrategyListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementStrategiesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategiesListResponse". + pub kind: Option, + /// Placement strategy collection. + #[serde(rename="placementStrategies")] + pub placement_strategies: Option>, +} + +impl ResponseResult for PlacementStrategiesListResponse {} + + +/// Language Targeting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LanguageTargeting { + /// Languages that this ad targets. For each language only languageId is required. The other fields are populated automatically when the ad is inserted or updated. + pub languages: Option>, +} + +impl Part for LanguageTargeting {} + + +/// Third Party Authentication Token +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThirdPartyAuthenticationToken { + /// Name of the third-party authentication token. + pub name: Option, + /// Value of the third-party authentication token. This is a read-only, auto-generated field. + pub value: Option, +} + +impl Part for ThirdPartyAuthenticationToken {} + + +/// Groups advertisers together so that reports can be generated for the entire group at once. +/// +/// # 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 advertiser groups](struct.AdvertiserGroupDeleteCall.html) (none) +/// * [get advertiser groups](struct.AdvertiserGroupGetCall.html) (response) +/// * [update advertiser groups](struct.AdvertiserGroupUpdateCall.html) (request|response) +/// * [list advertiser groups](struct.AdvertiserGroupListCall.html) (none) +/// * [patch advertiser groups](struct.AdvertiserGroupPatchCall.html) (request|response) +/// * [insert advertiser groups](struct.AdvertiserGroupInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdvertiserGroup { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroup". + pub kind: Option, + /// Account ID of this advertiser group. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this advertiser group. This is a read-only, auto-generated field. + pub id: Option, + /// Name of this advertiser group. This is a required field and must be less than 256 characters long and unique among advertiser groups of the same account. + pub name: Option, +} + +impl RequestValue for AdvertiserGroup {} +impl Resource for AdvertiserGroup {} +impl ResponseResult for AdvertiserGroup {} + + +/// FsCommand. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FsCommand { + /// Height of the window. + #[serde(rename="windowHeight")] + pub window_height: Option, + /// Distance from the top of the browser. Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. + pub top: Option, + /// Width of the window. + #[serde(rename="windowWidth")] + pub window_width: Option, + /// Position in the browser where the window will open. + #[serde(rename="positionOption")] + pub position_option: Option, + /// Distance from the left of the browser.Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. + pub left: Option, +} + +impl Part for FsCommand {} + + +/// Creative optimization settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeOptimizationConfiguration { + /// List of optimization activities associated with this configuration. + #[serde(rename="optimizationActivitys")] + pub optimization_activitys: Option>, + /// ID of this creative optimization config. This field is auto-generated when the campaign is inserted or updated. It can be null for existing campaigns. + pub id: Option, + /// Name of this creative optimization config. This is a required field and must be less than 129 characters long. + pub name: Option, + /// Optimization model for this configuration. + #[serde(rename="optimizationModel")] + pub optimization_model: Option, +} + +impl Part for CreativeOptimizationConfiguration {} + + +/// Creative Group List Response +/// +/// # 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 creative groups](struct.CreativeGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeGroupsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Creative group collection. + #[serde(rename="creativeGroups")] + pub creative_groups: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroupsListResponse". + pub kind: Option, +} + +impl ResponseResult for CreativeGroupsListResponse {} + + +/// Offset Position. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OffsetPosition { + /// Offset distance from top side of an asset or a window. + pub top: Option, + /// Offset distance from left side of an asset or a window. + pub left: Option, +} + +impl Part for OffsetPosition {} + + +/// Target Window. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetWindow { + /// User-entered value. + #[serde(rename="customHtml")] + pub custom_html: Option, + /// Type of browser window for which the backup image of the flash creative can be displayed. + #[serde(rename="targetWindowOption")] + pub target_window_option: Option, +} + +impl Part for TargetWindow {} + + +/// Contains properties of a user role permission. +/// +/// # 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 user role permissions](struct.UserRolePermissionGetCall.html) (response) +/// * [list user role permissions](struct.UserRolePermissionListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolePermission { + /// ID of the permission group that this user role permission belongs to. + #[serde(rename="permissionGroupId")] + pub permission_group_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermission". + pub kind: Option, + /// Levels of availability for a user role permission. + pub availability: Option, + /// ID of this user role permission. + pub id: Option, + /// Name of this user role permission. + pub name: Option, +} + +impl Resource for UserRolePermission {} +impl ResponseResult for UserRolePermission {} + + +/// Site Contact +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SiteContact { + /// First name of this site contact. + #[serde(rename="firstName")] + pub first_name: Option, + /// Title or designation of this site contact. + pub title: Option, + /// Last name of this site contact. + #[serde(rename="lastName")] + pub last_name: Option, + /// Site contact type. + #[serde(rename="contactType")] + pub contact_type: Option, + /// ID of this site contact. This is a read-only, auto-generated field. + pub id: Option, + /// Primary phone number of this site contact. + pub phone: Option, + /// Address of this site contact. + pub address: Option, + /// Email address of this site contact. This is a required field. + pub email: Option, +} + +impl Part for SiteContact {} + + +/// Creative Rotation. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeRotation { + /// Creative assignments in this creative rotation. + #[serde(rename="creativeAssignments")] + pub creative_assignments: Option>, + /// Strategy for calculating weights. Used with CREATIVE_ROTATION_TYPE_RANDOM. + #[serde(rename="weightCalculationStrategy")] + pub weight_calculation_strategy: Option, + /// Creative optimization configuration that is used by this ad. It should refer to one of the existing optimization configurations in the ad's campaign. If it is unset or set to 0, then the campaign's default optimization configuration will be used for this ad. + #[serde(rename="creativeOptimizationConfigurationId")] + pub creative_optimization_configuration_id: Option, + /// Type of creative rotation. Can be used to specify whether to use sequential or random rotation. + #[serde(rename="type")] + pub type_: Option, +} + +impl Part for CreativeRotation {} + + +/// Contains information about a metro region that can be targeted by ads. +/// +/// # 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 metros](struct.MetroListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Metro { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metro". + pub kind: Option, + /// DART ID of the country to which this metro region belongs. + #[serde(rename="countryDartId")] + pub country_dart_id: Option, + /// Name of this metro region. + pub name: Option, + /// Country code of the country to which this metro region belongs. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Metro code of this metro region. This is equivalent to dma_id. + #[serde(rename="metroCode")] + pub metro_code: Option, + /// DART ID of this metro region. + #[serde(rename="dartId")] + pub dart_id: Option, + /// DMA ID of this metro region. This is the ID used for targeting and generating reports, and is equivalent to metro_code. + #[serde(rename="dmaId")] + pub dma_id: Option, +} + +impl Resource for Metro {} + + +/// Contains information about a country that can be targeted by ads. +/// +/// # 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 countries](struct.CountryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Country { + /// DART ID of this country. This is the ID used for targeting and generating reports. + #[serde(rename="dartId")] + pub dart_id: Option, + /// Whether ad serving supports secure servers in this country. + #[serde(rename="sslEnabled")] + pub ssl_enabled: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#country". + pub kind: Option, + /// Country code. + #[serde(rename="countryCode")] + pub country_code: Option, + /// Name of this country. + pub name: Option, +} + +impl ResponseResult for Country {} + + +/// Postal Code List Response +/// +/// # 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 postal codes](struct.PostalCodeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PostalCodesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCodesListResponse". + pub kind: Option, + /// Postal code collection. + #[serde(rename="postalCodes")] + pub postal_codes: Option>, +} + +impl ResponseResult for PostalCodesListResponse {} + + +/// Tag Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TagSetting { + /// Whether static landing page URLs should be included in the tags. This setting applies only to placements. + #[serde(rename="includeClickThroughUrls")] + pub include_click_through_urls: Option, + /// Whether click-tracking string should be included in the tags. + #[serde(rename="includeClickTracking")] + pub include_click_tracking: Option, + /// Additional key-values to be included in tags. Each key-value pair must be of the form key=value, and pairs must be separated by a semicolon (;). Keys and values must not contain commas. For example, id=2;color=red is a valid value for this field. + #[serde(rename="additionalKeyValues")] + pub additional_key_values: Option, + /// Option specifying how keywords are embedded in ad tags. This setting can be used to specify whether keyword placeholders are inserted in placement tags for this site. Publishers can then add keywords to those placeholders. + #[serde(rename="keywordOption")] + pub keyword_option: Option, +} + +impl Part for TagSetting {} + + +/// Contains properties of a creative field. +/// +/// # 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 creative fields](struct.CreativeFieldListCall.html) (none) +/// * [update creative fields](struct.CreativeFieldUpdateCall.html) (request|response) +/// * [get creative fields](struct.CreativeFieldGetCall.html) (response) +/// * [insert creative fields](struct.CreativeFieldInsertCall.html) (request|response) +/// * [delete creative fields](struct.CreativeFieldDeleteCall.html) (none) +/// * [patch creative fields](struct.CreativeFieldPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeField { + /// Advertiser ID of this creative field. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField". + pub kind: Option, + /// Subaccount ID of this creative field. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this creative field. This is a required field and must be less than 256 characters long and unique among creative fields of the same advertiser. + pub name: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this creative field. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this creative field. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for CreativeField {} +impl Resource for CreativeField {} +impl ResponseResult for CreativeField {} + + +/// Creative Field Value List Response +/// +/// # 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 creative field values](struct.CreativeFieldValueListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CreativeFieldValuesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValuesListResponse". + pub kind: Option, + /// Creative field value collection. + #[serde(rename="creativeFieldValues")] + pub creative_field_values: Option>, +} + +impl ResponseResult for CreativeFieldValuesListResponse {} + + +/// The properties of the report. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportFloodlightCriteriaReportProperties { + /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. + #[serde(rename="includeUnattributedIPConversions")] + pub include_unattributed_ip_conversions: Option, + /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. + #[serde(rename="includeUnattributedCookieConversions")] + pub include_unattributed_cookie_conversions: Option, + /// Include conversions that have no cookie, but do have an exposure path. + #[serde(rename="includeAttributedIPConversions")] + pub include_attributed_ip_conversions: Option, +} + +impl NestedType for ReportFloodlightCriteriaReportProperties {} +impl Part for ReportFloodlightCriteriaReportProperties {} + + +/// Insert Conversions Response. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionsBatchInsertResponse { + /// The status of each conversion's insertion status. The status is returned in the same order that conversions are inserted. + pub status: Option>, + /// Indicates that some or all conversions failed to insert. + #[serde(rename="hasFailures")] + pub has_failures: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertResponse". + pub kind: Option, +} + +impl ResponseResult for ConversionsBatchInsertResponse {} + + +/// Contains properties of a Site Directory contact. +/// +/// # 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 directory site contacts](struct.DirectorySiteContactGetCall.html) (response) +/// * [list directory site contacts](struct.DirectorySiteContactListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DirectorySiteContact { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContact". + pub kind: Option, + /// First name of this directory site contact. + #[serde(rename="firstName")] + pub first_name: Option, + /// Title or designation of this directory site contact. + pub title: Option, + /// Last name of this directory site contact. + #[serde(rename="lastName")] + pub last_name: Option, + /// ID of this directory site contact. This is a read-only, auto-generated field. + pub id: Option, + /// Phone number of this directory site contact. + pub phone: Option, + /// Directory site contact role. + pub role: Option, + /// Address of this directory site contact. + pub address: Option, + /// Directory site contact type. + #[serde(rename="type")] + pub type_: Option, + /// Email address of this directory site contact. + pub email: Option, +} + +impl Resource for DirectorySiteContact {} +impl ResponseResult for DirectorySiteContact {} + + +/// Represents a DimensionValue 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*). +/// +/// * [query dimension values](struct.DimensionValueQueryCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DimensionValue { + /// The name of the dimension. + #[serde(rename="dimensionName")] + pub dimension_name: Option, + /// The kind of resource this is, in this case dfareporting#dimensionValue. + pub kind: Option, + /// The eTag of this response for caching purposes. + pub etag: Option, + /// Determines how the 'value' field is matched when filtering. If not specified, defaults to EXACT. If set to WILDCARD_EXPRESSION, '*' is allowed as a placeholder for variable length character sequences, and it can be escaped with a backslash. Note, only paid search dimensions ('dfa:paidSearch*') allow a matchType other than EXACT. + #[serde(rename="matchType")] + pub match_type: Option, + /// The ID associated with the value if available. + pub id: Option, + /// The value of the dimension. + pub value: Option, +} + +impl Resource for DimensionValue {} + + +/// Content Category List Response +/// +/// # 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 content categories](struct.ContentCategoryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentCategoriesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategoriesListResponse". + pub kind: Option, + /// Content category collection. + #[serde(rename="contentCategories")] + pub content_categories: Option>, +} + +impl ResponseResult for ContentCategoriesListResponse {} + + +/// Floodlight Configuration List Response +/// +/// # 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 floodlight configurations](struct.FloodlightConfigurationListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightConfigurationsListResponse { + /// Floodlight configuration collection. + #[serde(rename="floodlightConfigurations")] + pub floodlight_configurations: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfigurationsListResponse". + pub kind: Option, +} + +impl ResponseResult for FloodlightConfigurationsListResponse {} + + +/// Describes properties of a DoubleClick Planning order. +/// +/// # 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 orders](struct.OrderListCall.html) (none) +/// * [get orders](struct.OrderGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Order { + /// Terms and conditions of this order. + #[serde(rename="termsAndConditions")] + pub terms_and_conditions: Option, + /// Name of the buyer organization. + #[serde(rename="buyerOrganizationName")] + pub buyer_organization_name: Option, + /// Advertiser ID of this order. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Site IDs this order is associated with. + #[serde(rename="siteId")] + pub site_id: Option>, + /// Buyer invoice ID associated with this order. + #[serde(rename="buyerInvoiceId")] + pub buyer_invoice_id: Option, + /// ID of the terms and conditions template used in this order. + #[serde(rename="planningTermId")] + pub planning_term_id: Option, + /// ID of this order. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this order. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#order". + pub kind: Option, + /// Subaccount ID of this order. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this order. + pub name: Option, + /// Contacts for this order. + pub contacts: Option>, + /// Information about the most recent modification of this order. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Notes of this order. + pub notes: Option, + /// Name of the seller organization. + #[serde(rename="sellerOrganizationName")] + pub seller_organization_name: Option, + /// Comments in this order. + pub comments: Option, + /// IDs for users that have to approve documents created for this order. + #[serde(rename="approverUserProfileIds")] + pub approver_user_profile_ids: Option>, + /// Seller order ID associated with this order. + #[serde(rename="sellerOrderId")] + pub seller_order_id: Option, + /// Project ID of this order. + #[serde(rename="projectId")] + pub project_id: Option, + /// Free-form site names this order is associated with. + #[serde(rename="siteNames")] + pub site_names: Option>, +} + +impl Resource for Order {} +impl ResponseResult for Order {} + + +/// A custom floodlight variable. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CustomFloodlightVariable { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#customFloodlightVariable". + pub kind: Option, + /// The type of custom floodlight variable to supply a value for. These map to the "u[1-20]=" in the tags. + #[serde(rename="type")] + pub type_: Option, + /// The value of the custom floodlight variable. The length of string must not exceed 50 characters. + pub value: Option, +} + +impl Part for CustomFloodlightVariable {} + + +/// AccountPermissions contains information about a particular account permission. Some features of DCM require an account permission to be present in the account. +/// +/// # 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 account permissions](struct.AccountPermissionListCall.html) (none) +/// * [get account permissions](struct.AccountPermissionGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermission { + /// Permission group of this account permission. + #[serde(rename="permissionGroupId")] + pub permission_group_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermission". + pub kind: Option, + /// Name of this account permission. + pub name: Option, + /// Administrative level required to enable this account permission. + pub level: Option, + /// Account profiles associated with this account permission. + /// + /// Possible values are: + /// - "ACCOUNT_PROFILE_BASIC" + /// - "ACCOUNT_PROFILE_STANDARD" + #[serde(rename="accountProfiles")] + pub account_profiles: Option>, + /// ID of this account permission. + pub id: Option, +} + +impl Resource for AccountPermission {} +impl ResponseResult for AccountPermission {} + + +/// Contains properties of a DoubleClick Planning project. +/// +/// # 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 projects](struct.ProjectGetCall.html) (response) +/// * [list projects](struct.ProjectListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Project { + /// Start date of the project. + #[serde(rename="startDate")] + pub start_date: Option, + /// CPM that the advertiser is targeting. + #[serde(rename="targetCpmNanos")] + pub target_cpm_nanos: Option, + /// End date of the project. + #[serde(rename="endDate")] + pub end_date: Option, + /// Client billing code of this project. + #[serde(rename="clientBillingCode")] + pub client_billing_code: Option, + /// Overview of this project. + pub overview: Option, + /// Number of clicks that the advertiser is targeting. + #[serde(rename="targetClicks")] + pub target_clicks: Option, + /// CPA that the advertiser is targeting. + #[serde(rename="targetCpaNanos")] + pub target_cpa_nanos: Option, + /// Advertiser ID of this project. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Number of impressions that the advertiser is targeting. + #[serde(rename="targetImpressions")] + pub target_impressions: Option, + /// Subaccount ID of this project. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Audience gender of this project. + #[serde(rename="audienceGender")] + pub audience_gender: Option, + /// ID of this project. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this project. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#project". + pub kind: Option, + /// CPC that the advertiser is targeting. + #[serde(rename="targetCpcNanos")] + pub target_cpc_nanos: Option, + /// Name of this project. + pub name: Option, + /// vCPM from Active View that the advertiser is targeting. + #[serde(rename="targetCpmActiveViewNanos")] + pub target_cpm_active_view_nanos: Option, + /// Information about the most recent modification of this project. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Budget of this project in the currency specified by the current account. The value stored in this field represents only the non-fractional amount. For example, for USD, the smallest value that can be represented by this field is 1 US dollar. + pub budget: Option, + /// Audience age group of this project. + #[serde(rename="audienceAgeGroup")] + pub audience_age_group: Option, + /// Number of conversions that the advertiser is targeting. + #[serde(rename="targetConversions")] + pub target_conversions: Option, + /// Name of the project client. + #[serde(rename="clientName")] + pub client_name: Option, +} + +impl Resource for Project {} +impl ResponseResult for Project {} + + +/// Popup Window Properties. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PopupWindowProperties { + /// Whether to display the browser status bar. + #[serde(rename="showStatusBar")] + pub show_status_bar: Option, + /// Whether to display the browser scroll bar. + #[serde(rename="showScrollBar")] + pub show_scroll_bar: Option, + /// Whether to display the browser address bar. + #[serde(rename="showAddressBar")] + pub show_address_bar: Option, + /// Whether to display the browser menu bar. + #[serde(rename="showMenuBar")] + pub show_menu_bar: Option, + /// Title of popup window. + pub title: Option, + /// Upper-left corner coordinates of the popup window. Applicable if positionType is COORDINATES. + pub offset: Option, + /// Popup window position either centered or at specific coordinate. + #[serde(rename="positionType")] + pub position_type: Option, + /// Whether to display the browser tool bar. + #[serde(rename="showToolBar")] + pub show_tool_bar: Option, + /// Popup dimension for a creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID + pub dimension: Option, +} + +impl Part for PopupWindowProperties {} + + +/// Contains properties of a DCM ad. +/// +/// # 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 ads](struct.AdPatchCall.html) (request|response) +/// * [list ads](struct.AdListCall.html) (none) +/// * [insert ads](struct.AdInsertCall.html) (request|response) +/// * [get ads](struct.AdGetCall.html) (response) +/// * [update ads](struct.AdUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Ad { + /// Click-through URL suffix properties for this ad. Applies to the URL in the ad or (if overriding ad properties) the URL in the creative. + #[serde(rename="clickThroughUrlSuffixProperties")] + pub click_through_url_suffix_properties: Option, + /// Campaign ID of this ad. This is a required field on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Language targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="languageTargeting")] + pub language_targeting: Option, + /// Advertiser ID of this ad. This is a required field on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="geoTargeting")] + pub geo_targeting: Option, + /// Comments for this ad. + pub comments: Option, + /// Delivery schedule information for this ad. Applicable when type is AD_SERVING_STANDARD_AD or AD_SERVING_TRACKING. This field along with subfields priority and impressionRatio are required on insertion when type is AD_SERVING_STANDARD_AD. + #[serde(rename="deliverySchedule")] + pub delivery_schedule: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Event tag overrides for this ad. + #[serde(rename="eventTagOverrides")] + pub event_tag_overrides: Option>, + /// ID of this ad. This is a read-only, auto-generated field. + pub id: Option, + /// Size of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. + pub size: Option, + /// Whether this ad is archived. + pub archived: Option, + /// Targeting template ID, used to apply preconfigured targeting information to this ad. This cannot be set while any of dayPartTargeting, geoTargeting, keyValueTargetingExpression, languageTargeting, remarketingListExpression, or technologyTargeting are set. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="targetingTemplateId")] + pub targeting_template_id: Option, + /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="technologyTargeting")] + pub technology_targeting: Option, + /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment. + #[serde(rename="creativeRotation")] + pub creative_rotation: Option, + /// Click-through URL for this ad. This is a required field on insertion. Applicable when type is AD_SERVING_CLICK_TRACKER. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option, + /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments. + #[serde(rename="creativeGroupAssignments")] + pub creative_group_assignments: Option>, + /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="remarketingListExpression")] + pub remarketing_list_expression: Option, + /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Account ID of this ad. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Type of ad. This is a required field on insertion. Note that default ads (AD_SERVING_DEFAULT_AD) cannot be created directly (see Creative resource). + #[serde(rename="type")] + pub type_: Option, + /// Whether this ad requires ssl. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslRequired")] + pub ssl_required: Option, + /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="audienceSegmentId")] + pub audience_segment_id: Option, + /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="keyValueTargetingExpression")] + pub key_value_targeting_expression: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Default click-through event tag properties for this ad. + #[serde(rename="defaultClickThroughEventTagProperties")] + pub default_click_through_event_tag_properties: Option, + /// Information about the creation of this ad. This is a read-only field. + #[serde(rename="createInfo")] + pub create_info: Option, + /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion. + #[serde(rename="startTime")] + pub start_time: Option, + /// Whether this ad is active. + pub active: Option, + /// Compatibility of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to either rendering on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are only used for existing default ads. New mobile placements must be assigned DISPLAY or DISPLAY_INTERSTITIAL and default ads created for those placements will be limited to those compatibility types. IN_STREAM_VIDEO refers to rendering in-stream video ads developed with the VAST standard. + pub compatibility: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ad". + pub kind: Option, + /// Subaccount ID of this ad. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this ad. This is a required field and must be less than 256 characters long. + pub name: Option, + /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD. + #[serde(rename="dayPartTargeting")] + pub day_part_targeting: Option, + /// Information about the most recent modification of this ad. This is a read-only field. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option, + /// Whether this ad is ssl compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Date and time that this ad should stop serving. Must be later than the start time. This is a required field on insertion. + #[serde(rename="endTime")] + pub end_time: Option, + /// Whether this ad is a dynamic click tracker. Applicable when type is AD_SERVING_CLICK_TRACKER. This is a required field on insert, and is read-only after insert. + #[serde(rename="dynamicClickTracker")] + pub dynamic_click_tracker: Option, + /// Placement assignments for this ad. + #[serde(rename="placementAssignments")] + pub placement_assignments: Option>, +} + +impl RequestValue for Ad {} +impl Resource for Ad {} +impl ResponseResult for Ad {} + + +/// Pricing Period +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PricingSchedulePricingPeriod { + /// Units of this pricing period. + pub units: Option, + /// Pricing period start date. This date must be later than, or the same day as, the placement start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. + #[serde(rename="startDate")] + pub start_date: Option, + /// Rate or cost of this pricing period. + #[serde(rename="rateOrCostNanos")] + pub rate_or_cost_nanos: Option, + /// Pricing period end date. This date must be later than, or the same day as, the pricing period start date, but not later than the placement end date. The period end date can be the same date as the period start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective pricing period date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. + #[serde(rename="endDate")] + pub end_date: Option, + /// Comments for this pricing period. + #[serde(rename="pricingComment")] + pub pricing_comment: Option, +} + +impl Part for PricingSchedulePricingPeriod {} + + +/// Contains properties of an event tag. +/// +/// # 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 event tags](struct.EventTagDeleteCall.html) (none) +/// * [patch event tags](struct.EventTagPatchCall.html) (request|response) +/// * [list event tags](struct.EventTagListCall.html) (none) +/// * [update event tags](struct.EventTagUpdateCall.html) (request|response) +/// * [insert event tags](struct.EventTagInsertCall.html) (request|response) +/// * [get event tags](struct.EventTagGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTag { + /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field. + pub status: Option, + /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter. + #[serde(rename="siteIds")] + pub site_ids: Option>, + /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option, + /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads. + #[serde(rename="enabledByDefault")] + pub enabled_by_default: Option, + /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites. + #[serde(rename="siteFilterType")] + pub site_filter_type: Option, + /// Event tag type. Can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. This is a required field. + #[serde(rename="type")] + pub type_: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// ID of this event tag. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag". + pub kind: Option, + /// Subaccount ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this event tag. This is a required field and must be less than 256 characters long. + pub name: Option, + /// Payload URL for this event tag. The URL on a click-through event tag should have a landing page URL appended to the end of it. This field is required on insertion. + pub url: Option, + /// Whether this tag is SSL-compliant or not. This is a read-only field. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option, + /// Whether to remove this event tag from ads that are trafficked through DoubleClick Bid Manager to Ad Exchange. This may be useful if the event tag uses a pixel that is unapproved for Ad Exchange bids on one or more networks, such as the Google Display Network. + #[serde(rename="excludeFromAdxRequests")] + pub exclude_from_adx_requests: Option, + /// Number of times the landing page URL should be URL-escaped before being appended to the click-through event tag URL. Only applies to click-through event tags as specified by the event tag type. + #[serde(rename="urlEscapeLevels")] + pub url_escape_levels: Option, +} + +impl RequestValue for EventTag {} +impl Resource for EventTag {} +impl ResponseResult for EventTag {} + + +/// Placement Assignment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementAssignment { + /// Whether this placement assignment is active. When true, the placement will be included in the ad's rotation. + pub active: Option, + /// Dimension value for the ID of the placement. This is a read-only, auto-generated field. + #[serde(rename="placementIdDimensionValue")] + pub placement_id_dimension_value: Option, + /// ID of the placement to be assigned. This is a required field. + #[serde(rename="placementId")] + pub placement_id: Option, + /// Whether the placement to be assigned requires SSL. This is a read-only field that is auto-generated when the ad is inserted or updated. + #[serde(rename="sslRequired")] + pub ssl_required: Option, +} + +impl Part for PlacementAssignment {} + + +/// Represents fields that are compatible to be selected for a report of type "REACH". +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReachReportCompatibleFields { + /// Metrics which are compatible to be selected in the "metricNames" section of the report. + pub metrics: Option>, + /// The kind of resource this is, in this case dfareporting#reachReportCompatibleFields. + pub kind: Option, + /// Dimensions which are compatible to be selected in the "dimensions" section of the report. + pub dimensions: Option>, + /// Metrics which are compatible to be selected in the "reachByFrequencyMetricNames" section of the report. + #[serde(rename="reachByFrequencyMetrics")] + pub reach_by_frequency_metrics: Option>, + /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. + #[serde(rename="dimensionFilters")] + pub dimension_filters: Option>, + /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. + #[serde(rename="pivotedActivityMetrics")] + pub pivoted_activity_metrics: Option>, +} + +impl Part for ReachReportCompatibleFields {} + + +/// Insert Conversions Request. +/// +/// # 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*). +/// +/// * [batchinsert conversions](struct.ConversionBatchinsertCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConversionsBatchInsertRequest { + /// The set of conversions to insert. + pub conversions: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertRequest". + pub kind: Option, + /// Describes how encryptedUserId or encryptedUserIdCandidates[] is encrypted. This is a required field if encryptedUserId or encryptedUserIdCandidates[] is used. + #[serde(rename="encryptionInfo")] + pub encryption_info: Option, +} + +impl RequestValue for ConversionsBatchInsertRequest {} + + +/// Contains properties of a site. +/// +/// # 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 sites](struct.SiteUpdateCall.html) (request|response) +/// * [list sites](struct.SiteListCall.html) (none) +/// * [insert sites](struct.SiteInsertCall.html) (request|response) +/// * [get sites](struct.SiteGetCall.html) (response) +/// * [patch sites](struct.SitePatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Site { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#site". + pub kind: Option, + /// Subaccount ID of this site. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this site.This is a required field. Must be less than 128 characters long. If this site is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this site is a top-level site, and the name must be unique among top-level sites of the same account. + pub name: Option, + /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. + #[serde(rename="directorySiteIdDimensionValue")] + pub directory_site_id_dimension_value: Option, + /// Site-wide settings. + #[serde(rename="siteSettings")] + pub site_settings: Option, + /// ID of this site. This is a read-only, auto-generated field. + pub id: Option, + /// Directory site associated with this site. This is a required field that is read-only after insertion. + #[serde(rename="directorySiteId")] + pub directory_site_id: Option, + /// Site contacts. + #[serde(rename="siteContacts")] + pub site_contacts: Option>, + /// Key name of this site. This is a read-only, auto-generated field. + #[serde(rename="keyName")] + pub key_name: Option, + /// Dimension value for the ID of this site. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, + /// Whether this site is approved. + pub approved: Option, + /// Account ID of this site. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, +} + +impl RequestValue for Site {} +impl Resource for Site {} +impl ResponseResult for Site {} + + +/// DFP Settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DfpSettings { + /// DFP network name for this directory site. + pub dfp_network_name: Option, + /// DFP network code for this directory site. + pub dfp_network_code: Option, + /// Whether this directory site is available only via DoubleClick Publisher Portal. + #[serde(rename="publisherPortalOnly")] + pub publisher_portal_only: Option, + /// Whether this directory site accepts programmatic placements. + #[serde(rename="programmaticPlacementAccepted")] + pub programmatic_placement_accepted: Option, + /// Whether this directory site accepts publisher-paid tags. + #[serde(rename="pubPaidPlacementAccepted")] + pub pub_paid_placement_accepted: Option, +} + +impl Part for DfpSettings {} + + +/// Connection Type List Response +/// +/// # 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 connection types](struct.ConnectionTypeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ConnectionTypesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionTypesListResponse". + pub kind: Option, + /// Collection of connection types such as broadband and mobile. + #[serde(rename="connectionTypes")] + pub connection_types: Option>, +} + +impl ResponseResult for ConnectionTypesListResponse {} + + +/// Contains properties of a Floodlight configuration. +/// +/// # 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 floodlight configurations](struct.FloodlightConfigurationGetCall.html) (response) +/// * [update floodlight configurations](struct.FloodlightConfigurationUpdateCall.html) (request|response) +/// * [patch floodlight configurations](struct.FloodlightConfigurationPatchCall.html) (request|response) +/// * [list floodlight configurations](struct.FloodlightConfigurationListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightConfiguration { + /// List of user defined variables enabled for this configuration. + #[serde(rename="userDefinedVariableConfigurations")] + pub user_defined_variable_configurations: Option>, + /// List of third-party authentication tokens enabled for this configuration. + #[serde(rename="thirdPartyAuthenticationTokens")] + pub third_party_authentication_tokens: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfiguration". + pub kind: Option, + /// Advertiser ID of the parent advertiser of this floodlight configuration. + #[serde(rename="advertiserId")] + pub advertiser_id: Option, + /// Configuration settings for dynamic and image floodlight tags. + #[serde(rename="tagSettings")] + pub tag_settings: Option, + /// Whether in-app attribution tracking is enabled. + #[serde(rename="inAppAttributionTrackingEnabled")] + pub in_app_attribution_tracking_enabled: Option, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option, + /// Subaccount ID of this floodlight configuration. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// ID of this floodlight configuration. This is a read-only, auto-generated field. + pub id: Option, + /// Account ID of this floodlight configuration. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// Types of attribution options for natural search conversions. + #[serde(rename="naturalSearchConversionAttributionOption")] + pub natural_search_conversion_attribution_option: Option, + /// Settings for DCM Omniture integration. + #[serde(rename="omnitureSettings")] + pub omniture_settings: Option, + /// Whether the exposure-to-conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting. + #[serde(rename="exposureToConversionEnabled")] + pub exposure_to_conversion_enabled: Option, + /// Lookback window settings for this floodlight configuration. + #[serde(rename="lookbackConfiguration")] + pub lookback_configuration: Option, + /// Day that will be counted as the first day of the week in reports. This is a required field. + #[serde(rename="firstDayOfWeek")] + pub first_day_of_week: Option, + /// List of standard variables enabled for this configuration. + /// + /// Acceptable values are: + /// - "ORD" + /// - "NUM" + #[serde(rename="standardVariableTypes")] + pub standard_variable_types: Option>, + /// Whether advertiser data is shared with Google Analytics. + #[serde(rename="analyticsDataSharingEnabled")] + pub analytics_data_sharing_enabled: Option, + /// Dimension value for the ID of this floodlight configuration. This is a read-only, auto-generated field. + #[serde(rename="idDimensionValue")] + pub id_dimension_value: Option, +} + +impl RequestValue for FloodlightConfiguration {} +impl Resource for FloodlightConfiguration {} +impl ResponseResult for FloodlightConfiguration {} + + +/// Account Permission Group List Response +/// +/// # 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 account permission groups](struct.AccountPermissionGroupListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccountPermissionGroupsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroupsListResponse". + pub kind: Option, + /// Account permission group collection. + #[serde(rename="accountPermissionGroups")] + pub account_permission_groups: Option>, +} + +impl ResponseResult for AccountPermissionGroupsListResponse {} + + +/// Size List Response +/// +/// # 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 sizes](struct.SizeListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SizesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sizesListResponse". + pub kind: Option, + /// Size collection. + pub sizes: Option>, +} + +impl ResponseResult for SizesListResponse {} + + +/// User Role List Response +/// +/// # 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 user roles](struct.UserRoleListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRolesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolesListResponse". + pub kind: Option, + /// User role collection. + #[serde(rename="userRoles")] + pub user_roles: Option>, +} + +impl ResponseResult for UserRolesListResponse {} + + +/// Floodlight Activity List Response +/// +/// # 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 floodlight activities](struct.FloodlightActivityListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FloodlightActivitiesListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesListResponse". + pub kind: Option, + /// Floodlight activity collection. + #[serde(rename="floodlightActivities")] + pub floodlight_activities: Option>, +} + +impl ResponseResult for FloodlightActivitiesListResponse {} + + +/// Contains properties of auser role, which is used to manage user access. +/// +/// # 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 user roles](struct.UserRoleInsertCall.html) (request|response) +/// * [update user roles](struct.UserRoleUpdateCall.html) (request|response) +/// * [delete user roles](struct.UserRoleDeleteCall.html) (none) +/// * [patch user roles](struct.UserRolePatchCall.html) (request|response) +/// * [list user roles](struct.UserRoleListCall.html) (none) +/// * [get user roles](struct.UserRoleGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserRole { + /// Whether this is a default user role. Default user roles are created by the system for the account/subaccount and cannot be modified or deleted. Each default user role comes with a basic set of preassigned permissions. + #[serde(rename="defaultUserRole")] + pub default_user_role: Option, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRole". + pub kind: Option, + /// Subaccount ID of this user role. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option, + /// Name of this user role. This is a required field. Must be less than 256 characters long. If this user role is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this user role is a top-level user role, and the name must be unique among top-level user roles of the same account. + pub name: Option, + /// ID of the user role that this user role is based on or copied from. This is a required field. + #[serde(rename="parentUserRoleId")] + pub parent_user_role_id: Option, + /// Account ID of this user role. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option, + /// ID of this user role. This is a read-only, auto-generated field. + pub id: Option, + /// List of permissions associated with this user role. + pub permissions: Option>, +} + +impl RequestValue for UserRole {} +impl Resource for UserRole {} +impl ResponseResult for UserRole {} + + + +// ################### +// MethodBuilders ### +// ################# + +/// A builder providing access to all methods supported on *conversion* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `batchinsert(...)` +/// // to build up your call. +/// let rb = hub.conversions(); +/// # } +/// ``` +pub struct ConversionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ConversionMethods<'a, C, A> {} + +impl<'a, C, A> ConversionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts conversions. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn batchinsert(&self, request: ConversionsBatchInsertRequest, profile_id: &str) -> ConversionBatchinsertCall<'a, C, A> { + ConversionBatchinsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRolePermissionGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_role_permission_groups(); +/// # } +/// ``` +pub struct UserRolePermissionGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRolePermissionGroupMethods<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role permission group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role permission group ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + UserRolePermissionGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 list of all supported user role permission groups. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRolePermissionGroupListCall<'a, C, A> { + UserRolePermissionGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *platformType* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.platform_types(); +/// # } +/// ``` +pub struct PlatformTypeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlatformTypeMethods<'a, C, A> {} + +impl<'a, C, A> PlatformTypeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one platform type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Platform type ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlatformTypeGetCall<'a, C, A> { + PlatformTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 platform types. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlatformTypeListCall<'a, C, A> { + PlatformTypeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *orderDocument* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.order_documents(); +/// # } +/// ``` +pub struct OrderDocumentMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OrderDocumentMethods<'a, C, A> {} + +impl<'a, C, A> OrderDocumentMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one order document by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + /// * `id` - Order document ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderDocumentGetCall<'a, C, A> { + OrderDocumentGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.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 order documents, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderDocumentListCall<'a, C, A> { + OrderDocumentListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _order_id: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _approved: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeField* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.creative_fields(); +/// # } +/// ``` +pub struct CreativeFieldMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeFieldMethods<'a, C, A> {} + +impl<'a, C, A> CreativeFieldMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: CreativeField, profile_id: &str) -> CreativeFieldUpdateCall<'a, C, A> { + CreativeFieldUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 creative fields, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeFieldListCall<'a, C, A> { + CreativeFieldListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing creative field. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn delete(&self, profile_id: &str, id: &str) -> CreativeFieldDeleteCall<'a, C, A> { + CreativeFieldDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative field by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn get(&self, profile_id: &str, id: &str) -> CreativeFieldGetCall<'a, C, A> { + CreativeFieldGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative field. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: CreativeField, profile_id: &str) -> CreativeFieldInsertCall<'a, C, A> { + CreativeFieldInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 creative field. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative Field ID + pub fn patch(&self, request: CreativeField, profile_id: &str, id: &str) -> CreativeFieldPatchCall<'a, C, A> { + CreativeFieldPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRole* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_roles(); +/// # } +/// ``` +pub struct UserRoleMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRoleMethods<'a, C, A> {} + +impl<'a, C, A> UserRoleMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new user role. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: UserRole, profile_id: &str) -> UserRoleInsertCall<'a, C, A> { + UserRoleInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRoleGetCall<'a, C, A> { + UserRoleGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 user role. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: UserRole, profile_id: &str) -> UserRoleUpdateCall<'a, C, A> { + UserRoleUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing user role. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn delete(&self, profile_id: &str, id: &str) -> UserRoleDeleteCall<'a, C, A> { + UserRoleDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 user role. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role ID. + pub fn patch(&self, request: UserRole, profile_id: &str, id: &str) -> UserRolePatchCall<'a, C, A> { + UserRolePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 user roles, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRoleListCall<'a, C, A> { + UserRoleListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _account_user_role_only: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *operatingSystemVersion* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.operating_system_versions(); +/// # } +/// ``` +pub struct OperatingSystemVersionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OperatingSystemVersionMethods<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system version by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Operating system version ID. + pub fn get(&self, profile_id: &str, id: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + OperatingSystemVersionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 operating system versions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> OperatingSystemVersionListCall<'a, C, A> { + OperatingSystemVersionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *landingPage* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.landing_pages(); +/// # } +/// ``` +pub struct LandingPageMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for LandingPageMethods<'a, C, A> {} + +impl<'a, C, A> LandingPageMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one campaign landing page by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn get(&self, profile_id: &str, campaign_id: &str, id: &str) -> LandingPageGetCall<'a, C, A> { + LandingPageGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: 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 campaign landing page. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn update(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageUpdateCall<'a, C, A> { + LandingPageUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.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 landing pages for the specified campaign. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn list(&self, profile_id: &str, campaign_id: &str) -> LandingPageListCall<'a, C, A> { + LandingPageListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new landing page for the specified campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + pub fn insert(&self, request: LandingPage, profile_id: &str, campaign_id: &str) -> LandingPageInsertCall<'a, C, A> { + LandingPageInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_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 campaign landing page. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn patch(&self, request: LandingPage, profile_id: &str, campaign_id: &str, id: &str) -> LandingPagePatchCall<'a, C, A> { + LandingPagePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing campaign landing page. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Landing page campaign ID. + /// * `id` - Landing page ID. + pub fn delete(&self, profile_id: &str, campaign_id: &str, id: &str) -> LandingPageDeleteCall<'a, C, A> { + LandingPageDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeAsset* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.creative_assets(); +/// # } +/// ``` +pub struct CreativeAssetMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeAssetMethods<'a, C, A> {} + +impl<'a, C, A> CreativeAssetMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative asset. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Advertiser ID of this creative. This is a required field. + pub fn insert(&self, request: CreativeAssetMetadata, profile_id: &str, advertiser_id: &str) -> CreativeAssetInsertCall<'a, C, A> { + CreativeAssetInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *campaignCreativeAssociation* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.campaign_creative_associations(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CampaignCreativeAssociationMethods<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Campaign ID in this association. + pub fn insert(&self, request: CampaignCreativeAssociation, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + CampaignCreativeAssociationInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.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 creative IDs associated with the specified campaign. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `campaignId` - Campaign ID in this association. + pub fn list(&self, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + CampaignCreativeAssociationListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _campaign_id: campaign_id.to_string(), + _sort_order: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *changeLog* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.change_logs(); +/// # } +/// ``` +pub struct ChangeLogMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ChangeLogMethods<'a, C, A> {} + +impl<'a, C, A> ChangeLogMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of change logs. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ChangeLogListCall<'a, C, A> { + ChangeLogListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _user_profile_ids: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _object_type: Default::default(), + _object_ids: Default::default(), + _min_change_time: Default::default(), + _max_results: Default::default(), + _max_change_time: Default::default(), + _ids: Default::default(), + _action: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one change log by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Change log ID. + pub fn get(&self, profile_id: &str, id: &str) -> ChangeLogGetCall<'a, C, A> { + ChangeLogGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *remarketingListShare* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.remarketing_list_shares(); +/// # } +/// ``` +pub struct RemarketingListShareMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for RemarketingListShareMethods<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list share by remarketing list ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `remarketingListId` - Remarketing list ID. + pub fn get(&self, profile_id: &str, remarketing_list_id: &str) -> RemarketingListShareGetCall<'a, C, A> { + RemarketingListShareGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _remarketing_list_id: remarketing_list_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 remarketing list share. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `remarketingListId` - Remarketing list ID. + pub fn patch(&self, request: RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, C, A> { + RemarketingListSharePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _remarketing_list_id: remarketing_list_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 remarketing list share. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: RemarketingListShare, profile_id: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + RemarketingListShareUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *report* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.reports(); +/// # } +/// ``` +pub struct ReportMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {} + +impl<'a, C, A> ReportMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Runs a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + pub fn run(&self, profile_id: &str, report_id: &str) -> ReportRunCall<'a, C, A> { + ReportRunCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _synchronous: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn patch(&self, request: Report, profile_id: &str, report_id: &str) -> ReportPatchCall<'a, C, A> { + ReportPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists files for a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the parent report. + pub fn files_list(&self, profile_id: &str, report_id: &str) -> ReportFileListCall<'a, C, A> { + ReportFileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: 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: + /// + /// Creates a report. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn insert(&self, request: Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { + ReportInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn update(&self, request: Report, profile_id: &str, report_id: &str) -> ReportUpdateCall<'a, C, A> { + ReportUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn compatible_fields_query(&self, request: Report, profile_id: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + ReportCompatibleFieldQueryCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn get(&self, profile_id: &str, report_id: &str) -> ReportGetCall<'a, C, A> { + ReportGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report file. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + /// * `fileId` - The ID of the report file. + pub fn files_get(&self, profile_id: &str, report_id: &str, file_id: &str) -> ReportFileGetCall<'a, C, A> { + ReportFileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _file_id: file_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn delete(&self, profile_id: &str, report_id: &str) -> ReportDeleteCall<'a, C, A> { + ReportDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of reports. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + pub fn list(&self, profile_id: &str) -> ReportListCall<'a, C, A> { + ReportListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _scope: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *advertiser* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.advertisers(); +/// # } +/// ``` +pub struct AdvertiserMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdvertiserMethods<'a, C, A> {} + +impl<'a, C, A> AdvertiserMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new advertiser. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Advertiser, profile_id: &str) -> AdvertiserInsertCall<'a, C, A> { + AdvertiserInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser ID. + pub fn patch(&self, request: Advertiser, profile_id: &str, id: &str) -> AdvertiserPatchCall<'a, C, A> { + AdvertiserPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 advertisers, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdvertiserListCall<'a, C, A> { + AdvertiserListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _status: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _only_parent: Default::default(), + _max_results: Default::default(), + _include_advertisers_without_groups_only: Default::default(), + _ids: Default::default(), + _floodlight_configuration_ids: Default::default(), + _advertiser_group_ids: 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 advertiser. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Advertiser, profile_id: &str) -> AdvertiserUpdateCall<'a, C, A> { + AdvertiserUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one advertiser by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGetCall<'a, C, A> { + AdvertiserGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *dimensionValue* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `query(...)` +/// // to build up your call. +/// let rb = hub.dimension_values(); +/// # } +/// ``` +pub struct DimensionValueMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DimensionValueMethods<'a, C, A> {} + +impl<'a, C, A> DimensionValueMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of report dimension values for a list of filters. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn query(&self, request: DimensionValueRequest, profile_id: &str) -> DimensionValueQueryCall<'a, C, A> { + DimensionValueQueryCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightActivityGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_activity_groups(); +/// # } +/// ``` +pub struct FloodlightActivityGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightActivityGroupMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight activity group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity Group ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + FloodlightActivityGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight activity group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity Group ID. + pub fn patch(&self, request: FloodlightActivityGroup, profile_id: &str, id: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + FloodlightActivityGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight activity groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + FloodlightActivityGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _type_: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _floodlight_configuration_id: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new floodlight activity group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { + FloodlightActivityGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 floodlight activity group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + FloodlightActivityGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *metro* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.metros(); +/// # } +/// ``` +pub struct MetroMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for MetroMethods<'a, C, A> {} + +impl<'a, C, A> MetroMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of metros. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> MetroListCall<'a, C, A> { + MetroListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *order* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.orders(); +/// # } +/// ``` +pub struct OrderMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OrderMethods<'a, C, A> {} + +impl<'a, C, A> OrderMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of orders, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderListCall<'a, C, A> { + OrderListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one order by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + /// * `id` - Order ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderGetCall<'a, C, A> { + OrderGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *language* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.languages(); +/// # } +/// ``` +pub struct LanguageMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for LanguageMethods<'a, C, A> {} + +impl<'a, C, A> LanguageMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of languages. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> LanguageListCall<'a, C, A> { + LanguageListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *directorySiteContact* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.directory_site_contacts(); +/// # } +/// ``` +pub struct DirectorySiteContactMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DirectorySiteContactMethods<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one directory site contact by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Directory site contact ID. + pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteContactGetCall<'a, C, A> { + DirectorySiteContactGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 directory site contacts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DirectorySiteContactListCall<'a, C, A> { + DirectorySiteContactListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userProfile* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_profiles(); +/// # } +/// ``` +pub struct UserProfileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserProfileMethods<'a, C, A> {} + +impl<'a, C, A> UserProfileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of user profiles for a user. + pub fn list(&self) -> UserProfileListCall<'a, C, A> { + UserProfileListCall { + hub: self.hub, + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one user profile by ID. + /// + /// # Arguments + /// + /// * `profileId` - The user profile ID. + pub fn get(&self, profile_id: &str) -> UserProfileGetCall<'a, C, A> { + UserProfileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *ad* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.ads(); +/// # } +/// ``` +pub struct AdMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdMethods<'a, C, A> {} + +impl<'a, C, A> AdMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing ad. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Ad ID. + pub fn patch(&self, request: Ad, profile_id: &str, id: &str) -> AdPatchCall<'a, C, A> { + AdPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new ad. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Ad, profile_id: &str) -> AdInsertCall<'a, C, A> { + AdInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 ads, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdListCall<'a, C, A> { + AdListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _type_: Default::default(), + _ssl_required: Default::default(), + _ssl_compliant: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _search_string: Default::default(), + _remarketing_list_ids: Default::default(), + _placement_ids: Default::default(), + _page_token: Default::default(), + _overridden_event_tag_id: Default::default(), + _max_results: Default::default(), + _landing_page_ids: Default::default(), + _ids: Default::default(), + _dynamic_click_tracker: Default::default(), + _creative_type: Default::default(), + _creative_optimization_configuration_ids: Default::default(), + _creative_ids: Default::default(), + _compatibility: Default::default(), + _campaign_ids: Default::default(), + _audience_segment_ids: Default::default(), + _archived: Default::default(), + _advertiser_id: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one ad by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Ad ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdGetCall<'a, C, A> { + AdGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 ad. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Ad, profile_id: &str) -> AdUpdateCall<'a, C, A> { + AdUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountPermission* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_permissions(); +/// # } +/// ``` +pub struct AccountPermissionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountPermissionMethods<'a, C, A> {} + +impl<'a, C, A> AccountPermissionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one account permission by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account permission ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGetCall<'a, C, A> { + AccountPermissionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 account permissions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountPermissionListCall<'a, C, A> { + AccountPermissionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *connectionType* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.connection_types(); +/// # } +/// ``` +pub struct ConnectionTypeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ConnectionTypeMethods<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of connection types. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ConnectionTypeListCall<'a, C, A> { + ConnectionTypeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one connection type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Connection type ID. + pub fn get(&self, profile_id: &str, id: &str) -> ConnectionTypeGetCall<'a, C, A> { + ConnectionTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *targetableRemarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.targetable_remarketing_lists(); +/// # } +/// ``` +pub struct TargetableRemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for TargetableRemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of targetable remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only targetable remarketing lists targetable by these advertisers. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> TargetableRemarketingListListCall<'a, C, A> { + TargetableRemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + TargetableRemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *advertiserGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.advertiser_groups(); +/// # } +/// ``` +pub struct AdvertiserGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AdvertiserGroupMethods<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one advertiser group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGroupGetCall<'a, C, A> { + AdvertiserGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 advertiser groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AdvertiserGroupListCall<'a, C, A> { + AdvertiserGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new advertiser group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupInsertCall<'a, C, A> { + AdvertiserGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { + AdvertiserGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 advertiser group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn patch(&self, request: AdvertiserGroup, profile_id: &str, id: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + AdvertiserGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing advertiser group. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Advertiser group ID. + pub fn delete(&self, profile_id: &str, id: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + AdvertiserGroupDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *site* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.sites(); +/// # } +/// ``` +pub struct SiteMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SiteMethods<'a, C, A> {} + +impl<'a, C, A> SiteMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Site, profile_id: &str) -> SiteInsertCall<'a, C, A> { + SiteInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one site by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Site ID. + pub fn get(&self, profile_id: &str, id: &str) -> SiteGetCall<'a, C, A> { + SiteGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 sites, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SiteListCall<'a, C, A> { + SiteListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _unmapped_site: Default::default(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _campaign_ids: Default::default(), + _approved: Default::default(), + _ad_words_site: Default::default(), + _accepts_publisher_paid_placements: Default::default(), + _accepts_interstitial_placements: Default::default(), + _accepts_in_stream_video_placements: 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 site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Site, profile_id: &str) -> SiteUpdateCall<'a, C, A> { + SiteUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 site. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Site ID. + pub fn patch(&self, request: Site, profile_id: &str, id: &str) -> SitePatchCall<'a, C, A> { + SitePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightActivity* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `generatetag(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_activities(); +/// # } +/// ``` +pub struct FloodlightActivityMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightActivityMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight activity by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGetCall<'a, C, A> { + FloodlightActivityGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight activities, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightActivityListCall<'a, C, A> { + FloodlightActivityListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _tag_string: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _floodlight_configuration_id: Default::default(), + _floodlight_activity_group_type: Default::default(), + _floodlight_activity_group_tag_string: Default::default(), + _floodlight_activity_group_name: Default::default(), + _floodlight_activity_group_ids: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new floodlight activity. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityInsertCall<'a, C, A> { + FloodlightActivityInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing floodlight activity. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn delete(&self, profile_id: &str, id: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + FloodlightActivityDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight activity. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight activity ID. + pub fn patch(&self, request: FloodlightActivity, profile_id: &str, id: &str) -> FloodlightActivityPatchCall<'a, C, A> { + FloodlightActivityPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates a tag for a floodlight activity. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn generatetag(&self, profile_id: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + FloodlightActivityGeneratetagCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _floodlight_activity_id: 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 floodlight activity. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityUpdateCall<'a, C, A> { + FloodlightActivityUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _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 `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.regions(); +/// # } +/// ``` +pub struct RegionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +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 a list of regions. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> RegionListCall<'a, C, A> { + RegionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.creative_groups(); +/// # } +/// ``` +pub struct CreativeGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeGroupMethods<'a, C, A> {} + +impl<'a, C, A> CreativeGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupInsertCall<'a, C, A> { + CreativeGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative group ID. + pub fn get(&self, profile_id: &str, id: &str) -> CreativeGroupGetCall<'a, C, A> { + CreativeGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 creative group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupUpdateCall<'a, C, A> { + CreativeGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 creative groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeGroupListCall<'a, C, A> { + CreativeGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _group_number: Default::default(), + _advertiser_ids: 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 creative group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative group ID. + pub fn patch(&self, request: CreativeGroup, profile_id: &str, id: &str) -> CreativeGroupPatchCall<'a, C, A> { + CreativeGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *targetingTemplate* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.targeting_templates(); +/// # } +/// ``` +pub struct TargetingTemplateMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for TargetingTemplateMethods<'a, C, A> {} + +impl<'a, C, A> TargetingTemplateMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing targeting template. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Targeting template ID. + pub fn patch(&self, request: TargetingTemplate, profile_id: &str, id: &str) -> TargetingTemplatePatchCall<'a, C, A> { + TargetingTemplatePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 targeting templates, optionally filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> TargetingTemplateListCall<'a, C, A> { + TargetingTemplateListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one targeting template by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Targeting template ID. + pub fn get(&self, profile_id: &str, id: &str) -> TargetingTemplateGetCall<'a, C, A> { + TargetingTemplateGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new targeting template. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: TargetingTemplate, profile_id: &str) -> TargetingTemplateInsertCall<'a, C, A> { + TargetingTemplateInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 targeting template. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: TargetingTemplate, profile_id: &str) -> TargetingTemplateUpdateCall<'a, C, A> { + TargetingTemplateUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *subaccount* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.subaccounts(); +/// # } +/// ``` +pub struct SubaccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SubaccountMethods<'a, C, A> {} + +impl<'a, C, A> SubaccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing subaccount. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Subaccount ID. + pub fn patch(&self, request: Subaccount, profile_id: &str, id: &str) -> SubaccountPatchCall<'a, C, A> { + SubaccountPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new subaccount. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Subaccount, profile_id: &str) -> SubaccountInsertCall<'a, C, A> { + SubaccountInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 subaccount. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Subaccount, profile_id: &str) -> SubaccountUpdateCall<'a, C, A> { + SubaccountUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 list of subaccounts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SubaccountListCall<'a, C, A> { + SubaccountListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one subaccount by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Subaccount ID. + pub fn get(&self, profile_id: &str, id: &str) -> SubaccountGetCall<'a, C, A> { + SubaccountGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *mobileCarrier* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.mobile_carriers(); +/// # } +/// ``` +pub struct MobileCarrierMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for MobileCarrierMethods<'a, C, A> {} + +impl<'a, C, A> MobileCarrierMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one mobile carrier by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Mobile carrier ID. + pub fn get(&self, profile_id: &str, id: &str) -> MobileCarrierGetCall<'a, C, A> { + MobileCarrierGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 mobile carriers. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> MobileCarrierListCall<'a, C, A> { + MobileCarrierListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *floodlightConfiguration* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.floodlight_configurations(); +/// # } +/// ``` +pub struct FloodlightConfigurationMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FloodlightConfigurationMethods<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight configuration by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight configuration ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + FloodlightConfigurationGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 floodlight configuration. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: FloodlightConfiguration, profile_id: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { + FloodlightConfigurationUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 floodlight configuration. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight configuration ID. + pub fn patch(&self, request: FloodlightConfiguration, profile_id: &str, id: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + FloodlightConfigurationPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 floodlight configurations, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> FloodlightConfigurationListCall<'a, C, A> { + FloodlightConfigurationListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *operatingSystem* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.operating_systems(); +/// # } +/// ``` +pub struct OperatingSystemMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for OperatingSystemMethods<'a, C, A> {} + +impl<'a, C, A> OperatingSystemMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of operating systems. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> OperatingSystemListCall<'a, C, A> { + OperatingSystemListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system by DART ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `dartId` - Operating system DART ID. + pub fn get(&self, profile_id: &str, dart_id: &str) -> OperatingSystemGetCall<'a, C, A> { + OperatingSystemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _dart_id: dart_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *file* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.files(); +/// # } +/// ``` +pub struct FileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for FileMethods<'a, C, A> {} + +impl<'a, C, A> FileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Lists files for a user profile. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + pub fn list(&self, profile_id: &str) -> FileListCall<'a, C, A> { + FileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _scope: Default::default(), + _page_token: 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: + /// + /// Retrieves a report file by its report ID and file ID. + /// + /// # Arguments + /// + /// * `reportId` - The ID of the report. + /// * `fileId` - The ID of the report file. + pub fn get(&self, report_id: &str, file_id: &str) -> FileGetCall<'a, C, A> { + FileGetCall { + hub: self.hub, + _report_id: report_id.to_string(), + _file_id: file_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placementGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.placement_groups(); +/// # } +/// ``` +pub struct PlacementGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementGroupMethods<'a, C, A> {} + +impl<'a, C, A> PlacementGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of placement groups, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementGroupListCall<'a, C, A> { + PlacementGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_ids: Default::default(), + _search_string: Default::default(), + _pricing_types: Default::default(), + _placement_strategy_ids: Default::default(), + _placement_group_type: Default::default(), + _page_token: Default::default(), + _min_start_date: Default::default(), + _min_end_date: Default::default(), + _max_start_date: Default::default(), + _max_results: Default::default(), + _max_end_date: Default::default(), + _ids: Default::default(), + _directory_site_ids: Default::default(), + _content_category_ids: Default::default(), + _campaign_ids: Default::default(), + _archived: Default::default(), + _advertiser_ids: 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 placement group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupUpdateCall<'a, C, A> { + PlacementGroupUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement group. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupInsertCall<'a, C, A> { + PlacementGroupInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement group ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementGroupGetCall<'a, C, A> { + PlacementGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 placement group. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement group ID. + pub fn patch(&self, request: PlacementGroup, profile_id: &str, id: &str) -> PlacementGroupPatchCall<'a, C, A> { + PlacementGroupPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *inventoryItem* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.inventory_items(); +/// # } +/// ``` +pub struct InventoryItemMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for InventoryItemMethods<'a, C, A> {} + +impl<'a, C, A> InventoryItemMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of inventory items, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> InventoryItemListCall<'a, C, A> { + InventoryItemListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _type_: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _page_token: Default::default(), + _order_id: Default::default(), + _max_results: Default::default(), + _in_plan: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one inventory item by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + /// * `id` - Inventory item ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> InventoryItemGetCall<'a, C, A> { + InventoryItemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *userRolePermission* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.user_role_permissions(); +/// # } +/// ``` +pub struct UserRolePermissionMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for UserRolePermissionMethods<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one user role permission by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User role permission ID. + pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGetCall<'a, C, A> { + UserRolePermissionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 list of user role permissions, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> UserRolePermissionListCall<'a, C, A> { + UserRolePermissionListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountPermissionGroup* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_permission_groups(); +/// # } +/// ``` +pub struct AccountPermissionGroupMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountPermissionGroupMethods<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the list of account permission groups. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountPermissionGroupListCall<'a, C, A> { + AccountPermissionGroupListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one account permission group by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account permission group ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + AccountPermissionGroupGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *contentCategory* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.content_categories(); +/// # } +/// ``` +pub struct ContentCategoryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for ContentCategoryMethods<'a, C, A> {} + +impl<'a, C, A> ContentCategoryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of content categories, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ContentCategoryListCall<'a, C, A> { + ContentCategoryListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: 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 content category. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryUpdateCall<'a, C, A> { + ContentCategoryUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new content category. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryInsertCall<'a, C, A> { + ContentCategoryInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing content category. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn delete(&self, profile_id: &str, id: &str) -> ContentCategoryDeleteCall<'a, C, A> { + ContentCategoryDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one content category by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn get(&self, profile_id: &str, id: &str) -> ContentCategoryGetCall<'a, C, A> { + ContentCategoryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 content category. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Content category ID. + pub fn patch(&self, request: ContentCategory, profile_id: &str, id: &str) -> ContentCategoryPatchCall<'a, C, A> { + ContentCategoryPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creative* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.creatives(); +/// # } +/// ``` +pub struct CreativeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeMethods<'a, C, A> {} + +impl<'a, C, A> CreativeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Creative, profile_id: &str) -> CreativeUpdateCall<'a, C, A> { + CreativeUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Creative, profile_id: &str) -> CreativeInsertCall<'a, C, A> { + CreativeInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative ID. + pub fn get(&self, profile_id: &str, id: &str) -> CreativeGetCall<'a, C, A> { + CreativeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 creatives, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CreativeListCall<'a, C, A> { + CreativeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _types: Default::default(), + _studio_creative_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _search_string: Default::default(), + _rendering_ids: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _creative_field_ids: Default::default(), + _companion_creative_ids: Default::default(), + _campaign_id: Default::default(), + _archived: Default::default(), + _advertiser_id: Default::default(), + _active: 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 creative. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Creative ID. + pub fn patch(&self, request: Creative, profile_id: &str, id: &str) -> CreativePatchCall<'a, C, A> { + CreativePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *campaign* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.campaigns(); +/// # } +/// ``` +pub struct CampaignMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CampaignMethods<'a, C, A> {} + +impl<'a, C, A> CampaignMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one campaign by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Campaign ID. + pub fn get(&self, profile_id: &str, id: &str) -> CampaignGetCall<'a, C, A> { + CampaignGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `defaultLandingPageName` - Default landing page name for this new campaign. Must be less than 256 characters long. + /// * `defaultLandingPageUrl` - Default landing page URL for this new campaign. + pub fn insert(&self, request: Campaign, profile_id: &str, default_landing_page_name: &str, default_landing_page_url: &str) -> CampaignInsertCall<'a, C, A> { + CampaignInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _default_landing_page_name: default_landing_page_name.to_string(), + _default_landing_page_url: default_landing_page_url.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 campaign. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Campaign ID. + pub fn patch(&self, request: Campaign, profile_id: &str, id: &str) -> CampaignPatchCall<'a, C, A> { + CampaignPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: 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 campaign. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Campaign, profile_id: &str) -> CampaignUpdateCall<'a, C, A> { + CampaignUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 campaigns, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CampaignListCall<'a, C, A> { + CampaignListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _overridden_event_tag_id: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _excluded_ids: Default::default(), + _at_least_one_optimization_activity: Default::default(), + _archived: Default::default(), + _advertiser_ids: Default::default(), + _advertiser_group_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *eventTag* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.event_tags(); +/// # } +/// ``` +pub struct EventTagMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for EventTagMethods<'a, C, A> {} + +impl<'a, C, A> EventTagMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing event tag. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn delete(&self, profile_id: &str, id: &str) -> EventTagDeleteCall<'a, C, A> { + EventTagDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 event tags, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> EventTagListCall<'a, C, A> { + EventTagListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _ids: Default::default(), + _event_tag_types: Default::default(), + _enabled: Default::default(), + _definitions_only: Default::default(), + _campaign_id: Default::default(), + _advertiser_id: Default::default(), + _ad_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new event tag. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: EventTag, profile_id: &str) -> EventTagInsertCall<'a, C, A> { + EventTagInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 event tag. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn patch(&self, request: EventTag, profile_id: &str, id: &str) -> EventTagPatchCall<'a, C, A> { + EventTagPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: 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 event tag. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: EventTag, profile_id: &str) -> EventTagUpdateCall<'a, C, A> { + EventTagUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one event tag by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Event tag ID. + pub fn get(&self, profile_id: &str, id: &str) -> EventTagGetCall<'a, C, A> { + EventTagGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *remarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.remarketing_lists(); +/// # } +/// ``` +pub struct RemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for RemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> RemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> RemarketingListGetCall<'a, C, A> { + RemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: 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 remarketing list. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: RemarketingList, profile_id: &str) -> RemarketingListUpdateCall<'a, C, A> { + RemarketingListUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only remarketing lists owned by this advertiser. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> RemarketingListListCall<'a, C, A> { + RemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _floodlight_activity_id: Default::default(), + _active: 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 remarketing list. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn patch(&self, request: RemarketingList, profile_id: &str, id: &str) -> RemarketingListPatchCall<'a, C, A> { + RemarketingListPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new remarketing list. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: RemarketingList, profile_id: &str) -> RemarketingListInsertCall<'a, C, A> { + RemarketingListInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *city* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.cities(); +/// # } +/// ``` +pub struct CityMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CityMethods<'a, C, A> {} + +impl<'a, C, A> CityMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of cities, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CityListCall<'a, C, A> { + CityListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _region_dart_ids: Default::default(), + _name_prefix: Default::default(), + _dart_ids: Default::default(), + _country_dart_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placementStrategy* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.placement_strategies(); +/// # } +/// ``` +pub struct PlacementStrategyMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementStrategyMethods<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing placement strategy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + PlacementStrategyUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement strategy by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementStrategyGetCall<'a, C, A> { + PlacementStrategyGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 placement strategies, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementStrategyListCall<'a, C, A> { + PlacementStrategyListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing placement strategy. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn delete(&self, profile_id: &str, id: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + PlacementStrategyDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement strategy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyInsertCall<'a, C, A> { + PlacementStrategyInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 placement strategy. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement strategy ID. + pub fn patch(&self, request: PlacementStrategy, profile_id: &str, id: &str) -> PlacementStrategyPatchCall<'a, C, A> { + PlacementStrategyPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.projects(); +/// # } +/// ``` +pub struct ProjectMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +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: + /// + /// Retrieves a list of projects, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ProjectListCall<'a, C, A> { + ProjectListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one project by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Project ID. + pub fn get(&self, profile_id: &str, id: &str) -> ProjectGetCall<'a, C, A> { + ProjectGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *directorySite* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.directory_sites(); +/// # } +/// ``` +pub struct DirectorySiteMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DirectorySiteMethods<'a, C, A> {} + +impl<'a, C, A> DirectorySiteMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new directory site. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: DirectorySite, profile_id: &str) -> DirectorySiteInsertCall<'a, C, A> { + DirectorySiteInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 directory sites, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DirectorySiteListCall<'a, C, A> { + DirectorySiteListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _parent_id: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _dfp_network_code: Default::default(), + _country_id: Default::default(), + _active: Default::default(), + _accepts_publisher_paid_placements: Default::default(), + _accepts_interstitial_placements: Default::default(), + _accepts_in_stream_video_placements: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one directory site by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Directory site ID. + pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteGetCall<'a, C, A> { + DirectorySiteGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *dynamicTargetingKey* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.dynamic_targeting_keys(); +/// # } +/// ``` +pub struct DynamicTargetingKeyMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for DynamicTargetingKeyMethods<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing dynamic targeting key. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `objectId` - ID of the object of this dynamic targeting key. This is a required field. + /// * `name` - Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + /// * `objectType` - Type of the object of this dynamic targeting key. This is a required field. + pub fn delete(&self, profile_id: &str, object_id: &str, name: &str, object_type: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + DynamicTargetingKeyDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _object_id: object_id.to_string(), + _name: name.to_string(), + _object_type: object_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 dynamic targeting keys. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + DynamicTargetingKeyListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _object_type: Default::default(), + _object_id: Default::default(), + _names: Default::default(), + _advertiser_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: DynamicTargetingKey, profile_id: &str) -> DynamicTargetingKeyInsertCall<'a, C, A> { + DynamicTargetingKeyInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *size* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.sizes(); +/// # } +/// ``` +pub struct SizeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for SizeMethods<'a, C, A> {} + +impl<'a, C, A> SizeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new size. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Size, profile_id: &str) -> SizeInsertCall<'a, C, A> { + SizeInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 sizes, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> SizeListCall<'a, C, A> { + SizeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _width: Default::default(), + _ids: Default::default(), + _iab_standard: Default::default(), + _height: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one size by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Size ID. + pub fn get(&self, profile_id: &str, id: &str) -> SizeGetCall<'a, C, A> { + SizeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountActiveAdSummary* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.account_active_ad_summaries(); +/// # } +/// ``` +pub struct AccountActiveAdSummaryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountActiveAdSummaryMethods<'a, C, A> {} + +impl<'a, C, A> AccountActiveAdSummaryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets the account's active ad summary by account ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `summaryAccountId` - Account ID. + pub fn get(&self, profile_id: &str, summary_account_id: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + AccountActiveAdSummaryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _summary_account_id: summary_account_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *accountUserProfile* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.account_user_profiles(); +/// # } +/// ``` +pub struct AccountUserProfileMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountUserProfileMethods<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing account user profile. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileUpdateCall<'a, C, A> { + AccountUserProfileUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.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 account user profiles, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountUserProfileListCall<'a, C, A> { + AccountUserProfileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _user_role_id: Default::default(), + _subaccount_id: Default::default(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new account user profile. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileInsertCall<'a, C, A> { + AccountUserProfileInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 account user profile. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User profile ID. + pub fn patch(&self, request: AccountUserProfile, profile_id: &str, id: &str) -> AccountUserProfilePatchCall<'a, C, A> { + AccountUserProfilePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one account user profile by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - User profile ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountUserProfileGetCall<'a, C, A> { + AccountUserProfileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *country* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.countries(); +/// # } +/// ``` +pub struct CountryMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CountryMethods<'a, C, A> {} + +impl<'a, C, A> CountryMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of countries. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> CountryListCall<'a, C, A> { + CountryListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one country by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `dartId` - Country DART ID. + pub fn get(&self, profile_id: &str, dart_id: &str) -> CountryGetCall<'a, C, A> { + CountryGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _dart_id: dart_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *creativeFieldValue* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.creative_field_values(); +/// # } +/// ``` +pub struct CreativeFieldValueMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for CreativeFieldValueMethods<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field value. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn patch(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + CreativeFieldValuePatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative field value by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn get(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueGetCall<'a, C, A> { + CreativeFieldValueGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing creative field value. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn delete(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + CreativeFieldValueDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative field value. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn insert(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + CreativeFieldValueInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_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 creative field value. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn update(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + CreativeFieldValueUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.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 creative field values, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn list(&self, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueListCall<'a, C, A> { + CreativeFieldValueListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *postalCode* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::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.postal_codes(); +/// # } +/// ``` +pub struct PostalCodeMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PostalCodeMethods<'a, C, A> {} + +impl<'a, C, A> PostalCodeMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one postal code by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `code` - Postal code ID. + pub fn get(&self, profile_id: &str, code: &str) -> PostalCodeGetCall<'a, C, A> { + PostalCodeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _code: code.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 postal codes. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PostalCodeListCall<'a, C, A> { + PostalCodeListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *browser* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.browsers(); +/// # } +/// ``` +pub struct BrowserMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for BrowserMethods<'a, C, A> {} + +impl<'a, C, A> BrowserMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of browsers. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> BrowserListCall<'a, C, A> { + BrowserListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *account* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.accounts(); +/// # } +/// ``` +pub struct AccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} + +impl<'a, C, A> AccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one account by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountGetCall<'a, C, A> { + AccountGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.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 accounts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountListCall<'a, C, A> { + AccountListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _active: 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 account. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Account, profile_id: &str) -> AccountUpdateCall<'a, C, A> { + AccountUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 account. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account ID. + pub fn patch(&self, request: Account, profile_id: &str, id: &str) -> AccountPatchCall<'a, C, A> { + AccountPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *placement* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d6 as dfareporting2d6; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d6::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `generatetags(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.placements(); +/// # } +/// ``` +pub struct PlacementMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, +} + +impl<'a, C, A> MethodsBuilder for PlacementMethods<'a, C, A> {} + +impl<'a, C, A> PlacementMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing placement. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement ID. + pub fn patch(&self, request: Placement, profile_id: &str, id: &str) -> PlacementPatchCall<'a, C, A> { + PlacementPatchCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _id: id.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 placements, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementListCall<'a, C, A> { + PlacementListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _size_ids: Default::default(), + _site_ids: Default::default(), + _search_string: Default::default(), + _pricing_types: Default::default(), + _placement_strategy_ids: Default::default(), + _payment_source: Default::default(), + _page_token: Default::default(), + _min_start_date: Default::default(), + _min_end_date: Default::default(), + _max_start_date: Default::default(), + _max_results: Default::default(), + _max_end_date: Default::default(), + _ids: Default::default(), + _group_ids: Default::default(), + _directory_site_ids: Default::default(), + _content_category_ids: Default::default(), + _compatibilities: Default::default(), + _campaign_ids: Default::default(), + _archived: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementGetCall<'a, C, A> { + PlacementGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn insert(&self, request: Placement, profile_id: &str) -> PlacementInsertCall<'a, C, A> { + PlacementInsertCall { + hub: self.hub, + _request: request, + _profile_id: profile_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 placement. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - User profile ID associated with this request. + pub fn update(&self, request: Placement, profile_id: &str) -> PlacementUpdateCall<'a, C, A> { + PlacementUpdateCall { + hub: self.hub, + _request: request, + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Generates tags for a placement. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn generatetags(&self, profile_id: &str) -> PlacementGeneratetagCall<'a, C, A> { + PlacementGeneratetagCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _tag_formats: Default::default(), + _placement_ids: Default::default(), + _campaign_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + + + +// ################### +// CallBuilders ### +// ################# + +/// Inserts conversions. +/// +/// A builder for the *batchinsert* method supported by a *conversion* resource. +/// It is not used directly, but through a `ConversionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::ConversionsBatchInsertRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ConversionsBatchInsertRequest::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.conversions().batchinsert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ConversionBatchinsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ConversionsBatchInsertRequest, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConversionBatchinsertCall<'a, C, A> {} + +impl<'a, C, A> ConversionBatchinsertCall<'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, ConversionsBatchInsertResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.conversions.batchinsert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/conversions/batchinsert".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Ddmconversion.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ConversionsBatchInsertRequest) -> ConversionBatchinsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConversionBatchinsertCall<'a, C, A> { + self._profile_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) -> ConversionBatchinsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConversionBatchinsertCall<'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::Ddmconversion`. + /// + /// 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) -> ConversionBatchinsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role permission group by ID. +/// +/// A builder for the *get* method supported by a *userRolePermissionGroup* resource. +/// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permission_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGroupGetCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupGetCall<'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, UserRolePermissionGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissionGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRolePermissionGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role permission group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._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) -> UserRolePermissionGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of all supported user role permission groups. +/// +/// A builder for the *list* method supported by a *userRolePermissionGroup* resource. +/// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permission_groups().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGroupListCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGroupListCall<'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, UserRolePermissionGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissionGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRolePermissionGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGroupListCall<'a, C, A> { + self._profile_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) -> UserRolePermissionGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one platform type by ID. +/// +/// A builder for the *get* method supported by a *platformType* resource. +/// It is not used directly, but through a `PlatformTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.platform_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlatformTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlatformTypeGetCall<'a, C, A> {} + +impl<'a, C, A> PlatformTypeGetCall<'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, PlatformType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.platformTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/platformTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Platform type ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._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) -> PlatformTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlatformTypeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlatformTypeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of platform types. +/// +/// A builder for the *list* method supported by a *platformType* resource. +/// It is not used directly, but through a `PlatformTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.platform_types().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlatformTypeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlatformTypeListCall<'a, C, A> {} + +impl<'a, C, A> PlatformTypeListCall<'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, PlatformTypesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.platformTypes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/platformTypes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlatformTypeListCall<'a, C, A> { + self._profile_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) -> PlatformTypeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlatformTypeListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlatformTypeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one order document by ID. +/// +/// A builder for the *get* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.order_documents().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OrderDocumentGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderDocumentGetCall<'a, C, A> {} + +impl<'a, C, A> OrderDocumentGetCall<'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, OrderDocument)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/orderDocuments/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> OrderDocumentGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order document ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { + self._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) -> OrderDocumentGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderDocumentGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderDocumentGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of order documents, possibly filtered. +/// +/// A builder for the *list* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.order_documents().list("profileId", "projectId") +/// .sort_order("et") +/// .sort_field("diam") +/// .add_site_id("ipsum") +/// .search_string("Lorem") +/// .page_token("et") +/// .add_order_id("duo") +/// .max_results(-32) +/// .add_ids("sea") +/// .approved(false) +/// .doit(); +/// # } +/// ``` +pub struct OrderDocumentListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _search_string: Option, + _page_token: Option, + _order_id: Vec, + _max_results: Option, + _ids: Vec, + _approved: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderDocumentListCall<'a, C, A> {} + +impl<'a, C, A> OrderDocumentListCall<'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, OrderDocumentsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if self._order_id.len() > 0 { + for f in self._order_id.iter() { + params.push(("orderId", f.to_string())); + } + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "orderId", "maxResults", "ids", "approved"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/orderDocuments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> OrderDocumentListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only order documents that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for order documents by name or ID. Wildcards (*) are allowed. For example, "orderdocument*2015" will return order documents with names like "orderdocument June 2015", "orderdocument April 2015", or simply "orderdocument 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "orderdocument" will match order documents with name "my orderdocument", "orderdocument 2015", or simply "orderdocument". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only order documents for specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> OrderDocumentListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only order documents with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only order documents that have been approved by at least one user. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> OrderDocumentListCall<'a, C, A> { + self._approved = 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) -> OrderDocumentListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderDocumentListCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderDocumentListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field. +/// +/// A builder for the *update* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldUpdateCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldUpdateCall<'a, C, A> { + self._profile_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) -> CreativeFieldUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative fields, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().list("profileId") +/// .sort_order("sadipscing") +/// .sort_field("dolor") +/// .search_string("eirmod") +/// .page_token("elitr") +/// .max_results(-97) +/// .add_ids("no") +/// .add_advertiser_ids("labore") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldListCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldListCall<'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, CreativeFieldsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative fields by name or ID. Wildcards (*) are allowed. For example, "creativefield*2015" will return creative fields with names like "creativefield June 2015", "creativefield April 2015", or simply "creativefield 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativefield" will match creative fields with the name "my creativefield", "creativefield 2015", or simply "creativefield". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeFieldListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative fields with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creative fields that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, C, A> { + self._advertiser_ids.push(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) -> CreativeFieldListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing creative field. +/// +/// A builder for the *delete* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldDeleteCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldDeleteCall<'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: "dfareporting.creativeFields.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, C, A> { + self._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) -> CreativeFieldDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative field by ID. +/// +/// A builder for the *get* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_fields().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldGetCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, C, A> { + self._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) -> CreativeFieldGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative field. +/// +/// A builder for the *insert* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldInsertCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldInsertCall<'a, C, A> { + self._profile_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) -> CreativeFieldInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeField* resource. +/// It is not used directly, but through a `CreativeFieldMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeField; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeField::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.creative_fields().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeField, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldPatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldPatchCall<'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, CreativeField)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFields.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeField) -> CreativeFieldPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative Field ID + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, C, A> { + self._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) -> CreativeFieldPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new user role. +/// +/// A builder for the *insert* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleInsertCall<'a, C, A> {} + +impl<'a, C, A> UserRoleInsertCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRoleInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleInsertCall<'a, C, A> { + self._profile_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) -> UserRoleInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role by ID. +/// +/// A builder for the *get* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleGetCall<'a, C, A> {} + +impl<'a, C, A> UserRoleGetCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRoleGetCall<'a, C, A> { + self._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) -> UserRoleGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing user role. +/// +/// A builder for the *update* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleUpdateCall<'a, C, A> {} + +impl<'a, C, A> UserRoleUpdateCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRoleUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleUpdateCall<'a, C, A> { + self._profile_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) -> UserRoleUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing user role. +/// +/// A builder for the *delete* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRoleDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserRoleDeleteCall<'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: "dfareporting.userRoles.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, C, A> { + self._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) -> UserRoleDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing user role. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::UserRole; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = UserRole::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.user_roles().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: UserRole, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePatchCall<'a, C, A> {} + +impl<'a, C, A> UserRolePatchCall<'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, UserRole)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: UserRole) -> UserRolePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> UserRolePatchCall<'a, C, A> { + self._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) -> UserRolePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of user roles, possibly filtered. +/// +/// A builder for the *list* method supported by a *userRole* resource. +/// It is not used directly, but through a `UserRoleMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_roles().list("profileId") +/// .subaccount_id("ut") +/// .sort_order("ea") +/// .sort_field("sed") +/// .search_string("dolor") +/// .page_token("dolor") +/// .max_results(-48) +/// .add_ids("et") +/// .account_user_role_only(false) +/// .doit(); +/// # } +/// ``` +pub struct UserRoleListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _account_user_role_only: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRoleListCall<'a, C, A> {} + +impl<'a, C, A> UserRoleListCall<'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, UserRolesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRoles.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._account_user_role_only { + params.push(("accountUserRoleOnly", value.to_string())); + } + for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "accountUserRoleOnly"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRoles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user roles that belong to this subaccount. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "userrole*2015" will return objects with names like "userrole June 2015", "userrole April 2015", or simply "userrole 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "userrole" will match objects with name "my userrole", "userrole 2015", or simply "userrole". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> UserRoleListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only user roles with the specified IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> UserRoleListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only account level user roles not associated with any specific subaccount. + /// + /// Sets the *account user role only* query property to the given value. + pub fn account_user_role_only(mut self, new_value: bool) -> UserRoleListCall<'a, C, A> { + self._account_user_role_only = 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) -> UserRoleListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRoleListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRoleListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one operating system version by ID. +/// +/// A builder for the *get* method supported by a *operatingSystemVersion* resource. +/// It is not used directly, but through a `OperatingSystemVersionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_system_versions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemVersionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemVersionGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionGetCall<'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, OperatingSystemVersion)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystemVersions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/operatingSystemVersions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system version ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._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) -> OperatingSystemVersionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemVersionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemVersionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of operating system versions. +/// +/// A builder for the *list* method supported by a *operatingSystemVersion* resource. +/// It is not used directly, but through a `OperatingSystemVersionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_system_versions().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemVersionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemVersionListCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionListCall<'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, OperatingSystemVersionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystemVersions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/operatingSystemVersions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemVersionListCall<'a, C, A> { + self._profile_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) -> OperatingSystemVersionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemVersionListCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemVersionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one campaign landing page by ID. +/// +/// A builder for the *get* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().get("profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageGetCall<'a, C, A> {} + +impl<'a, C, A> LandingPageGetCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId"), ("{id}", "id")].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 ["id", "campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> LandingPageGetCall<'a, C, A> { + self._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) -> LandingPageGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageGetCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign landing page. +/// +/// A builder for the *update* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().update(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageUpdateCall<'a, C, A> {} + +impl<'a, C, A> LandingPageUpdateCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPageUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageUpdateCall<'a, C, A> { + self._campaign_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) -> LandingPageUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of landing pages for the specified campaign. +/// +/// A builder for the *list* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().list("profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageListCall<'a, C, A> {} + +impl<'a, C, A> LandingPageListCall<'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, LandingPagesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageListCall<'a, C, A> { + self._campaign_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) -> LandingPageListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageListCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new landing page for the specified campaign. +/// +/// A builder for the *insert* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().insert(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageInsertCall<'a, C, A> {} + +impl<'a, C, A> LandingPageInsertCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPageInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageInsertCall<'a, C, A> { + self._campaign_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) -> LandingPageInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign landing page. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::LandingPage; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = LandingPage::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.landing_pages().patch(req, "profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPagePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: LandingPage, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPagePatchCall<'a, C, A> {} + +impl<'a, C, A> LandingPagePatchCall<'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, LandingPage)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.landingPages.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: LandingPage) -> LandingPagePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> LandingPagePatchCall<'a, C, A> { + self._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) -> LandingPagePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPagePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPagePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing campaign landing page. +/// +/// A builder for the *delete* method supported by a *landingPage* resource. +/// It is not used directly, but through a `LandingPageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.landing_pages().delete("profileId", "campaignId", "id") +/// .doit(); +/// # } +/// ``` +pub struct LandingPageDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LandingPageDeleteCall<'a, C, A> {} + +impl<'a, C, A> LandingPageDeleteCall<'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: "dfareporting.landingPages.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "campaignId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId"), ("{id}", "id")].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 ["id", "campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Landing page campaign ID. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Landing page ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> LandingPageDeleteCall<'a, C, A> { + self._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) -> LandingPageDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LandingPageDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> LandingPageDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative asset. +/// +/// A builder for the *insert* method supported by a *creativeAsset* resource. +/// It is not used directly, but through a `CreativeAssetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeAssetMetadata; +/// use std::fs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeAssetMetadata::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `upload_resumable(...)`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.creative_assets().insert(req, "profileId", "advertiserId") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// # } +/// ``` +pub struct CreativeAssetInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeAssetMetadata, + _profile_id: String, + _advertiser_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeAssetInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeAssets.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + for &field in ["alt", "profileId", "advertiserId"].iter() { + if self._additional_params.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, upload_type) = + if protocol == "simple" { + ("https://www.googleapis.com/upload/dfareporting/v2.6/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "multipart") + } else if protocol == "resumable" { + ("https://www.googleapis.com/resumable/upload/dfareporting/v2.6/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string(), "resumable") + } else { + unreachable!() + }; + params.push(("uploadType", upload_type.to_string())); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{advertiserId}", "advertiserId")].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 ["advertiserId", "profileId"].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(); + + let mut should_ask_dlg_for_url = false; + let mut upload_url_from_server; + let mut upload_url: Option = None; + + 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 = { + if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { + should_ask_dlg_for_url = false; + upload_url_from_server = false; + let url = upload_url.as_ref().and_then(|s| Some(hyper::Url::parse(s).unwrap())).unwrap(); + hyper::client::Response::new(url, Box::new(cmn::DummyNetworkStream)).and_then(|mut res| { + res.status = hyper::status::StatusCode::Ok; + res.headers.set(Location(upload_url.as_ref().unwrap().clone())); + Ok(res) + }) + } else { + let mut mp_reader: MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + "simple" => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + let mime_type = mp_reader.mime_type(); + (&mut mp_reader as &mut io::Read, ContentType(mime_type)) + }, + _ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())), + }; + 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(content_type) + .body(&mut body_reader); + upload_url_from_server = true; + if protocol == "resumable" { + req = req.header(cmn::XUploadContentType(reader_mime_type.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)) + } + } + if protocol == "resumable" { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 1073741824 { + return Err(Error::UploadSizeLimitExceeded(size, 1073741824)) + } + let mut client = &mut *self.hub.client.borrow_mut(); + let upload_result = { + let url_str = &res.headers.get::().expect("Location header is part of protocol").0; + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + cmn::ResumableUploadHelper { + client: &mut client.borrow_mut(), + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &mut *self.hub.auth.borrow_mut(), + user_agent: &self.hub._user_agent, + auth_header: auth_header.clone(), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload() + }; + match upload_result { + None => { + dlg.finished(false); + return Err(Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Some(Ok(upload_result)) => { + res = upload_result; + if !res.status.is_success() { + dlg.store_upload_url(None); + dlg.finished(false); + return Err(Error::Failure(res)) + } + } + } + } + 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) + } + } + } + } + + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *max size*: 1024MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(stream, mime_type, "simple") + } + /// Upload media in a resumable fashion. + /// Even if the upload fails or is interrupted, it can be resumed for a + /// certain amount of time as the server maintains state temporarily. + /// + /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL + /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate + /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using + /// `cancel_chunk_upload(...)`. + /// + /// * *max size*: 1024MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(resumeable_stream, mime_type, "resumable") + } + + /// + /// 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: CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID of this creative. This is a required field. + /// + /// Sets the *advertiser 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 advertiser_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._advertiser_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) -> CreativeAssetInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeAssetInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeAssetInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already. +/// +/// A builder for the *insert* method supported by a *campaignCreativeAssociation* resource. +/// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CampaignCreativeAssociation; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CampaignCreativeAssociation::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.campaign_creative_associations().insert(req, "profileId", "campaignId") +/// .doit(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CampaignCreativeAssociation, + _profile_id: String, + _campaign_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignCreativeAssociationInsertCall<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationInsertCall<'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, CampaignCreativeAssociation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaignCreativeAssociations.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + for &field in ["alt", "profileId", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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: CampaignCreativeAssociation) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID in this association. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._campaign_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) -> CampaignCreativeAssociationInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignCreativeAssociationInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignCreativeAssociationInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of creative IDs associated with the specified campaign. +/// +/// A builder for the *list* method supported by a *campaignCreativeAssociation* resource. +/// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaign_creative_associations().list("profileId", "campaignId") +/// .sort_order("kasd") +/// .page_token("sanctus") +/// .max_results(-58) +/// .doit(); +/// # } +/// ``` +pub struct CampaignCreativeAssociationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _campaign_id: String, + _sort_order: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignCreativeAssociationListCall<'a, C, A> {} + +impl<'a, C, A> CampaignCreativeAssociationListCall<'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, CampaignCreativeAssociationsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaignCreativeAssociations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("campaignId", self._campaign_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.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())); + } + for &field in ["alt", "profileId", "campaignId", "sortOrder", "pageToken", "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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].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 ["campaignId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID in this association. + /// + /// Sets the *campaign 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 campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._campaign_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CampaignCreativeAssociationListCall<'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) -> CampaignCreativeAssociationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignCreativeAssociationListCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignCreativeAssociationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of change logs. +/// +/// A builder for the *list* method supported by a *changeLog* resource. +/// It is not used directly, but through a `ChangeLogMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.change_logs().list("profileId") +/// .add_user_profile_ids("labore") +/// .search_string("invidunt") +/// .page_token("ea") +/// .object_type("sadipscing") +/// .add_object_ids("rebum.") +/// .min_change_time("dolore") +/// .max_results(-41) +/// .max_change_time("sed") +/// .add_ids("aliquyam") +/// .action("sit") +/// .doit(); +/// # } +/// ``` +pub struct ChangeLogListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _user_profile_ids: Vec, + _search_string: Option, + _page_token: Option, + _object_type: Option, + _object_ids: Vec, + _min_change_time: Option, + _max_results: Option, + _max_change_time: Option, + _ids: Vec, + _action: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ChangeLogListCall<'a, C, A> {} + +impl<'a, C, A> ChangeLogListCall<'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, ChangeLogsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.changeLogs.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._user_profile_ids.len() > 0 { + for f in self._user_profile_ids.iter() { + params.push(("userProfileIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._object_type { + params.push(("objectType", value.to_string())); + } + if self._object_ids.len() > 0 { + for f in self._object_ids.iter() { + params.push(("objectIds", f.to_string())); + } + } + if let Some(value) = self._min_change_time { + params.push(("minChangeTime", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_change_time { + params.push(("maxChangeTime", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._action { + params.push(("action", value.to_string())); + } + for &field in ["alt", "profileId", "userProfileIds", "searchString", "pageToken", "objectType", "objectIds", "minChangeTime", "maxResults", "maxChangeTime", "ids", "action"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/changeLogs".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only change logs with these user profile IDs. + /// + /// Append the given value to the *user profile ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_user_profile_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._user_profile_ids.push(new_value.to_string()); + self + } + /// Select only change logs whose object ID, user name, old or new values match the search string. + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only change logs with the specified object type. + /// + /// Sets the *object type* query property to the given value. + pub fn object_type(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._object_type = Some(new_value.to_string()); + self + } + /// Select only change logs with these object IDs. + /// + /// Append the given value to the *object ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_object_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._object_ids.push(new_value.to_string()); + self + } + /// Select only change logs whose change time is before the specified minChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset. + /// + /// Sets the *min change time* query property to the given value. + pub fn min_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._min_change_time = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ChangeLogListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only change logs whose change time is before the specified maxChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset. + /// + /// Sets the *max change time* query property to the given value. + pub fn max_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._max_change_time = Some(new_value.to_string()); + self + } + /// Select only change logs with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only change logs with the specified action. + /// + /// Sets the *action* query property to the given value. + pub fn action(mut self, new_value: &str) -> ChangeLogListCall<'a, C, A> { + self._action = 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) -> ChangeLogListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ChangeLogListCall<'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::Dfatrafficking`. + /// + /// 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) -> ChangeLogListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one change log by ID. +/// +/// A builder for the *get* method supported by a *changeLog* resource. +/// It is not used directly, but through a `ChangeLogMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.change_logs().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ChangeLogGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ChangeLogGetCall<'a, C, A> {} + +impl<'a, C, A> ChangeLogGetCall<'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, ChangeLog)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.changeLogs.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/changeLogs/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ChangeLogGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Change log ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ChangeLogGetCall<'a, C, A> { + self._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) -> ChangeLogGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ChangeLogGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ChangeLogGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list share by remarketing list ID. +/// +/// A builder for the *get* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_list_shares().get("profileId", "remarketingListId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListShareGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _remarketing_list_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListShareGetCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareGetCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingListShares/{remarketingListId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{remarketingListId}", "remarketingListId")].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 ["remarketingListId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *remarketing list 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 remarketing_list_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { + self._remarketing_list_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) -> RemarketingListShareGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListShareGetCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListShareGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list share. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::RemarketingListShare; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingListShare::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.remarketing_list_shares().patch(req, "profileId", "remarketingListId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListSharePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingListShare, + _profile_id: String, + _remarketing_list_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListSharePatchCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListSharePatchCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingListShares".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingListShare) -> RemarketingListSharePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *remarketing list id* 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 remarketing_list_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { + self._remarketing_list_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) -> RemarketingListSharePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListSharePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListSharePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list share. +/// +/// A builder for the *update* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::RemarketingListShare; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingListShare::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.remarketing_list_shares().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListShareUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingListShare, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListShareUpdateCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListShareUpdateCall<'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, RemarketingListShare)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingListShares".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingListShare) -> RemarketingListShareUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + self._profile_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) -> RemarketingListShareUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListShareUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListShareUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Runs a report. +/// +/// A builder for the *run* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().run("profileId", "reportId") +/// .synchronous(false) +/// .doit(); +/// # } +/// ``` +pub struct ReportRunCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _synchronous: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportRunCall<'a, C, A> {} + +impl<'a, C, A> ReportRunCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.run", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._synchronous { + params.push(("synchronous", value.to_string())); + } + for &field in ["alt", "profileId", "reportId", "synchronous"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}/run".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// If set and true, tries to run the report synchronously. + /// + /// Sets the *synchronous* query property to the given value. + pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, C, A> { + self._synchronous = 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) -> ReportRunCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportRunCall<'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) -> ReportRunCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().patch(req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportPatchCall<'a, C, A> {} + +impl<'a, C, A> ReportPatchCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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: Report) -> ReportPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._report_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) -> ReportPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportPatchCall<'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) -> ReportPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists files for a report. +/// +/// A builder for the *files.list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().files_list("profileId", "reportId") +/// .sort_order("sit") +/// .sort_field("diam") +/// .page_token("ut") +/// .max_results(-70) +/// .doit(); +/// # } +/// ``` +pub struct ReportFileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportFileListCall<'a, C, A> {} + +impl<'a, C, A> ReportFileListCall<'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, FileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.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())); + } + for &field in ["alt", "profileId", "reportId", "sortOrder", "sortField", "pageToken", "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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}/files".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the parent report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'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) -> ReportFileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportFileListCall<'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) -> ReportFileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a report. +/// +/// A builder for the *insert* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportInsertCall<'a, C, A> {} + +impl<'a, C, A> ReportInsertCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Report) -> ReportInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportInsertCall<'a, C, A> { + self._profile_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) -> ReportInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportInsertCall<'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) -> ReportInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. +/// +/// A builder for the *update* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().update(req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportUpdateCall<'a, C, A> {} + +impl<'a, C, A> ReportUpdateCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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: Report) -> ReportUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._report_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) -> ReportUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportUpdateCall<'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) -> ReportUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. +/// +/// A builder for the *compatibleFields.query* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Report::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.reports().compatible_fields_query(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportCompatibleFieldQueryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportCompatibleFieldQueryCall<'a, C, A> {} + +impl<'a, C, A> ReportCompatibleFieldQueryCall<'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, CompatibleFields)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.compatibleFields.query", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/compatiblefields/query".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Report) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._profile_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) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportCompatibleFieldQueryCall<'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) -> ReportCompatibleFieldQueryCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report by its ID. +/// +/// A builder for the *get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().get("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportGetCall<'a, C, A> {} + +impl<'a, C, A> ReportGetCall<'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, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._report_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) -> ReportGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportGetCall<'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) -> ReportGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report 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 `File` structure that you would usually get. The latter will be a default value. +/// +/// A builder for the *files.get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().files_get("profileId", "reportId", "fileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportFileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _file_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportFileGetCall<'a, C, A> {} + +impl<'a, C, A> ReportFileGetCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + params.push(("fileId", self._file_id.to_string())); + for &field in ["profileId", "reportId", "fileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}/files/{fileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId"), ("{fileId}", "fileId")].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 ["fileId", "reportId", "profileId"].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 = 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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The ID of the report file. + /// + /// Sets the *file 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 file_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._file_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) -> ReportFileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportFileGetCall<'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) -> ReportFileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a report by its ID. +/// +/// A builder for the *delete* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().delete("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportDeleteCall<'a, C, A> {} + +impl<'a, C, A> ReportDeleteCall<'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: "dfareporting.reports.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["profileId", "reportId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].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 ["reportId", "profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._report_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) -> ReportDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportDeleteCall<'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) -> ReportDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of reports. +/// +/// A builder for the *list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.reports().list("profileId") +/// .sort_order("voluptua.") +/// .sort_field("duo") +/// .scope("sed") +/// .page_token("aliquyam") +/// .max_results(-67) +/// .doit(); +/// # } +/// ``` +pub struct ReportListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _scope: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ReportListCall<'a, C, A> {} + +impl<'a, C, A> ReportListCall<'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, ReportList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._scope { + params.push(("scope", value.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())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "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/dfareporting/v2.6/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The scope that defines which results are returned, default is 'MINE'. + /// + /// Sets the *scope* query property to the given value. + pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._scope = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportListCall<'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) -> ReportListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ReportListCall<'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) -> ReportListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new advertiser. +/// +/// A builder for the *insert* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserInsertCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserInsertCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserInsertCall<'a, C, A> { + self._profile_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) -> AdvertiserInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserPatchCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserPatchCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, C, A> { + self._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) -> AdvertiserPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of advertisers, possibly filtered. +/// +/// A builder for the *list* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertisers().list("profileId") +/// .subaccount_id("kasd") +/// .status("invidunt") +/// .sort_order("rebum.") +/// .sort_field("Lorem") +/// .search_string("clita") +/// .page_token("invidunt") +/// .only_parent(false) +/// .max_results(-77) +/// .include_advertisers_without_groups_only(false) +/// .add_ids("et") +/// .add_floodlight_configuration_ids("sed") +/// .add_advertiser_group_ids("sit") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _status: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _only_parent: Option, + _max_results: Option, + _include_advertisers_without_groups_only: Option, + _ids: Vec, + _floodlight_configuration_ids: Vec, + _advertiser_group_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserListCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserListCall<'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, AdvertisersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._status { + params.push(("status", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._only_parent { + params.push(("onlyParent", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._include_advertisers_without_groups_only { + params.push(("includeAdvertisersWithoutGroupsOnly", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._floodlight_configuration_ids.len() > 0 { + for f in self._floodlight_configuration_ids.iter() { + params.push(("floodlightConfigurationIds", f.to_string())); + } + } + if self._advertiser_group_ids.len() > 0 { + for f in self._advertiser_group_ids.iter() { + params.push(("advertiserGroupIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "subaccountId", "status", "sortOrder", "sortField", "searchString", "pageToken", "onlyParent", "maxResults", "includeAdvertisersWithoutGroupsOnly", "ids", "floodlightConfigurationIds", "advertiserGroupIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only advertisers with these subaccount IDs. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Select only advertisers with the specified status. + /// + /// Sets the *status* query property to the given value. + pub fn status(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._status = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser June 2015", "advertiser April 2015", or simply "advertiser 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertiser" will match objects with name "my advertiser", "advertiser 2015", or simply "advertiser". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only advertisers which use another advertiser's floodlight configuration. + /// + /// Sets the *only parent* query property to the given value. + pub fn only_parent(mut self, new_value: bool) -> AdvertiserListCall<'a, C, A> { + self._only_parent = Some(new_value); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdvertiserListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only advertisers which do not belong to any advertiser group. + /// + /// Sets the *include advertisers without groups only* query property to the given value. + pub fn include_advertisers_without_groups_only(mut self, new_value: bool) -> AdvertiserListCall<'a, C, A> { + self._include_advertisers_without_groups_only = Some(new_value); + self + } + /// Select only advertisers with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only advertisers with these floodlight configuration IDs. + /// + /// Append the given value to the *floodlight configuration ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_floodlight_configuration_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._floodlight_configuration_ids.push(new_value.to_string()); + self + } + /// Select only advertisers with these advertiser group IDs. + /// + /// Append the given value to the *advertiser group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_group_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, C, A> { + self._advertiser_group_ids.push(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) -> AdvertiserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser. +/// +/// A builder for the *update* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Advertiser; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Advertiser::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.advertisers().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Advertiser, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserUpdateCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertisers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Advertiser) -> AdvertiserUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserUpdateCall<'a, C, A> { + self._profile_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) -> AdvertiserUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one advertiser by ID. +/// +/// A builder for the *get* method supported by a *advertiser* resource. +/// It is not used directly, but through a `AdvertiserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertisers().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGetCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGetCall<'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, Advertiser)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertisers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertisers/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGetCall<'a, C, A> { + self._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) -> AdvertiserGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of report dimension values for a list of filters. +/// +/// A builder for the *query* method supported by a *dimensionValue* resource. +/// It is not used directly, but through a `DimensionValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::DimensionValueRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DimensionValueRequest::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.dimension_values().query(req, "profileId") +/// .page_token("Lorem") +/// .max_results(-50) +/// .doit(); +/// # } +/// ``` +pub struct DimensionValueQueryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DimensionValueRequest, + _profile_id: String, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DimensionValueQueryCall<'a, C, A> {} + +impl<'a, C, A> DimensionValueQueryCall<'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, DimensionValueList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dimensionValues.query", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.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())); + } + for &field in ["alt", "profileId", "pageToken", "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/dfareporting/v2.6/userprofiles/{profileId}/dimensionvalues/query".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DimensionValueRequest) -> DimensionValueQueryCall<'a, C, A> { + self._request = new_value; + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DimensionValueQueryCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DimensionValueQueryCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DimensionValueQueryCall<'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) -> DimensionValueQueryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DimensionValueQueryCall<'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) -> DimensionValueQueryCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight activity group by ID. +/// +/// A builder for the *get* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activity_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupGetCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity Group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._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) -> FloodlightActivityGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupPatchCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity Group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._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) -> FloodlightActivityGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight activity groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activity_groups().list("profileId") +/// .type_("ut") +/// .sort_order("dolor") +/// .sort_field("sea") +/// .search_string("ut") +/// .page_token("eirmod") +/// .max_results(-8) +/// .add_ids("voluptua.") +/// .floodlight_configuration_id("dolor") +/// .advertiser_id("et") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _type_: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _floodlight_configuration_id: Option, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupListCall<'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, FloodlightActivityGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._floodlight_configuration_id { + params.push(("floodlightConfigurationId", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "type", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only floodlight activity groups with the specified floodlight activity group type. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._type_ = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivitygroup*2015" will return objects with names like "floodlightactivitygroup June 2015", "floodlightactivitygroup April 2015", or simply "floodlightactivitygroup 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivitygroup" will match objects with name "my floodlightactivitygroup activity", "floodlightactivitygroup 2015", or simply "floodlightactivitygroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FloodlightActivityGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only floodlight activity groups with the specified IDs. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only floodlight activity groups with the specified floodlight configuration ID. Must specify either advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *floodlight configuration id* query property to the given value. + pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._floodlight_configuration_id = Some(new_value.to_string()); + self + } + /// Select only floodlight activity groups with the specified advertiser ID. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C, A> { + self._advertiser_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) -> FloodlightActivityGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new floodlight activity group. +/// +/// A builder for the *insert* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupInsertCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._profile_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) -> FloodlightActivityGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity group. +/// +/// A builder for the *update* method supported by a *floodlightActivityGroup* resource. +/// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivityGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivityGroup::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.floodlight_activity_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivityGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGroupUpdateCall<'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, FloodlightActivityGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivityGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivityGroup) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightActivityGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of metros. +/// +/// A builder for the *list* method supported by a *metro* resource. +/// It is not used directly, but through a `MetroMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.metros().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct MetroListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MetroListCall<'a, C, A> {} + +impl<'a, C, A> MetroListCall<'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, MetrosListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.metros.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/metros".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MetroListCall<'a, C, A> { + self._profile_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) -> MetroListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MetroListCall<'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::Dfatrafficking`. + /// + /// 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) -> MetroListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of orders, possibly filtered. +/// +/// A builder for the *list* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.orders().list("profileId", "projectId") +/// .sort_order("ipsum") +/// .sort_field("justo") +/// .add_site_id("dolore") +/// .search_string("vero") +/// .page_token("dolor") +/// .max_results(-58) +/// .add_ids("et") +/// .doit(); +/// # } +/// ``` +pub struct OrderListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderListCall<'a, C, A> {} + +impl<'a, C, A> OrderListCall<'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, OrdersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/orders".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// 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) -> OrderListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only orders that are associated with these site IDs. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for orders by name or ID. Wildcards (*) are allowed. For example, "order*2015" will return orders with names like "order June 2015", "order April 2015", or simply "order 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "order" will match orders with name "my order", "order 2015", or simply "order". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> OrderListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only orders with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._ids.push(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) -> OrderListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderListCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one order by ID. +/// +/// A builder for the *get* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.orders().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OrderGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OrderGetCall<'a, C, A> {} + +impl<'a, C, A> OrderGetCall<'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, Order)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/orders/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// 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) -> OrderGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._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) -> OrderGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OrderGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OrderGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of languages. +/// +/// A builder for the *list* method supported by a *language* resource. +/// It is not used directly, but through a `LanguageMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.languages().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct LanguageListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for LanguageListCall<'a, C, A> {} + +impl<'a, C, A> LanguageListCall<'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, LanguagesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.languages.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/languages".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> LanguageListCall<'a, C, A> { + self._profile_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) -> LanguageListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> LanguageListCall<'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::Dfatrafficking`. + /// + /// 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) -> LanguageListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one directory site contact by ID. +/// +/// A builder for the *get* method supported by a *directorySiteContact* resource. +/// It is not used directly, but through a `DirectorySiteContactMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_site_contacts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteContactGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteContactGetCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactGetCall<'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, DirectorySiteContact)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySiteContacts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/directorySiteContacts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Directory site contact ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, C, A> { + self._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) -> DirectorySiteContactGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteContactGetCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteContactGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of directory site contacts, possibly filtered. +/// +/// A builder for the *list* method supported by a *directorySiteContact* resource. +/// It is not used directly, but through a `DirectorySiteContactMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_site_contacts().list("profileId") +/// .sort_order("aliquyam") +/// .sort_field("elitr") +/// .search_string("consetetur") +/// .page_token("sea") +/// .max_results(-43) +/// .add_ids("At") +/// .add_directory_site_ids("sea") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteContactListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _directory_site_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteContactListCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteContactListCall<'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, DirectorySiteContactsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySiteContacts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/directorySiteContacts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "directory site contact*2015" will return objects with names like "directory site contact June 2015", "directory site contact April 2015", or simply "directory site contact 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site contact" will match objects with name "my directory site contact", "directory site contact 2015", or simply "directory site contact". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DirectorySiteContactListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only directory site contacts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only directory site contacts with these directory site IDs. This is a required field. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C, A> { + self._directory_site_ids.push(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) -> DirectorySiteContactListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteContactListCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteContactListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of user profiles for a user. +/// +/// A builder for the *list* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_profiles().list() +/// .doit(); +/// # } +/// ``` +pub struct UserProfileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserProfileListCall<'a, C, A> {} + +impl<'a, C, A> UserProfileListCall<'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, UserProfileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userProfiles.list", + 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/dfareporting/v2.6/userprofiles".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)); + } + + + + 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) -> UserProfileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileListCall<'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) -> UserProfileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user profile by ID. +/// +/// A builder for the *get* method supported by a *userProfile* resource. +/// It is not used directly, but through a `UserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_profiles().get("profileId") +/// .doit(); +/// # } +/// ``` +pub struct UserProfileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserProfileGetCall<'a, C, A> {} + +impl<'a, C, A> UserProfileGetCall<'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, UserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userProfiles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The user profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserProfileGetCall<'a, C, A> { + self._profile_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) -> UserProfileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserProfileGetCall<'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) -> UserProfileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing ad. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdPatchCall<'a, C, A> {} + +impl<'a, C, A> AdPatchCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Ad ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdPatchCall<'a, C, A> { + self._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) -> AdPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new ad. +/// +/// A builder for the *insert* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdInsertCall<'a, C, A> {} + +impl<'a, C, A> AdInsertCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdInsertCall<'a, C, A> { + self._profile_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) -> AdInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of ads, possibly filtered. +/// +/// A builder for the *list* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.ads().list("profileId") +/// .add_type("dolor") +/// .ssl_required(false) +/// .ssl_compliant(false) +/// .sort_order("ea") +/// .sort_field("et") +/// .add_size_ids("Stet") +/// .search_string("sed") +/// .add_remarketing_list_ids("dolor") +/// .add_placement_ids("sanctus") +/// .page_token("dolore") +/// .overridden_event_tag_id("Lorem") +/// .max_results(-96) +/// .add_landing_page_ids("consetetur") +/// .add_ids("eirmod") +/// .dynamic_click_tracker(true) +/// .creative_type("gubergren") +/// .add_creative_optimization_configuration_ids("et") +/// .add_creative_ids("sadipscing") +/// .compatibility("accusam") +/// .add_campaign_ids("magna") +/// .add_audience_segment_ids("Lorem") +/// .archived(true) +/// .advertiser_id("et") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct AdListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _type_: Vec, + _ssl_required: Option, + _ssl_compliant: Option, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _search_string: Option, + _remarketing_list_ids: Vec, + _placement_ids: Vec, + _page_token: Option, + _overridden_event_tag_id: Option, + _max_results: Option, + _landing_page_ids: Vec, + _ids: Vec, + _dynamic_click_tracker: Option, + _creative_type: Option, + _creative_optimization_configuration_ids: Vec, + _creative_ids: Vec, + _compatibility: Option, + _campaign_ids: Vec, + _audience_segment_ids: Vec, + _archived: Option, + _advertiser_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdListCall<'a, C, A> {} + +impl<'a, C, A> AdListCall<'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, AdsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((27 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._type_.len() > 0 { + for f in self._type_.iter() { + params.push(("type", f.to_string())); + } + } + if let Some(value) = self._ssl_required { + params.push(("sslRequired", value.to_string())); + } + if let Some(value) = self._ssl_compliant { + params.push(("sslCompliant", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._remarketing_list_ids.len() > 0 { + for f in self._remarketing_list_ids.iter() { + params.push(("remarketingListIds", f.to_string())); + } + } + if self._placement_ids.len() > 0 { + for f in self._placement_ids.iter() { + params.push(("placementIds", f.to_string())); + } + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._overridden_event_tag_id { + params.push(("overriddenEventTagId", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._landing_page_ids.len() > 0 { + for f in self._landing_page_ids.iter() { + params.push(("landingPageIds", f.to_string())); + } + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._dynamic_click_tracker { + params.push(("dynamicClickTracker", value.to_string())); + } + if let Some(value) = self._creative_type { + params.push(("creativeType", value.to_string())); + } + if self._creative_optimization_configuration_ids.len() > 0 { + for f in self._creative_optimization_configuration_ids.iter() { + params.push(("creativeOptimizationConfigurationIds", f.to_string())); + } + } + if self._creative_ids.len() > 0 { + for f in self._creative_ids.iter() { + params.push(("creativeIds", f.to_string())); + } + } + if let Some(value) = self._compatibility { + params.push(("compatibility", value.to_string())); + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if self._audience_segment_ids.len() > 0 { + for f in self._audience_segment_ids.iter() { + params.push(("audienceSegmentIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "type", "sslRequired", "sslCompliant", "sortOrder", "sortField", "sizeIds", "searchString", "remarketingListIds", "placementIds", "pageToken", "overriddenEventTagId", "maxResults", "landingPageIds", "ids", "dynamicClickTracker", "creativeType", "creativeOptimizationConfigurationIds", "creativeIds", "compatibility", "campaignIds", "audienceSegmentIds", "archived", "advertiserId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only ads with these types. + /// + /// 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) -> AdListCall<'a, C, A> { + self._type_.push(new_value.to_string()); + self + } + /// Select only ads that require SSL. + /// + /// Sets the *ssl required* query property to the given value. + pub fn ssl_required(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._ssl_required = Some(new_value); + self + } + /// Select only ads that are SSL-compliant. + /// + /// Sets the *ssl compliant* query property to the given value. + pub fn ssl_compliant(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._ssl_compliant = Some(new_value); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only ads with these size IDs. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "ad*2015" will return objects with names like "ad June 2015", "ad April 2015", or simply "ad 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "ad" will match objects with name "my ad", "ad 2015", or simply "ad". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only ads whose list targeting expression use these remarketing list IDs. + /// + /// Append the given value to the *remarketing list ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_remarketing_list_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._remarketing_list_ids.push(new_value.to_string()); + self + } + /// Select only ads with these placement IDs assigned. + /// + /// Append the given value to the *placement ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._placement_ids.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only ads with this event tag override ID. + /// + /// Sets the *overridden event tag id* query property to the given value. + pub fn overridden_event_tag_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._overridden_event_tag_id = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only ads with these landing page IDs. + /// + /// Append the given value to the *landing page ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_landing_page_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._landing_page_ids.push(new_value.to_string()); + self + } + /// Select only ads with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only dynamic click trackers. Applicable when type is AD_SERVING_CLICK_TRACKER. If true, select dynamic click trackers. If false, select static click trackers. Leave unset to select both. + /// + /// Sets the *dynamic click tracker* query property to the given value. + pub fn dynamic_click_tracker(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._dynamic_click_tracker = Some(new_value); + self + } + /// Select only ads with the specified creativeType. + /// + /// Sets the *creative type* query property to the given value. + pub fn creative_type(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_type = Some(new_value.to_string()); + self + } + /// Select only ads with these creative optimization configuration IDs. + /// + /// Append the given value to the *creative optimization configuration ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_optimization_configuration_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_optimization_configuration_ids.push(new_value.to_string()); + self + } + /// Select only ads with these creative IDs assigned. + /// + /// Append the given value to the *creative ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._creative_ids.push(new_value.to_string()); + self + } + /// Select default ads with the specified compatibility. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering an in-stream video ads developed with the VAST standard. + /// + /// Sets the *compatibility* query property to the given value. + pub fn compatibility(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._compatibility = Some(new_value.to_string()); + self + } + /// Select only ads with these campaign IDs. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only ads with these audience segment IDs. + /// + /// Append the given value to the *audience segment ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_audience_segment_ids(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._audience_segment_ids.push(new_value.to_string()); + self + } + /// Select only archived ads. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only ads with this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> AdListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only active ads. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AdListCall<'a, C, A> { + self._active = 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) -> AdListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one ad by ID. +/// +/// A builder for the *get* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.ads().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdGetCall<'a, C, A> {} + +impl<'a, C, A> AdGetCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/ads/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Ad ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdGetCall<'a, C, A> { + self._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) -> AdGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing ad. +/// +/// A builder for the *update* method supported by a *ad* resource. +/// It is not used directly, but through a `AdMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Ad; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Ad::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.ads().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Ad, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdUpdateCall<'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, Ad)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.ads.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/ads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Ad) -> AdUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdUpdateCall<'a, C, A> { + self._profile_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) -> AdUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account permission by ID. +/// +/// A builder for the *get* method supported by a *accountPermission* resource. +/// It is not used directly, but through a `AccountPermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permissions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGetCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGetCall<'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, AccountPermission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountPermissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account permission ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C, A> { + self._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) -> AccountPermissionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of account permissions. +/// +/// A builder for the *list* method supported by a *accountPermission* resource. +/// It is not used directly, but through a `AccountPermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permissions().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionListCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionListCall<'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, AccountPermissionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountPermissions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionListCall<'a, C, A> { + self._profile_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) -> AccountPermissionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of connection types. +/// +/// A builder for the *list* method supported by a *connectionType* resource. +/// It is not used directly, but through a `ConnectionTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.connection_types().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct ConnectionTypeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConnectionTypeListCall<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeListCall<'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, ConnectionTypesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.connectionTypes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/connectionTypes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConnectionTypeListCall<'a, C, A> { + self._profile_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) -> ConnectionTypeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConnectionTypeListCall<'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::Dfatrafficking`. + /// + /// 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) -> ConnectionTypeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one connection type by ID. +/// +/// A builder for the *get* method supported by a *connectionType* resource. +/// It is not used directly, but through a `ConnectionTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.connection_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ConnectionTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ConnectionTypeGetCall<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeGetCall<'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, ConnectionType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.connectionTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/connectionTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Connection type ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._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) -> ConnectionTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ConnectionTypeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ConnectionTypeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of targetable remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targetable_remarketing_lists().list("profileId", "advertiserId") +/// .sort_order("amet.") +/// .sort_field("dolore") +/// .page_token("magna") +/// .name("elitr") +/// .max_results(-82) +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _name: Option, + _max_results: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListListCall<'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, TargetableRemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetableRemarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only targetable remarketing lists targetable by these advertisers. + /// + /// Sets the *advertiser id* 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 advertiser_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> TargetableRemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only active or only inactive targetable remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> TargetableRemarketingListListCall<'a, C, A> { + self._active = 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) -> TargetableRemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetableRemarketingListListCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetableRemarketingListListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targetable_remarketing_lists().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListGetCall<'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, TargetableRemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetableRemarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._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) -> TargetableRemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetableRemarketingListGetCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetableRemarketingListGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one advertiser group by ID. +/// +/// A builder for the *get* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupGetCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupGetCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, C, A> { + self._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) -> AdvertiserGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of advertiser groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().list("profileId") +/// .sort_order("sed") +/// .sort_field("diam") +/// .search_string("magna") +/// .page_token("dolor") +/// .max_results(-5) +/// .add_ids("dolor") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupListCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupListCall<'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, AdvertiserGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser group June 2015", "advertiser group April 2015", or simply "advertiser group 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertisergroup" will match objects with name "my advertisergroup", "advertisergroup 2015", or simply "advertisergroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AdvertiserGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only advertiser groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C, A> { + self._ids.push(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) -> AdvertiserGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new advertiser group. +/// +/// A builder for the *insert* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupInsertCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupInsertCall<'a, C, A> { + self._profile_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) -> AdvertiserGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser group. +/// +/// A builder for the *update* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupUpdateCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._profile_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) -> AdvertiserGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing advertiser group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AdvertiserGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AdvertiserGroup::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.advertiser_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AdvertiserGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupPatchCall<'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, AdvertiserGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.advertiserGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, C, A> { + self._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) -> AdvertiserGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing advertiser group. +/// +/// A builder for the *delete* method supported by a *advertiserGroup* resource. +/// It is not used directly, but through a `AdvertiserGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.advertiser_groups().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AdvertiserGroupDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AdvertiserGroupDeleteCall<'a, C, A> {} + +impl<'a, C, A> AdvertiserGroupDeleteCall<'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: "dfareporting.advertiserGroups.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._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) -> AdvertiserGroupDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AdvertiserGroupDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> AdvertiserGroupDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new site. +/// +/// A builder for the *insert* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SiteInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteInsertCall<'a, C, A> {} + +impl<'a, C, A> SiteInsertCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SiteInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteInsertCall<'a, C, A> { + self._profile_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) -> SiteInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one site by ID. +/// +/// A builder for the *get* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sites().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SiteGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteGetCall<'a, C, A> {} + +impl<'a, C, A> SiteGetCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sites/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Site ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SiteGetCall<'a, C, A> { + self._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) -> SiteGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of sites, possibly filtered. +/// +/// A builder for the *list* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sites().list("profileId") +/// .unmapped_site(true) +/// .subaccount_id("et") +/// .sort_order("aliquyam") +/// .sort_field("nonumy") +/// .search_string("sit") +/// .page_token("aliquyam") +/// .max_results(-95) +/// .add_ids("magna") +/// .add_directory_site_ids("gubergren") +/// .add_campaign_ids("sit") +/// .approved(false) +/// .ad_words_site(true) +/// .accepts_publisher_paid_placements(false) +/// .accepts_interstitial_placements(true) +/// .accepts_in_stream_video_placements(false) +/// .doit(); +/// # } +/// ``` +pub struct SiteListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _unmapped_site: Option, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _directory_site_ids: Vec, + _campaign_ids: Vec, + _approved: Option, + _ad_words_site: Option, + _accepts_publisher_paid_placements: Option, + _accepts_interstitial_placements: Option, + _accepts_in_stream_video_placements: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteListCall<'a, C, A> {} + +impl<'a, C, A> SiteListCall<'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, SitesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((18 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._unmapped_site { + params.push(("unmappedSite", value.to_string())); + } + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + if let Some(value) = self._ad_words_site { + params.push(("adWordsSite", value.to_string())); + } + if let Some(value) = self._accepts_publisher_paid_placements { + params.push(("acceptsPublisherPaidPlacements", value.to_string())); + } + if let Some(value) = self._accepts_interstitial_placements { + params.push(("acceptsInterstitialPlacements", value.to_string())); + } + if let Some(value) = self._accepts_in_stream_video_placements { + params.push(("acceptsInStreamVideoPlacements", value.to_string())); + } + for &field in ["alt", "profileId", "unmappedSite", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds", "campaignIds", "approved", "adWordsSite", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only sites that have not been mapped to a directory site. + /// + /// Sets the *unmapped site* query property to the given value. + pub fn unmapped_site(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._unmapped_site = Some(new_value); + self + } + /// Select only sites with this subaccount ID. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or keyName. Wildcards (*) are allowed. For example, "site*2015" will return objects with names like "site June 2015", "site April 2015", or simply "site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "site" will match objects with name "my site", "site 2015", or simply "site". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> SiteListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only sites with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only sites with these directory site IDs. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only sites with these campaign IDs. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> SiteListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only approved sites. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._approved = Some(new_value); + self + } + /// Select only AdWords sites. + /// + /// Sets the *ad words site* query property to the given value. + pub fn ad_words_site(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._ad_words_site = Some(new_value); + self + } + /// Select only sites that accept publisher paid placements. + /// + /// Sets the *accepts publisher paid placements* query property to the given value. + pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_publisher_paid_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts interstitial placements* query property to the given value. + pub fn accepts_interstitial_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_interstitial_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts in stream video placements* query property to the given value. + pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> SiteListCall<'a, C, A> { + self._accepts_in_stream_video_placements = 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) -> SiteListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteListCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing site. +/// +/// A builder for the *update* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SiteUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SiteUpdateCall<'a, C, A> {} + +impl<'a, C, A> SiteUpdateCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SiteUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SiteUpdateCall<'a, C, A> { + self._profile_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) -> SiteUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SiteUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> SiteUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing site. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *site* resource. +/// It is not used directly, but through a `SiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Site; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Site::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.sites().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SitePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Site, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SitePatchCall<'a, C, A> {} + +impl<'a, C, A> SitePatchCall<'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, Site)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sites.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Site) -> SitePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SitePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Site ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> SitePatchCall<'a, C, A> { + self._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) -> SitePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SitePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> SitePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight activity by ID. +/// +/// A builder for the *get* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGetCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, C, A> { + self._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) -> FloodlightActivityGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight activities, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().list("profileId") +/// .tag_string("sed") +/// .sort_order("sit") +/// .sort_field("dolore") +/// .search_string("et") +/// .page_token("At") +/// .max_results(-98) +/// .add_ids("ut") +/// .floodlight_configuration_id("diam") +/// .floodlight_activity_group_type("tempor") +/// .floodlight_activity_group_tag_string("et") +/// .floodlight_activity_group_name("erat") +/// .add_floodlight_activity_group_ids("dolores") +/// .advertiser_id("kasd") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _tag_string: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _floodlight_configuration_id: Option, + _floodlight_activity_group_type: Option, + _floodlight_activity_group_tag_string: Option, + _floodlight_activity_group_name: Option, + _floodlight_activity_group_ids: Vec, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityListCall<'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, FloodlightActivitiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._tag_string { + params.push(("tagString", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._floodlight_configuration_id { + params.push(("floodlightConfigurationId", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_type { + params.push(("floodlightActivityGroupType", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_tag_string { + params.push(("floodlightActivityGroupTagString", value.to_string())); + } + if let Some(value) = self._floodlight_activity_group_name { + params.push(("floodlightActivityGroupName", value.to_string())); + } + if self._floodlight_activity_group_ids.len() > 0 { + for f in self._floodlight_activity_group_ids.iter() { + params.push(("floodlightActivityGroupIds", f.to_string())); + } + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "tagString", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "floodlightActivityGroupType", "floodlightActivityGroupTagString", "floodlightActivityGroupName", "floodlightActivityGroupIds", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only floodlight activities with the specified tag string. + /// + /// Sets the *tag string* query property to the given value. + pub fn tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._tag_string = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivity*2015" will return objects with names like "floodlightactivity June 2015", "floodlightactivity April 2015", or simply "floodlightactivity 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivity" will match objects with name "my floodlightactivity activity", "floodlightactivity 2015", or simply "floodlightactivity". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FloodlightActivityListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only floodlight activities with the specified IDs. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only floodlight activities for the specified floodlight configuration ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *floodlight configuration id* query property to the given value. + pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_configuration_id = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group type. + /// + /// Sets the *floodlight activity group type* query property to the given value. + pub fn floodlight_activity_group_type(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_type = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group tag string. + /// + /// Sets the *floodlight activity group tag string* query property to the given value. + pub fn floodlight_activity_group_tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_tag_string = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group name. + /// + /// Sets the *floodlight activity group name* query property to the given value. + pub fn floodlight_activity_group_name(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_name = Some(new_value.to_string()); + self + } + /// Select only floodlight activities with the specified floodlight activity group IDs. + /// + /// Append the given value to the *floodlight activity group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_floodlight_activity_group_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._floodlight_activity_group_ids.push(new_value.to_string()); + self + } + /// Select only floodlight activities for the specified advertiser ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C, A> { + self._advertiser_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) -> FloodlightActivityListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new floodlight activity. +/// +/// A builder for the *insert* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityInsertCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityInsertCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityInsertCall<'a, C, A> { + self._profile_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) -> FloodlightActivityInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing floodlight activity. +/// +/// A builder for the *delete* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityDeleteCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityDeleteCall<'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: "dfareporting.floodlightActivities.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, C, A> { + self._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) -> FloodlightActivityDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityPatchCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, C, A> { + self._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) -> FloodlightActivityPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates a tag for a floodlight activity. +/// +/// A builder for the *generatetag* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_activities().generatetag("profileId") +/// .floodlight_activity_id("amet") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityGeneratetagCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _floodlight_activity_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityGeneratetagCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityGeneratetagCall<'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, FloodlightActivitiesGenerateTagResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.generatetag", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._floodlight_activity_id { + params.push(("floodlightActivityId", value.to_string())); + } + for &field in ["alt", "profileId", "floodlightActivityId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities/generatetag".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight activity ID for which we want to generate a tag. + /// + /// Sets the *floodlight activity id* query property to the given value. + pub fn floodlight_activity_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._floodlight_activity_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) -> FloodlightActivityGeneratetagCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityGeneratetagCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityGeneratetagCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight activity. +/// +/// A builder for the *update* method supported by a *floodlightActivity* resource. +/// It is not used directly, but through a `FloodlightActivityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightActivity; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightActivity::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.floodlight_activities().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightActivityUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightActivity, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightActivityUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightActivityUpdateCall<'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, FloodlightActivity)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightActivities.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightActivities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightActivity) -> FloodlightActivityUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightActivityUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightActivityUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightActivityUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightActivityUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of regions. +/// +/// 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_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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("profileId") +/// .doit(); +/// # } +/// ``` +pub struct RegionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _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, RegionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.regions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/regions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RegionListCall<'a, C, A> { + self._profile_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) -> 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::Dfatrafficking`. + /// + /// 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 + } +} + + +/// Inserts a new creative group. +/// +/// A builder for the *insert* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupInsertCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupInsertCall<'a, C, A> { + self._profile_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) -> CreativeGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative group by ID. +/// +/// A builder for the *get* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupGetCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, C, A> { + self._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) -> CreativeGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative group. +/// +/// A builder for the *update* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupUpdateCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupUpdateCall<'a, C, A> { + self._profile_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) -> CreativeGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_groups().list("profileId") +/// .sort_order("erat") +/// .sort_field("et") +/// .search_string("amet") +/// .page_token("Lorem") +/// .max_results(-78) +/// .add_ids("rebum.") +/// .group_number(-70) +/// .add_advertiser_ids("labore") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _group_number: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupListCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupListCall<'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, CreativeGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._group_number { + params.push(("groupNumber", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "groupNumber", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative groups by name or ID. Wildcards (*) are allowed. For example, "creativegroup*2015" will return creative groups with names like "creativegroup June 2015", "creativegroup April 2015", or simply "creativegroup 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativegroup" will match creative groups with the name "my creativegroup", "creativegroup 2015", or simply "creativegroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creative groups that belong to this subgroup. + /// + /// Sets the *group number* query property to the given value. + pub fn group_number(mut self, new_value: i32) -> CreativeGroupListCall<'a, C, A> { + self._group_number = Some(new_value); + self + } + /// Select only creative groups that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, C, A> { + self._advertiser_ids.push(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) -> CreativeGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeGroup* resource. +/// It is not used directly, but through a `CreativeGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeGroup::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.creative_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeGroupPatchCall<'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, CreativeGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: CreativeGroup) -> CreativeGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, C, A> { + self._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) -> CreativeGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing targeting template. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *targetingTemplate* resource. +/// It is not used directly, but through a `TargetingTemplateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::TargetingTemplate; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = TargetingTemplate::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.targeting_templates().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct TargetingTemplatePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: TargetingTemplate, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetingTemplatePatchCall<'a, C, A> {} + +impl<'a, C, A> TargetingTemplatePatchCall<'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, TargetingTemplate)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetingTemplates.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetingTemplates".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: TargetingTemplate) -> TargetingTemplatePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetingTemplatePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Targeting template ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> TargetingTemplatePatchCall<'a, C, A> { + self._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) -> TargetingTemplatePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetingTemplatePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetingTemplatePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of targeting templates, optionally filtered. +/// +/// A builder for the *list* method supported by a *targetingTemplate* resource. +/// It is not used directly, but through a `TargetingTemplateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targeting_templates().list("profileId") +/// .sort_order("no") +/// .sort_field("aliquyam") +/// .search_string("magna") +/// .page_token("et") +/// .max_results(-29) +/// .add_ids("est") +/// .advertiser_id("sit") +/// .doit(); +/// # } +/// ``` +pub struct TargetingTemplateListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetingTemplateListCall<'a, C, A> {} + +impl<'a, C, A> TargetingTemplateListCall<'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, TargetingTemplatesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetingTemplates.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetingTemplates".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "template*2015" will return objects with names like "template June 2015", "template April 2015", or simply "template 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "template" will match objects with name "my template", "template 2015", or simply "template". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> TargetingTemplateListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only targeting templates with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only targeting templates with this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C, A> { + self._advertiser_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) -> TargetingTemplateListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetingTemplateListCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetingTemplateListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one targeting template by ID. +/// +/// A builder for the *get* method supported by a *targetingTemplate* resource. +/// It is not used directly, but through a `TargetingTemplateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.targeting_templates().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct TargetingTemplateGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetingTemplateGetCall<'a, C, A> {} + +impl<'a, C, A> TargetingTemplateGetCall<'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, TargetingTemplate)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetingTemplates.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetingTemplates/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetingTemplateGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Targeting template ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> TargetingTemplateGetCall<'a, C, A> { + self._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) -> TargetingTemplateGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetingTemplateGetCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetingTemplateGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new targeting template. +/// +/// A builder for the *insert* method supported by a *targetingTemplate* resource. +/// It is not used directly, but through a `TargetingTemplateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::TargetingTemplate; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = TargetingTemplate::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.targeting_templates().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct TargetingTemplateInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: TargetingTemplate, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetingTemplateInsertCall<'a, C, A> {} + +impl<'a, C, A> TargetingTemplateInsertCall<'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, TargetingTemplate)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetingTemplates.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetingTemplates".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: TargetingTemplate) -> TargetingTemplateInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetingTemplateInsertCall<'a, C, A> { + self._profile_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) -> TargetingTemplateInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetingTemplateInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetingTemplateInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing targeting template. +/// +/// A builder for the *update* method supported by a *targetingTemplate* resource. +/// It is not used directly, but through a `TargetingTemplateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::TargetingTemplate; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = TargetingTemplate::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.targeting_templates().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct TargetingTemplateUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: TargetingTemplate, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for TargetingTemplateUpdateCall<'a, C, A> {} + +impl<'a, C, A> TargetingTemplateUpdateCall<'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, TargetingTemplate)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetingTemplates.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/targetingTemplates".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: TargetingTemplate) -> TargetingTemplateUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> TargetingTemplateUpdateCall<'a, C, A> { + self._profile_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) -> TargetingTemplateUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> TargetingTemplateUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> TargetingTemplateUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing subaccount. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountPatchCall<'a, C, A> {} + +impl<'a, C, A> SubaccountPatchCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Subaccount ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> SubaccountPatchCall<'a, C, A> { + self._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) -> SubaccountPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new subaccount. +/// +/// A builder for the *insert* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountInsertCall<'a, C, A> {} + +impl<'a, C, A> SubaccountInsertCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountInsertCall<'a, C, A> { + self._profile_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) -> SubaccountInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing subaccount. +/// +/// A builder for the *update* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Subaccount; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Subaccount::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.subaccounts().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Subaccount, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountUpdateCall<'a, C, A> {} + +impl<'a, C, A> SubaccountUpdateCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Subaccount) -> SubaccountUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountUpdateCall<'a, C, A> { + self._profile_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) -> SubaccountUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of subaccounts, possibly filtered. +/// +/// A builder for the *list* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.subaccounts().list("profileId") +/// .sort_order("dolores") +/// .sort_field("magna") +/// .search_string("ut") +/// .page_token("amet") +/// .max_results(-42) +/// .add_ids("sit") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountListCall<'a, C, A> {} + +impl<'a, C, A> SubaccountListCall<'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, SubaccountsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/subaccounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "subaccount*2015" will return objects with names like "subaccount June 2015", "subaccount April 2015", or simply "subaccount 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "subaccount" will match objects with name "my subaccount", "subaccount 2015", or simply "subaccount". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> SubaccountListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only subaccounts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SubaccountListCall<'a, C, A> { + self._ids.push(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) -> SubaccountListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountListCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one subaccount by ID. +/// +/// A builder for the *get* method supported by a *subaccount* resource. +/// It is not used directly, but through a `SubaccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.subaccounts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SubaccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SubaccountGetCall<'a, C, A> {} + +impl<'a, C, A> SubaccountGetCall<'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, Subaccount)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.subaccounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/subaccounts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SubaccountGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Subaccount ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SubaccountGetCall<'a, C, A> { + self._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) -> SubaccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SubaccountGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SubaccountGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one mobile carrier by ID. +/// +/// A builder for the *get* method supported by a *mobileCarrier* resource. +/// It is not used directly, but through a `MobileCarrierMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.mobile_carriers().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct MobileCarrierGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MobileCarrierGetCall<'a, C, A> {} + +impl<'a, C, A> MobileCarrierGetCall<'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, MobileCarrier)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.mobileCarriers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/mobileCarriers/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Mobile carrier ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._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) -> MobileCarrierGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MobileCarrierGetCall<'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::Dfatrafficking`. + /// + /// 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) -> MobileCarrierGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of mobile carriers. +/// +/// A builder for the *list* method supported by a *mobileCarrier* resource. +/// It is not used directly, but through a `MobileCarrierMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.mobile_carriers().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct MobileCarrierListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for MobileCarrierListCall<'a, C, A> {} + +impl<'a, C, A> MobileCarrierListCall<'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, MobileCarriersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.mobileCarriers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/mobileCarriers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> MobileCarrierListCall<'a, C, A> { + self._profile_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) -> MobileCarrierListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MobileCarrierListCall<'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::Dfatrafficking`. + /// + /// 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) -> MobileCarrierListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one floodlight configuration by ID. +/// +/// A builder for the *get* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_configurations().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationGetCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightConfigurations/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight configuration ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._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) -> FloodlightConfigurationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationGetCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight configuration. +/// +/// A builder for the *update* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightConfiguration::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.floodlight_configurations().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightConfiguration, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationUpdateCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationUpdateCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightConfiguration) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._profile_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) -> FloodlightConfigurationUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing floodlight configuration. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::FloodlightConfiguration; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = FloodlightConfiguration::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.floodlight_configurations().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: FloodlightConfiguration, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationPatchCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationPatchCall<'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, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: FloodlightConfiguration) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight configuration ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._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) -> FloodlightConfigurationPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of floodlight configurations, possibly filtered. +/// +/// A builder for the *list* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.floodlight_configurations().list("profileId") +/// .add_ids("dolor") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationListCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationListCall<'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, FloodlightConfigurationsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/floodlightConfigurations".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Set of IDs of floodlight configurations to retrieve. Required field; otherwise an empty list will be returned. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, C, A> { + self._ids.push(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) -> FloodlightConfigurationListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FloodlightConfigurationListCall<'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::Dfatrafficking`. + /// + /// 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) -> FloodlightConfigurationListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of operating systems. +/// +/// A builder for the *list* method supported by a *operatingSystem* resource. +/// It is not used directly, but through a `OperatingSystemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_systems().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemListCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemListCall<'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, OperatingSystemsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystems.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/operatingSystems".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemListCall<'a, C, A> { + self._profile_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) -> OperatingSystemListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemListCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one operating system by DART ID. +/// +/// A builder for the *get* method supported by a *operatingSystem* resource. +/// It is not used directly, but through a `OperatingSystemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.operating_systems().get("profileId", "dartId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _dart_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for OperatingSystemGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemGetCall<'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, OperatingSystem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("dartId", self._dart_id.to_string())); + for &field in ["alt", "profileId", "dartId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/operatingSystems/{dartId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].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 ["dartId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system DART ID. + /// + /// Sets the *dart 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 dart_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._dart_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) -> OperatingSystemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> OperatingSystemGetCall<'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::Dfatrafficking`. + /// + /// 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) -> OperatingSystemGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists files for a user profile. +/// +/// A builder for the *list* method supported by a *file* resource. +/// It is not used directly, but through a `FileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.files().list("profileId") +/// .sort_order("duo") +/// .sort_field("et") +/// .scope("sit") +/// .page_token("eirmod") +/// .max_results(-60) +/// .doit(); +/// # } +/// ``` +pub struct FileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _scope: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FileListCall<'a, C, A> {} + +impl<'a, C, A> FileListCall<'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, FileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.files.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._scope { + params.push(("scope", value.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())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "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/dfareporting/v2.6/userprofiles/{profileId}/files".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The scope that defines which results are returned, default is 'MINE'. + /// + /// Sets the *scope* query property to the given value. + pub fn scope(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._scope = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> FileListCall<'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) -> FileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FileListCall<'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) -> FileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report file by its report ID and file ID. +/// +/// 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 `File` structure that you would usually get. The latter will be a default value. +/// +/// A builder for the *get* method supported by a *file* resource. +/// It is not used directly, but through a `FileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.files().get("reportId", "fileId") +/// .doit(); +/// # } +/// ``` +pub struct FileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _report_id: String, + _file_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for FileGetCall<'a, C, A> {} + +impl<'a, C, A> FileGetCall<'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, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.files.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("reportId", self._report_id.to_string())); + params.push(("fileId", self._file_id.to_string())); + for &field in ["reportId", "fileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/reports/{reportId}/files/{fileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{reportId}", "reportId"), ("{fileId}", "fileId")].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 ["fileId", "reportId"].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 = 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) + } + } + } + } + + + /// The ID of the report. + /// + /// Sets the *report 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 report_id(mut self, new_value: &str) -> FileGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The ID of the report file. + /// + /// Sets the *file 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 file_id(mut self, new_value: &str) -> FileGetCall<'a, C, A> { + self._file_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) -> FileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FileGetCall<'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) -> FileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placement groups, possibly filtered. +/// +/// A builder for the *list* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_groups().list("profileId") +/// .sort_order("clita") +/// .sort_field("kasd") +/// .add_site_ids("elitr") +/// .search_string("et") +/// .add_pricing_types("vero") +/// .add_placement_strategy_ids("sadipscing") +/// .placement_group_type("sed") +/// .page_token("vero") +/// .min_start_date("nonumy") +/// .min_end_date("magna") +/// .max_start_date("ea") +/// .max_results(-60) +/// .max_end_date("ipsum") +/// .add_ids("labore") +/// .add_directory_site_ids("Lorem") +/// .add_content_category_ids("aliquyam") +/// .add_campaign_ids("sanctus") +/// .archived(true) +/// .add_advertiser_ids("consetetur") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _site_ids: Vec, + _search_string: Option, + _pricing_types: Vec, + _placement_strategy_ids: Vec, + _placement_group_type: Option, + _page_token: Option, + _min_start_date: Option, + _min_end_date: Option, + _max_start_date: Option, + _max_results: Option, + _max_end_date: Option, + _ids: Vec, + _directory_site_ids: Vec, + _content_category_ids: Vec, + _campaign_ids: Vec, + _archived: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupListCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupListCall<'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, PlacementGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((22 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_ids.len() > 0 { + for f in self._site_ids.iter() { + params.push(("siteIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._pricing_types.len() > 0 { + for f in self._pricing_types.iter() { + params.push(("pricingTypes", f.to_string())); + } + } + if self._placement_strategy_ids.len() > 0 { + for f in self._placement_strategy_ids.iter() { + params.push(("placementStrategyIds", f.to_string())); + } + } + if let Some(value) = self._placement_group_type { + params.push(("placementGroupType", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._min_start_date { + params.push(("minStartDate", value.to_string())); + } + if let Some(value) = self._min_end_date { + params.push(("minEndDate", value.to_string())); + } + if let Some(value) = self._max_start_date { + params.push(("maxStartDate", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_end_date { + params.push(("maxEndDate", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._content_category_ids.len() > 0 { + for f in self._content_category_ids.iter() { + params.push(("contentCategoryIds", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "placementGroupType", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "directorySiteIds", "contentCategoryIds", "campaignIds", "archived", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these sites. + /// + /// Append the given value to the *site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._site_ids.push(new_value.to_string()); + self + } + /// Allows searching for placement groups by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placement groups with names like "placement group June 2015", "placement group May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementgroup" will match placement groups with name "my placementgroup", "placementgroup 2015", or simply "placementgroup". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only placement groups with these pricing types. + /// + /// Append the given value to the *pricing types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_pricing_types(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._pricing_types.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these placement strategies. + /// + /// Append the given value to the *placement strategy ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._placement_strategy_ids.push(new_value.to_string()); + self + } + /// Select only placement groups belonging with this group type. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting. + /// + /// Sets the *placement group type* query property to the given value. + pub fn placement_group_type(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._placement_group_type = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min start date* query property to the given value. + pub fn min_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._min_start_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min end date* query property to the given value. + pub fn min_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._min_end_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max start date* query property to the given value. + pub fn max_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._max_start_date = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementGroupListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max end date* query property to the given value. + pub fn max_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._max_end_date = Some(new_value.to_string()); + self + } + /// Select only placement groups with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these directory sites. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only placement groups that are associated with these content categories. + /// + /// Append the given value to the *content category ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._content_category_ids.push(new_value.to_string()); + self + } + /// Select only placement groups that belong to these campaigns. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only archived placements. Don't set this field to select both archived and non-archived placements. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> PlacementGroupListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only placement groups that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, C, A> { + self._advertiser_ids.push(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) -> PlacementGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement group. +/// +/// A builder for the *update* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupUpdateCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupUpdateCall<'a, C, A> { + self._profile_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) -> PlacementGroupUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement group. +/// +/// A builder for the *insert* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupInsertCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupInsertCall<'a, C, A> { + self._profile_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) -> PlacementGroupInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement group by ID. +/// +/// A builder for the *get* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupGetCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, C, A> { + self._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) -> PlacementGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement group. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placementGroup* resource. +/// It is not used directly, but through a `PlacementGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementGroup; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementGroup::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.placement_groups().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGroupPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementGroup, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGroupPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementGroupPatchCall<'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, PlacementGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementGroups.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementGroup) -> PlacementGroupPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement group ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, C, A> { + self._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) -> PlacementGroupPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGroupPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGroupPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of inventory items, possibly filtered. +/// +/// A builder for the *list* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.inventory_items().list("profileId", "projectId") +/// .type_("voluptua.") +/// .sort_order("labore") +/// .sort_field("erat") +/// .add_site_id("erat") +/// .page_token("voluptua.") +/// .add_order_id("est") +/// .max_results(-96) +/// .in_plan(true) +/// .add_ids("amet") +/// .doit(); +/// # } +/// ``` +pub struct InventoryItemListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _type_: Option, + _sort_order: Option, + _sort_field: Option, + _site_id: Vec, + _page_token: Option, + _order_id: Vec, + _max_results: Option, + _in_plan: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InventoryItemListCall<'a, C, A> {} + +impl<'a, C, A> InventoryItemListCall<'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, InventoryItemsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + for f in self._site_id.iter() { + params.push(("siteId", f.to_string())); + } + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if self._order_id.len() > 0 { + for f in self._order_id.iter() { + params.push(("orderId", f.to_string())); + } + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._in_plan { + params.push(("inPlan", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "projectId", "type", "sortOrder", "sortField", "siteId", "pageToken", "orderId", "maxResults", "inPlan", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/inventoryItems".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{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(2); + for param_name in ["projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> InventoryItemListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Select only inventory items with this type. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._type_ = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only inventory items that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only inventory items that belong to specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> InventoryItemListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only inventory items that are in plan. + /// + /// Sets the *in plan* query property to the given value. + pub fn in_plan(mut self, new_value: bool) -> InventoryItemListCall<'a, C, A> { + self._in_plan = Some(new_value); + self + } + /// Select only inventory items with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._ids.push(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) -> InventoryItemListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InventoryItemListCall<'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::Dfatrafficking`. + /// + /// 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) -> InventoryItemListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one inventory item by ID. +/// +/// A builder for the *get* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.inventory_items().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct InventoryItemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for InventoryItemGetCall<'a, C, A> {} + +impl<'a, C, A> InventoryItemGetCall<'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, InventoryItem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{projectId}/inventoryItems/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].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 ["id", "projectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// 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) -> InventoryItemGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Inventory item ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._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) -> InventoryItemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> InventoryItemGetCall<'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::Dfatrafficking`. + /// + /// 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) -> InventoryItemGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one user role permission by ID. +/// +/// A builder for the *get* method supported by a *userRolePermission* resource. +/// It is not used directly, but through a `UserRolePermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permissions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionGetCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionGetCall<'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, UserRolePermission)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRolePermissions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User role permission ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, C, A> { + self._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) -> UserRolePermissionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionGetCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a list of user role permissions, possibly filtered. +/// +/// A builder for the *list* method supported by a *userRolePermission* resource. +/// It is not used directly, but through a `UserRolePermissionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.user_role_permissions().list("profileId") +/// .add_ids("ea") +/// .doit(); +/// # } +/// ``` +pub struct UserRolePermissionListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserRolePermissionListCall<'a, C, A> {} + +impl<'a, C, A> UserRolePermissionListCall<'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, UserRolePermissionsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.userRolePermissions.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/userRolePermissions".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> UserRolePermissionListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user role permissions with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> UserRolePermissionListCall<'a, C, A> { + self._ids.push(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) -> UserRolePermissionListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserRolePermissionListCall<'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::Dfatrafficking`. + /// + /// 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) -> UserRolePermissionListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of account permission groups. +/// +/// A builder for the *list* method supported by a *accountPermissionGroup* resource. +/// It is not used directly, but through a `AccountPermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permission_groups().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGroupListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGroupListCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupListCall<'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, AccountPermissionGroupsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissionGroups.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountPermissionGroups".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGroupListCall<'a, C, A> { + self._profile_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) -> AccountPermissionGroupListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGroupListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGroupListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account permission group by ID. +/// +/// A builder for the *get* method supported by a *accountPermissionGroup* resource. +/// It is not used directly, but through a `AccountPermissionGroupMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_permission_groups().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPermissionGroupGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPermissionGroupGetCall<'a, C, A> {} + +impl<'a, C, A> AccountPermissionGroupGetCall<'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, AccountPermissionGroup)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountPermissionGroups.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountPermissionGroups/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account permission group ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, C, A> { + self._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) -> AccountPermissionGroupGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPermissionGroupGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPermissionGroupGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of content categories, possibly filtered. +/// +/// A builder for the *list* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().list("profileId") +/// .sort_order("ipsum") +/// .sort_field("gubergren") +/// .search_string("eos") +/// .page_token("sed") +/// .max_results(-98) +/// .add_ids("eirmod") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryListCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryListCall<'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, ContentCategoriesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "contentcategory*2015" will return objects with names like "contentcategory June 2015", "contentcategory April 2015", or simply "contentcategory 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "contentcategory" will match objects with name "my contentcategory", "contentcategory 2015", or simply "contentcategory". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ContentCategoryListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only content categories with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ContentCategoryListCall<'a, C, A> { + self._ids.push(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) -> ContentCategoryListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryListCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing content category. +/// +/// A builder for the *update* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryUpdateCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryUpdateCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryUpdateCall<'a, C, A> { + self._profile_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) -> ContentCategoryUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new content category. +/// +/// A builder for the *insert* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryInsertCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryInsertCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryInsertCall<'a, C, A> { + self._profile_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) -> ContentCategoryInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing content category. +/// +/// A builder for the *delete* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryDeleteCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryDeleteCall<'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: "dfareporting.contentCategories.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, C, A> { + self._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) -> ContentCategoryDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one content category by ID. +/// +/// A builder for the *get* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.content_categories().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryGetCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryGetCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, C, A> { + self._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) -> ContentCategoryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing content category. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *contentCategory* resource. +/// It is not used directly, but through a `ContentCategoryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::ContentCategory; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = ContentCategory::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.content_categories().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ContentCategoryPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: ContentCategory, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ContentCategoryPatchCall<'a, C, A> {} + +impl<'a, C, A> ContentCategoryPatchCall<'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, ContentCategory)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.contentCategories.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/contentCategories".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: ContentCategory) -> ContentCategoryPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Content category ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, C, A> { + self._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) -> ContentCategoryPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ContentCategoryPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> ContentCategoryPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative. +/// +/// A builder for the *update* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeUpdateCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativeUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeUpdateCall<'a, C, A> { + self._profile_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) -> CreativeUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative. +/// +/// A builder for the *insert* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeInsertCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativeInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeInsertCall<'a, C, A> { + self._profile_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) -> CreativeInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative by ID. +/// +/// A builder for the *get* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creatives().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeGetCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creatives/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeGetCall<'a, C, A> { + self._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) -> CreativeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creatives, possibly filtered. +/// +/// A builder for the *list* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creatives().list("profileId") +/// .add_types("dolore") +/// .studio_creative_id("Lorem") +/// .sort_order("invidunt") +/// .sort_field("duo") +/// .add_size_ids("dolor") +/// .search_string("accusam") +/// .add_rendering_ids("diam") +/// .page_token("dolor") +/// .max_results(-90) +/// .add_ids("amet") +/// .add_creative_field_ids("ipsum") +/// .add_companion_creative_ids("voluptua.") +/// .campaign_id("eirmod") +/// .archived(true) +/// .advertiser_id("accusam") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct CreativeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _types: Vec, + _studio_creative_id: Option, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _search_string: Option, + _rendering_ids: Vec, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _creative_field_ids: Vec, + _companion_creative_ids: Vec, + _campaign_id: Option, + _archived: Option, + _advertiser_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeListCall<'a, C, A> {} + +impl<'a, C, A> CreativeListCall<'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, CreativesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((19 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._types.len() > 0 { + for f in self._types.iter() { + params.push(("types", f.to_string())); + } + } + if let Some(value) = self._studio_creative_id { + params.push(("studioCreativeId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._rendering_ids.len() > 0 { + for f in self._rendering_ids.iter() { + params.push(("renderingIds", f.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._creative_field_ids.len() > 0 { + for f in self._creative_field_ids.iter() { + params.push(("creativeFieldIds", f.to_string())); + } + } + if self._companion_creative_ids.len() > 0 { + for f in self._companion_creative_ids.iter() { + params.push(("companionCreativeIds", f.to_string())); + } + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "types", "studioCreativeId", "sortOrder", "sortField", "sizeIds", "searchString", "renderingIds", "pageToken", "maxResults", "ids", "creativeFieldIds", "companionCreativeIds", "campaignId", "archived", "advertiserId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only creatives with these creative types. + /// + /// Append the given value to the *types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_types(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._types.push(new_value.to_string()); + self + } + /// Select only creatives corresponding to this Studio creative ID. + /// + /// Sets the *studio creative id* query property to the given value. + pub fn studio_creative_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._studio_creative_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only creatives with these size IDs. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "creative*2015" will return objects with names like "creative June 2015", "creative April 2015", or simply "creative 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "creative" will match objects with name "my creative", "creative 2015", or simply "creative". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only creatives with these rendering IDs. + /// + /// Append the given value to the *rendering ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_rendering_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._rendering_ids.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creatives with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only creatives with these creative field IDs. + /// + /// Append the given value to the *creative field ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_creative_field_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._creative_field_ids.push(new_value.to_string()); + self + } + /// Select only in-stream video creatives with these companion IDs. + /// + /// Append the given value to the *companion creative ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_companion_creative_ids(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._companion_creative_ids.push(new_value.to_string()); + self + } + /// Select only creatives with this campaign ID. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._campaign_id = Some(new_value.to_string()); + self + } + /// Select only archived creatives. Leave blank to select archived and unarchived creatives. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> CreativeListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only creatives with this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> CreativeListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only active creatives. Leave blank to select active and inactive creatives. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> CreativeListCall<'a, C, A> { + self._active = 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) -> CreativeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Creative::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.creatives().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Creative, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativePatchCall<'a, C, A> {} + +impl<'a, C, A> CreativePatchCall<'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, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Creative) -> CreativePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativePatchCall<'a, C, A> { + self._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) -> CreativePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one campaign by ID. +/// +/// A builder for the *get* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaigns().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CampaignGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignGetCall<'a, C, A> {} + +impl<'a, C, A> CampaignGetCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> CampaignGetCall<'a, C, A> { + self._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) -> CampaignGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new campaign. +/// +/// A builder for the *insert* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().insert(req, "profileId", "defaultLandingPageName", "defaultLandingPageUrl") +/// .doit(); +/// # } +/// ``` +pub struct CampaignInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _default_landing_page_name: String, + _default_landing_page_url: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignInsertCall<'a, C, A> {} + +impl<'a, C, A> CampaignInsertCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("defaultLandingPageName", self._default_landing_page_name.to_string())); + params.push(("defaultLandingPageUrl", self._default_landing_page_url.to_string())); + for &field in ["alt", "profileId", "defaultLandingPageName", "defaultLandingPageUrl"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Default landing page name for this new campaign. Must be less than 256 characters long. + /// + /// Sets the *default landing page 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 default_landing_page_name(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._default_landing_page_name = new_value.to_string(); + self + } + /// Default landing page URL for this new campaign. + /// + /// Sets the *default landing page url* 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 default_landing_page_url(mut self, new_value: &str) -> CampaignInsertCall<'a, C, A> { + self._default_landing_page_url = 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) -> CampaignInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CampaignPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignPatchCall<'a, C, A> {} + +impl<'a, C, A> CampaignPatchCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Campaign ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CampaignPatchCall<'a, C, A> { + self._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) -> CampaignPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing campaign. +/// +/// A builder for the *update* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Campaign; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Campaign::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.campaigns().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CampaignUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Campaign, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignUpdateCall<'a, C, A> {} + +impl<'a, C, A> CampaignUpdateCall<'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, Campaign)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Campaign) -> CampaignUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignUpdateCall<'a, C, A> { + self._profile_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) -> CampaignUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of campaigns, possibly filtered. +/// +/// A builder for the *list* method supported by a *campaign* resource. +/// It is not used directly, but through a `CampaignMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.campaigns().list("profileId") +/// .subaccount_id("invidunt") +/// .sort_order("amet") +/// .sort_field("dolor") +/// .search_string("voluptua.") +/// .page_token("et") +/// .overridden_event_tag_id("elitr") +/// .max_results(-12) +/// .add_ids("sit") +/// .add_excluded_ids("justo") +/// .at_least_one_optimization_activity(false) +/// .archived(false) +/// .add_advertiser_ids("amet.") +/// .add_advertiser_group_ids("dolor") +/// .doit(); +/// # } +/// ``` +pub struct CampaignListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _overridden_event_tag_id: Option, + _max_results: Option, + _ids: Vec, + _excluded_ids: Vec, + _at_least_one_optimization_activity: Option, + _archived: Option, + _advertiser_ids: Vec, + _advertiser_group_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CampaignListCall<'a, C, A> {} + +impl<'a, C, A> CampaignListCall<'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, CampaignsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.campaigns.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._overridden_event_tag_id { + params.push(("overriddenEventTagId", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._excluded_ids.len() > 0 { + for f in self._excluded_ids.iter() { + params.push(("excludedIds", f.to_string())); + } + } + if let Some(value) = self._at_least_one_optimization_activity { + params.push(("atLeastOneOptimizationActivity", value.to_string())); + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + if self._advertiser_group_ids.len() > 0 { + for f in self._advertiser_group_ids.iter() { + params.push(("advertiserGroupIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "overriddenEventTagId", "maxResults", "ids", "excludedIds", "atLeastOneOptimizationActivity", "archived", "advertiserIds", "advertiserGroupIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/campaigns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only campaigns that belong to this subaccount. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for campaigns by name or ID. Wildcards (*) are allowed. For example, "campaign*2015" will return campaigns with names like "campaign June 2015", "campaign April 2015", or simply "campaign 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "campaign" will match campaigns with name "my campaign", "campaign 2015", or simply "campaign". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only campaigns that have overridden this event tag ID. + /// + /// Sets the *overridden event tag id* query property to the given value. + pub fn overridden_event_tag_id(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._overridden_event_tag_id = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CampaignListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only campaigns with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Exclude campaigns with these IDs. + /// + /// Append the given value to the *excluded ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_excluded_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._excluded_ids.push(new_value.to_string()); + self + } + /// Select only campaigns that have at least one optimization activity. + /// + /// Sets the *at least one optimization activity* query property to the given value. + pub fn at_least_one_optimization_activity(mut self, new_value: bool) -> CampaignListCall<'a, C, A> { + self._at_least_one_optimization_activity = Some(new_value); + self + } + /// Select only archived campaigns. Don't set this field to select both archived and non-archived campaigns. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> CampaignListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only campaigns that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._advertiser_ids.push(new_value.to_string()); + self + } + /// Select only campaigns whose advertisers belong to these advertiser groups. + /// + /// Append the given value to the *advertiser group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_group_ids(mut self, new_value: &str) -> CampaignListCall<'a, C, A> { + self._advertiser_group_ids.push(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) -> CampaignListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CampaignListCall<'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::Dfatrafficking`. + /// + /// 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) -> CampaignListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing event tag. +/// +/// A builder for the *delete* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagDeleteCall<'a, C, A> {} + +impl<'a, C, A> EventTagDeleteCall<'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: "dfareporting.eventTags.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> EventTagDeleteCall<'a, C, A> { + self._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) -> EventTagDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of event tags, possibly filtered. +/// +/// A builder for the *list* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().list("profileId") +/// .sort_order("amet.") +/// .sort_field("eirmod") +/// .search_string("ea") +/// .add_ids("ea") +/// .add_event_tag_types("et") +/// .enabled(true) +/// .definitions_only(false) +/// .campaign_id("eos") +/// .advertiser_id("tempor") +/// .ad_id("sea") +/// .doit(); +/// # } +/// ``` +pub struct EventTagListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _ids: Vec, + _event_tag_types: Vec, + _enabled: Option, + _definitions_only: Option, + _campaign_id: Option, + _advertiser_id: Option, + _ad_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagListCall<'a, C, A> {} + +impl<'a, C, A> EventTagListCall<'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, EventTagsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._event_tag_types.len() > 0 { + for f in self._event_tag_types.iter() { + params.push(("eventTagTypes", f.to_string())); + } + } + if let Some(value) = self._enabled { + params.push(("enabled", value.to_string())); + } + if let Some(value) = self._definitions_only { + params.push(("definitionsOnly", value.to_string())); + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + if let Some(value) = self._ad_id { + params.push(("adId", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "ids", "eventTagTypes", "enabled", "definitionsOnly", "campaignId", "advertiserId", "adId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "eventtag*2015" will return objects with names like "eventtag June 2015", "eventtag April 2015", or simply "eventtag 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "eventtag" will match objects with name "my eventtag", "eventtag 2015", or simply "eventtag". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only event tags with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only event tags with the specified event tag types. Event tag types can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. + /// + /// Append the given value to the *event tag types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_event_tag_types(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._event_tag_types.push(new_value.to_string()); + self + } + /// Select only enabled event tags. What is considered enabled or disabled depends on the definitionsOnly parameter. When definitionsOnly is set to true, only the specified advertiser or campaign's event tags' enabledByDefault field is examined. When definitionsOnly is set to false, the specified ad or specified campaign's parent advertiser's or parent campaign's event tags' enabledByDefault and status fields are examined as well. + /// + /// Sets the *enabled* query property to the given value. + pub fn enabled(mut self, new_value: bool) -> EventTagListCall<'a, C, A> { + self._enabled = Some(new_value); + self + } + /// Examine only the specified campaign or advertiser's event tags for matching selector criteria. When set to false, the parent advertiser and parent campaign of the specified ad or campaign is examined as well. In addition, when set to false, the status field is examined as well, along with the enabledByDefault field. This parameter can not be set to true when adId is specified as ads do not define their own even tags. + /// + /// Sets the *definitions only* query property to the given value. + pub fn definitions_only(mut self, new_value: bool) -> EventTagListCall<'a, C, A> { + self._definitions_only = Some(new_value); + self + } + /// Select only event tags that belong to this campaign. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._campaign_id = Some(new_value.to_string()); + self + } + /// Select only event tags that belong to this advertiser. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._advertiser_id = Some(new_value.to_string()); + self + } + /// Select only event tags that belong to this ad. + /// + /// Sets the *ad id* query property to the given value. + pub fn ad_id(mut self, new_value: &str) -> EventTagListCall<'a, C, A> { + self._ad_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) -> EventTagListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagListCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new event tag. +/// +/// A builder for the *insert* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct EventTagInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagInsertCall<'a, C, A> {} + +impl<'a, C, A> EventTagInsertCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagInsertCall<'a, C, A> { + self._profile_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) -> EventTagInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing event tag. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagPatchCall<'a, C, A> {} + +impl<'a, C, A> EventTagPatchCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> EventTagPatchCall<'a, C, A> { + self._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) -> EventTagPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing event tag. +/// +/// A builder for the *update* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::EventTag; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = EventTag::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.event_tags().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct EventTagUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: EventTag, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagUpdateCall<'a, C, A> {} + +impl<'a, C, A> EventTagUpdateCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: EventTag) -> EventTagUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagUpdateCall<'a, C, A> { + self._profile_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) -> EventTagUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one event tag by ID. +/// +/// A builder for the *get* method supported by a *eventTag* resource. +/// It is not used directly, but through a `EventTagMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.event_tags().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct EventTagGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for EventTagGetCall<'a, C, A> {} + +impl<'a, C, A> EventTagGetCall<'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, EventTag)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.eventTags.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/eventTags/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> EventTagGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Event tag ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> EventTagGetCall<'a, C, A> { + self._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) -> EventTagGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> EventTagGetCall<'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::Dfatrafficking`. + /// + /// 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) -> EventTagGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_lists().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListGetCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._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) -> RemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListGetCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. +/// +/// A builder for the *update* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListUpdateCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListUpdateCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListUpdateCall<'a, C, A> { + self._profile_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) -> RemarketingListUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.remarketing_lists().list("profileId", "advertiserId") +/// .sort_order("sea") +/// .sort_field("amet.") +/// .page_token("clita") +/// .name("clita") +/// .max_results(-6) +/// .floodlight_activity_id("sit") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option, + _sort_field: Option, + _page_token: Option, + _name: Option, + _max_results: Option, + _floodlight_activity_id: Option, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListListCall<'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, RemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._floodlight_activity_id { + params.push(("floodlightActivityId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "floodlightActivityId", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only remarketing lists owned by this advertiser. + /// + /// Sets the *advertiser id* 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 advertiser_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> RemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only remarketing lists that have this floodlight activity ID. + /// + /// Sets the *floodlight activity id* query property to the given value. + pub fn floodlight_activity_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._floodlight_activity_id = Some(new_value.to_string()); + self + } + /// Select only active or only inactive remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> RemarketingListListCall<'a, C, A> { + self._active = 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) -> RemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListListCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListPatchCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListPatchCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._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) -> RemarketingListPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new remarketing list. +/// +/// A builder for the *insert* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = RemarketingList::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.remarketing_lists().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for RemarketingListInsertCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListInsertCall<'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, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: RemarketingList) -> RemarketingListInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> RemarketingListInsertCall<'a, C, A> { + self._profile_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) -> RemarketingListInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> RemarketingListInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> RemarketingListInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of cities, possibly filtered. +/// +/// A builder for the *list* method supported by a *city* resource. +/// It is not used directly, but through a `CityMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.cities().list("profileId") +/// .add_region_dart_ids("ea") +/// .name_prefix("dolor") +/// .add_dart_ids("consetetur") +/// .add_country_dart_ids("sadipscing") +/// .doit(); +/// # } +/// ``` +pub struct CityListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _region_dart_ids: Vec, + _name_prefix: Option, + _dart_ids: Vec, + _country_dart_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CityListCall<'a, C, A> {} + +impl<'a, C, A> CityListCall<'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, CitiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.cities.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._region_dart_ids.len() > 0 { + for f in self._region_dart_ids.iter() { + params.push(("regionDartIds", f.to_string())); + } + } + if let Some(value) = self._name_prefix { + params.push(("namePrefix", value.to_string())); + } + if self._dart_ids.len() > 0 { + for f in self._dart_ids.iter() { + params.push(("dartIds", f.to_string())); + } + } + if self._country_dart_ids.len() > 0 { + for f in self._country_dart_ids.iter() { + params.push(("countryDartIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "regionDartIds", "namePrefix", "dartIds", "countryDartIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/cities".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only cities from these regions. + /// + /// Append the given value to the *region dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_region_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._region_dart_ids.push(new_value.to_string()); + self + } + /// Select only cities with names starting with this prefix. + /// + /// Sets the *name prefix* query property to the given value. + pub fn name_prefix(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._name_prefix = Some(new_value.to_string()); + self + } + /// Select only cities with these DART IDs. + /// + /// Append the given value to the *dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._dart_ids.push(new_value.to_string()); + self + } + /// Select only cities from these countries. + /// + /// Append the given value to the *country dart ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_country_dart_ids(mut self, new_value: &str) -> CityListCall<'a, C, A> { + self._country_dart_ids.push(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) -> CityListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CityListCall<'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::Dfatrafficking`. + /// + /// 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) -> CityListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement strategy. +/// +/// A builder for the *update* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyUpdateCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + self._profile_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) -> PlacementStrategyUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement strategy by ID. +/// +/// A builder for the *get* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyGetCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._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) -> PlacementStrategyGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placement strategies, possibly filtered. +/// +/// A builder for the *list* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().list("profileId") +/// .sort_order("sit") +/// .sort_field("dolor") +/// .search_string("et") +/// .page_token("amet") +/// .max_results(-2) +/// .add_ids("vero") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyListCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyListCall<'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, PlacementStrategiesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "placementstrategy*2015" will return objects with names like "placementstrategy June 2015", "placementstrategy April 2015", or simply "placementstrategy 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementstrategy" will match objects with name "my placementstrategy", "placementstrategy 2015", or simply "placementstrategy". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementStrategyListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placement strategies with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C, A> { + self._ids.push(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) -> PlacementStrategyListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing placement strategy. +/// +/// A builder for the *delete* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placement_strategies().delete("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyDeleteCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyDeleteCall<'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: "dfareporting.placementStrategies.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, C, A> { + self._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) -> PlacementStrategyDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement strategy. +/// +/// A builder for the *insert* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyInsertCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyInsertCall<'a, C, A> { + self._profile_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) -> PlacementStrategyInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement strategy. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = PlacementStrategy::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.placement_strategies().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: PlacementStrategy, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementStrategyPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyPatchCall<'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, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: PlacementStrategy) -> PlacementStrategyPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, C, A> { + self._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) -> PlacementStrategyPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementStrategyPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementStrategyPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of projects, possibly filtered. +/// +/// A builder for the *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_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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().list("profileId") +/// .sort_order("accusam") +/// .sort_field("et") +/// .search_string("clita") +/// .page_token("tempor") +/// .max_results(-86) +/// .add_ids("kasd") +/// .add_advertiser_ids("diam") +/// .doit(); +/// # } +/// ``` +pub struct ProjectListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for ProjectListCall<'a, C, A> {} + +impl<'a, C, A> ProjectListCall<'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, ProjectsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.projects.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for projects by name or ID. Wildcards (*) are allowed. For example, "project*2015" will return projects with names like "project June 2015", "project April 2015", or simply "project 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "project" will match projects with name "my project", "project 2015", or simply "project". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ProjectListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only projects with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only projects with these advertiser IDs. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._advertiser_ids.push(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) -> ProjectListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ProjectListCall<'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::Dfatrafficking`. + /// + /// 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) -> ProjectListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one project by ID. +/// +/// 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_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ProjectGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: 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: "dfareporting.projects.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/projects/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._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) -> 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::Dfatrafficking`. + /// + /// 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 + } +} + + +/// Inserts a new directory site. +/// +/// A builder for the *insert* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::DirectorySite; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DirectorySite::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.directory_sites().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DirectorySite, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteInsertCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteInsertCall<'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, DirectorySite)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/directorySites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DirectorySite) -> DirectorySiteInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteInsertCall<'a, C, A> { + self._profile_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) -> DirectorySiteInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of directory sites, possibly filtered. +/// +/// A builder for the *list* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_sites().list("profileId") +/// .sort_order("tempor") +/// .sort_field("ipsum") +/// .search_string("no") +/// .parent_id("takimata") +/// .page_token("takimata") +/// .max_results(-11) +/// .add_ids("clita") +/// .dfp_network_code("et") +/// .country_id("justo") +/// .active(true) +/// .accepts_publisher_paid_placements(false) +/// .accepts_interstitial_placements(true) +/// .accepts_in_stream_video_placements(false) +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _parent_id: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _dfp_network_code: Option, + _country_id: Option, + _active: Option, + _accepts_publisher_paid_placements: Option, + _accepts_interstitial_placements: Option, + _accepts_in_stream_video_placements: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteListCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteListCall<'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, DirectorySitesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((16 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._parent_id { + params.push(("parentId", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._dfp_network_code { + params.push(("dfp_network_code", value.to_string())); + } + if let Some(value) = self._country_id { + params.push(("countryId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + if let Some(value) = self._accepts_publisher_paid_placements { + params.push(("acceptsPublisherPaidPlacements", value.to_string())); + } + if let Some(value) = self._accepts_interstitial_placements { + params.push(("acceptsInterstitialPlacements", value.to_string())); + } + if let Some(value) = self._accepts_in_stream_video_placements { + params.push(("acceptsInStreamVideoPlacements", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "parentId", "pageToken", "maxResults", "ids", "dfp_network_code", "countryId", "active", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/directorySites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or URL. Wildcards (*) are allowed. For example, "directory site*2015" will return objects with names like "directory site June 2015", "directory site April 2015", or simply "directory site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site" will match objects with name "my directory site", "directory site 2015" or simply, "directory site". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only directory sites with this parent ID. + /// + /// Sets the *parent id* query property to the given value. + pub fn parent_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._parent_id = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DirectorySiteListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only directory sites with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only directory sites with this DFP network code. + /// + /// Sets the *dfp_network_code* query property to the given value. + pub fn dfp_network_code(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._dfp_network_code = Some(new_value.to_string()); + self + } + /// Select only directory sites with this country ID. + /// + /// Sets the *country id* query property to the given value. + pub fn country_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, C, A> { + self._country_id = Some(new_value.to_string()); + self + } + /// Select only active directory sites. Leave blank to retrieve both active and inactive directory sites. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._active = Some(new_value); + self + } + /// Select only directory sites that accept publisher paid placements. This field can be left blank. + /// + /// Sets the *accepts publisher paid placements* query property to the given value. + pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_publisher_paid_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts interstitial placements* query property to the given value. + pub fn accepts_interstitial_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_interstitial_placements = Some(new_value); + self + } + /// This search filter is no longer supported and will have no effect on the results returned. + /// + /// Sets the *accepts in stream video placements* query property to the given value. + pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, C, A> { + self._accepts_in_stream_video_placements = 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) -> DirectorySiteListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteListCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one directory site by ID. +/// +/// A builder for the *get* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.directory_sites().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DirectorySiteGetCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteGetCall<'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, DirectorySite)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/directorySites/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Directory site ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, C, A> { + self._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) -> DirectorySiteGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DirectorySiteGetCall<'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::Dfatrafficking`. + /// + /// 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) -> DirectorySiteGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing dynamic targeting key. +/// +/// A builder for the *delete* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.dynamic_targeting_keys().delete("profileId", "objectId", "name", "objectType") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _object_id: String, + _name: String, + _object_type: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyDeleteCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyDeleteCall<'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: "dfareporting.dynamicTargetingKeys.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("objectId", self._object_id.to_string())); + params.push(("name", self._name.to_string())); + params.push(("objectType", self._object_type.to_string())); + for &field in ["profileId", "objectId", "name", "objectType"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/dynamicTargetingKeys/{objectId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{objectId}", "objectId")].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 ["objectId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// ID of the object of this dynamic targeting key. This is a required field. + /// + /// Sets the *object 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 object_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._object_id = new_value.to_string(); + self + } + /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase. + /// + /// Sets the *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 name(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._name = new_value.to_string(); + self + } + /// Type of the object of this dynamic targeting key. This is a required field. + /// + /// Sets the *object type* 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 object_type(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._object_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) -> DynamicTargetingKeyDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of dynamic targeting keys. +/// +/// A builder for the *list* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.dynamic_targeting_keys().list("profileId") +/// .object_type("amet.") +/// .object_id("rebum.") +/// .add_names("sit") +/// .advertiser_id("Lorem") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _object_type: Option, + _object_id: Option, + _names: Vec, + _advertiser_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyListCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyListCall<'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, DynamicTargetingKeysListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dynamicTargetingKeys.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._object_type { + params.push(("objectType", value.to_string())); + } + if let Some(value) = self._object_id { + params.push(("objectId", value.to_string())); + } + if self._names.len() > 0 { + for f in self._names.iter() { + params.push(("names", f.to_string())); + } + } + if let Some(value) = self._advertiser_id { + params.push(("advertiserId", value.to_string())); + } + for &field in ["alt", "profileId", "objectType", "objectId", "names", "advertiserId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/dynamicTargetingKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only dynamic targeting keys with this object type. + /// + /// Sets the *object type* query property to the given value. + pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._object_type = Some(new_value.to_string()); + self + } + /// Select only dynamic targeting keys with this object ID. + /// + /// Sets the *object id* query property to the given value. + pub fn object_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._object_id = Some(new_value.to_string()); + self + } + /// Select only dynamic targeting keys exactly matching these names. + /// + /// Append the given value to the *names* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_names(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._names.push(new_value.to_string()); + self + } + /// Select only dynamic targeting keys whose object has this advertiser ID. + /// + /// Sets the *advertiser id* query property to the given value. + pub fn advertiser_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C, A> { + self._advertiser_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) -> DynamicTargetingKeyListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyListCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement. +/// +/// A builder for the *insert* method supported by a *dynamicTargetingKey* resource. +/// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::DynamicTargetingKey; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = DynamicTargetingKey::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.dynamic_targeting_keys().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct DynamicTargetingKeyInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: DynamicTargetingKey, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for DynamicTargetingKeyInsertCall<'a, C, A> {} + +impl<'a, C, A> DynamicTargetingKeyInsertCall<'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, DynamicTargetingKey)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.dynamicTargetingKeys.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/dynamicTargetingKeys".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: DynamicTargetingKey) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._profile_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) -> DynamicTargetingKeyInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> DynamicTargetingKeyInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> DynamicTargetingKeyInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new size. +/// +/// A builder for the *insert* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Size; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Size::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.sizes().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct SizeInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Size, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeInsertCall<'a, C, A> {} + +impl<'a, C, A> SizeInsertCall<'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, Size)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sizes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Size) -> SizeInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeInsertCall<'a, C, A> { + self._profile_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) -> SizeInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of sizes, possibly filtered. +/// +/// A builder for the *list* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sizes().list("profileId") +/// .width(-6) +/// .add_ids("invidunt") +/// .iab_standard(false) +/// .height(-22) +/// .doit(); +/// # } +/// ``` +pub struct SizeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _width: Option, + _ids: Vec, + _iab_standard: Option, + _height: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeListCall<'a, C, A> {} + +impl<'a, C, A> SizeListCall<'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, SizesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._width { + params.push(("width", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._iab_standard { + params.push(("iabStandard", value.to_string())); + } + if let Some(value) = self._height { + params.push(("height", value.to_string())); + } + for &field in ["alt", "profileId", "width", "ids", "iabStandard", "height"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sizes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only sizes with this width. + /// + /// Sets the *width* query property to the given value. + pub fn width(mut self, new_value: i32) -> SizeListCall<'a, C, A> { + self._width = Some(new_value); + self + } + /// Select only sizes with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> SizeListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only IAB standard sizes. + /// + /// Sets the *iab standard* query property to the given value. + pub fn iab_standard(mut self, new_value: bool) -> SizeListCall<'a, C, A> { + self._iab_standard = Some(new_value); + self + } + /// Select only sizes with this height. + /// + /// Sets the *height* query property to the given value. + pub fn height(mut self, new_value: i32) -> SizeListCall<'a, C, A> { + self._height = 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) -> SizeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeListCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one size by ID. +/// +/// A builder for the *get* method supported by a *size* resource. +/// It is not used directly, but through a `SizeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.sizes().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct SizeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for SizeGetCall<'a, C, A> {} + +impl<'a, C, A> SizeGetCall<'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, Size)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.sizes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/sizes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> SizeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Size ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> SizeGetCall<'a, C, A> { + self._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) -> SizeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> SizeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> SizeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the account's active ad summary by account ID. +/// +/// A builder for the *get* method supported by a *accountActiveAdSummary* resource. +/// It is not used directly, but through a `AccountActiveAdSummaryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_active_ad_summaries().get("profileId", "summaryAccountId") +/// .doit(); +/// # } +/// ``` +pub struct AccountActiveAdSummaryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _summary_account_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountActiveAdSummaryGetCall<'a, C, A> {} + +impl<'a, C, A> AccountActiveAdSummaryGetCall<'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, AccountActiveAdSummary)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountActiveAdSummaries.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("summaryAccountId", self._summary_account_id.to_string())); + for &field in ["alt", "profileId", "summaryAccountId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{summaryAccountId}", "summaryAccountId")].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 ["summaryAccountId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *summary account 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 summary_account_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._summary_account_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) -> AccountActiveAdSummaryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountActiveAdSummaryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountActiveAdSummaryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account user profile. +/// +/// A builder for the *update* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileUpdateCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileUpdateCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfileUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileUpdateCall<'a, C, A> { + self._profile_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) -> AccountUserProfileUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of account user profiles, possibly filtered. +/// +/// A builder for the *list* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_user_profiles().list("profileId") +/// .user_role_id("duo") +/// .subaccount_id("et") +/// .sort_order("est") +/// .sort_field("et") +/// .search_string("et") +/// .page_token("clita") +/// .max_results(-45) +/// .add_ids("magna") +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _user_role_id: Option, + _subaccount_id: Option, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileListCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileListCall<'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, AccountUserProfilesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._user_role_id { + params.push(("userRoleId", value.to_string())); + } + if let Some(value) = self._subaccount_id { + params.push(("subaccountId", value.to_string())); + } + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "userRoleId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only user profiles with the specified user role ID. + /// + /// Sets the *user role id* query property to the given value. + pub fn user_role_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._user_role_id = Some(new_value.to_string()); + self + } + /// Select only user profiles with the specified subaccount ID. + /// + /// Sets the *subaccount id* query property to the given value. + pub fn subaccount_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._subaccount_id = Some(new_value.to_string()); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "user profile*2015" will return objects with names like "user profile June 2015", "user profile April 2015", or simply "user profile 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "user profile" will match objects with name "my user profile", "user profile 2015", or simply "user profile". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AccountUserProfileListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only user profiles with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only active user profiles. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AccountUserProfileListCall<'a, C, A> { + self._active = 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) -> AccountUserProfileListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new account user profile. +/// +/// A builder for the *insert* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileInsertCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileInsertCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfileInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileInsertCall<'a, C, A> { + self._profile_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) -> AccountUserProfileInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account user profile. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = AccountUserProfile::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.account_user_profiles().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfilePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: AccountUserProfile, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfilePatchCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfilePatchCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: AccountUserProfile) -> AccountUserProfilePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User profile ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, C, A> { + self._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) -> AccountUserProfilePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfilePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfilePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account user profile by ID. +/// +/// A builder for the *get* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.account_user_profiles().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUserProfileGetCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileGetCall<'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, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accountUserProfiles/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// User profile ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, C, A> { + self._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) -> AccountUserProfileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUserProfileGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUserProfileGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of countries. +/// +/// A builder for the *list* method supported by a *country* resource. +/// It is not used directly, but through a `CountryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.countries().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct CountryListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CountryListCall<'a, C, A> {} + +impl<'a, C, A> CountryListCall<'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, CountriesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.countries.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/countries".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CountryListCall<'a, C, A> { + self._profile_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) -> CountryListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CountryListCall<'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::Dfatrafficking`. + /// + /// 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) -> CountryListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one country by ID. +/// +/// A builder for the *get* method supported by a *country* resource. +/// It is not used directly, but through a `CountryMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.countries().get("profileId", "dartId") +/// .doit(); +/// # } +/// ``` +pub struct CountryGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _dart_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CountryGetCall<'a, C, A> {} + +impl<'a, C, A> CountryGetCall<'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, Country)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.countries.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("dartId", self._dart_id.to_string())); + for &field in ["alt", "profileId", "dartId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/countries/{dartId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].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 ["dartId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CountryGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Country DART ID. + /// + /// Sets the *dart 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 dart_id(mut self, new_value: &str) -> CountryGetCall<'a, C, A> { + self._dart_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) -> CountryGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CountryGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CountryGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field value. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().patch(req, "profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValuePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValuePatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValuePatchCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._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) -> CreativeFieldValuePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValuePatchCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValuePatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative field value by ID. +/// +/// A builder for the *get* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().get("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueGetCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].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 ["id", "creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._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) -> CreativeFieldValueGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueGetCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing creative field value. +/// +/// A builder for the *delete* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().delete("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueDeleteCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueDeleteCall<'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: "dfareporting.creativeFieldValues.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].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 ["id", "creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *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 id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._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) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueDeleteCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative field value. +/// +/// A builder for the *insert* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().insert(req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueInsertCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._creative_field_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) -> CreativeFieldValueInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field value. +/// +/// A builder for the *update* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = CreativeFieldValue::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.creative_field_values().update(req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueUpdateCall<'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, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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: CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._creative_field_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) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative field values, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.creative_field_values().list("profileId", "creativeFieldId") +/// .sort_order("dolore") +/// .sort_field("dolor") +/// .search_string("ipsum") +/// .page_token("et") +/// .max_results(-12) +/// .add_ids("sed") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _creative_field_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueListCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueListCall<'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, CreativeFieldValuesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + for &field in ["alt", "profileId", "creativeFieldId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].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 ["creativeFieldId", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field 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 creative_field_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed. + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative field values with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._ids.push(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) -> CreativeFieldValueListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> CreativeFieldValueListCall<'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::Dfatrafficking`. + /// + /// 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) -> CreativeFieldValueListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one postal code by ID. +/// +/// A builder for the *get* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.postal_codes().get("profileId", "code") +/// .doit(); +/// # } +/// ``` +pub struct PostalCodeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _code: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PostalCodeGetCall<'a, C, A> {} + +impl<'a, C, A> PostalCodeGetCall<'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, PostalCode)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("code", self._code.to_string())); + for &field in ["alt", "profileId", "code"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/postalCodes/{code}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{code}", "code")].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 ["code", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Postal code ID. + /// + /// Sets the *code* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn code(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { + self._code = 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) -> PostalCodeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PostalCodeGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PostalCodeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of postal codes. +/// +/// A builder for the *list* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.postal_codes().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct PostalCodeListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PostalCodeListCall<'a, C, A> {} + +impl<'a, C, A> PostalCodeListCall<'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, PostalCodesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/postalCodes".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PostalCodeListCall<'a, C, A> { + self._profile_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) -> PostalCodeListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PostalCodeListCall<'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::Dfatrafficking`. + /// + /// 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) -> PostalCodeListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of browsers. +/// +/// A builder for the *list* method supported by a *browser* resource. +/// It is not used directly, but through a `BrowserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.browsers().list("profileId") +/// .doit(); +/// # } +/// ``` +pub struct BrowserListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for BrowserListCall<'a, C, A> {} + +impl<'a, C, A> BrowserListCall<'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, BrowsersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.browsers.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/browsers".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> BrowserListCall<'a, C, A> { + self._profile_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) -> BrowserListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> BrowserListCall<'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::Dfatrafficking`. + /// + /// 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) -> BrowserListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one account by ID. +/// +/// A builder for the *get* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.accounts().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} + +impl<'a, C, A> AccountGetCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accounts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._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) -> AccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountGetCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of accounts, possibly filtered. +/// +/// A builder for the *list* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.accounts().list("profileId") +/// .sort_order("sea") +/// .sort_field("consetetur") +/// .search_string("sea") +/// .page_token("voluptua.") +/// .max_results(-77) +/// .add_ids("sanctus") +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct AccountListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _search_string: Option, + _page_token: Option, + _max_results: Option, + _ids: Vec, + _active: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountListCall<'a, C, A> {} + +impl<'a, C, A> AccountListCall<'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, AccountsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.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 self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "account*2015" will return objects with names like "account June 2015", "account April 2015", or simply "account 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "account" will match objects with name "my account", "account 2015", or simply "account". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only accounts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only active accounts. Don't set this field to select both active and non-active accounts. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AccountListCall<'a, C, A> { + self._active = 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) -> AccountListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountListCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. +/// +/// A builder for the *update* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Account::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.accounts().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Account, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} + +impl<'a, C, A> AccountUpdateCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Account) -> AccountUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { + self._profile_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) -> AccountUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Account::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.accounts().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Account, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountPatchCall<'a, C, A> {} + +impl<'a, C, A> AccountPatchCall<'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, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Account) -> AccountPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._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) -> AccountPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> AccountPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().patch(req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementPatchCall<'a, C, A> {} + +impl<'a, C, A> PlacementPatchCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement ID. + /// + /// Sets the *id* 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 id(mut self, new_value: &str) -> PlacementPatchCall<'a, C, A> { + self._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) -> PlacementPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementPatchCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementPatchCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of placements, possibly filtered. +/// +/// A builder for the *list* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().list("profileId") +/// .sort_order("eirmod") +/// .sort_field("elitr") +/// .add_size_ids("gubergren") +/// .add_site_ids("sit") +/// .search_string("et") +/// .add_pricing_types("sea") +/// .add_placement_strategy_ids("justo") +/// .payment_source("dolore") +/// .page_token("At") +/// .min_start_date("dolor") +/// .min_end_date("tempor") +/// .max_start_date("ipsum") +/// .max_results(-56) +/// .max_end_date("et") +/// .add_ids("no") +/// .add_group_ids("sed") +/// .add_directory_site_ids("kasd") +/// .add_content_category_ids("ipsum") +/// .add_compatibilities("sadipscing") +/// .add_campaign_ids("sea") +/// .archived(false) +/// .add_advertiser_ids("dolor") +/// .doit(); +/// # } +/// ``` +pub struct PlacementListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _sort_order: Option, + _sort_field: Option, + _size_ids: Vec, + _site_ids: Vec, + _search_string: Option, + _pricing_types: Vec, + _placement_strategy_ids: Vec, + _payment_source: Option, + _page_token: Option, + _min_start_date: Option, + _min_end_date: Option, + _max_start_date: Option, + _max_results: Option, + _max_end_date: Option, + _ids: Vec, + _group_ids: Vec, + _directory_site_ids: Vec, + _content_category_ids: Vec, + _compatibilities: Vec, + _campaign_ids: Vec, + _archived: Option, + _advertiser_ids: Vec, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementListCall<'a, C, A> {} + +impl<'a, C, A> PlacementListCall<'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, PlacementsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((25 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._size_ids.len() > 0 { + for f in self._size_ids.iter() { + params.push(("sizeIds", f.to_string())); + } + } + if self._site_ids.len() > 0 { + for f in self._site_ids.iter() { + params.push(("siteIds", f.to_string())); + } + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if self._pricing_types.len() > 0 { + for f in self._pricing_types.iter() { + params.push(("pricingTypes", f.to_string())); + } + } + if self._placement_strategy_ids.len() > 0 { + for f in self._placement_strategy_ids.iter() { + params.push(("placementStrategyIds", f.to_string())); + } + } + if let Some(value) = self._payment_source { + params.push(("paymentSource", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._min_start_date { + params.push(("minStartDate", value.to_string())); + } + if let Some(value) = self._min_end_date { + params.push(("minEndDate", value.to_string())); + } + if let Some(value) = self._max_start_date { + params.push(("maxStartDate", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._max_end_date { + params.push(("maxEndDate", value.to_string())); + } + if self._ids.len() > 0 { + for f in self._ids.iter() { + params.push(("ids", f.to_string())); + } + } + if self._group_ids.len() > 0 { + for f in self._group_ids.iter() { + params.push(("groupIds", f.to_string())); + } + } + if self._directory_site_ids.len() > 0 { + for f in self._directory_site_ids.iter() { + params.push(("directorySiteIds", f.to_string())); + } + } + if self._content_category_ids.len() > 0 { + for f in self._content_category_ids.iter() { + params.push(("contentCategoryIds", f.to_string())); + } + } + if self._compatibilities.len() > 0 { + for f in self._compatibilities.iter() { + params.push(("compatibilities", f.to_string())); + } + } + if self._campaign_ids.len() > 0 { + for f in self._campaign_ids.iter() { + params.push(("campaignIds", f.to_string())); + } + } + if let Some(value) = self._archived { + params.push(("archived", value.to_string())); + } + if self._advertiser_ids.len() > 0 { + for f in self._advertiser_ids.iter() { + params.push(("advertiserIds", f.to_string())); + } + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "sizeIds", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "paymentSource", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "groupIds", "directorySiteIds", "contentCategoryIds", "compatibilities", "campaignIds", "archived", "advertiserIds"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only placements that are associated with these sizes. + /// + /// Append the given value to the *size ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_size_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._size_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these sites. + /// + /// Append the given value to the *site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._site_ids.push(new_value.to_string()); + self + } + /// Allows searching for placements by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placements with names like "placement June 2015", "placement May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placement" will match placements with name "my placement", "placement 2015", or simply "placement". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Select only placements with these pricing types. + /// + /// Append the given value to the *pricing types* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_pricing_types(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._pricing_types.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these placement strategies. + /// + /// Append the given value to the *placement strategy ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._placement_strategy_ids.push(new_value.to_string()); + self + } + /// Select only placements with this payment source. + /// + /// Sets the *payment source* query property to the given value. + pub fn payment_source(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._payment_source = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min start date* query property to the given value. + pub fn min_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._min_start_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *min end date* query property to the given value. + pub fn min_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._min_end_date = Some(new_value.to_string()); + self + } + /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max start date* query property to the given value. + pub fn max_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._max_start_date = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PlacementListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd". + /// + /// Sets the *max end date* query property to the given value. + pub fn max_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._max_end_date = Some(new_value.to_string()); + self + } + /// Select only placements with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only placements that belong to these placement groups. + /// + /// Append the given value to the *group ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_group_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._group_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these directory sites. + /// + /// Append the given value to the *directory site ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._directory_site_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these content categories. + /// + /// Append the given value to the *content category ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._content_category_ids.push(new_value.to_string()); + self + } + /// Select only placements that are associated with these compatibilities. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. + /// + /// Append the given value to the *compatibilities* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_compatibilities(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._compatibilities.push(new_value.to_string()); + self + } + /// Select only placements that belong to these campaigns. + /// + /// Append the given value to the *campaign ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._campaign_ids.push(new_value.to_string()); + self + } + /// Select only archived placements. Don't set this field to select both archived and non-archived placements. + /// + /// Sets the *archived* query property to the given value. + pub fn archived(mut self, new_value: bool) -> PlacementListCall<'a, C, A> { + self._archived = Some(new_value); + self + } + /// Select only placements that belong to these advertisers. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementListCall<'a, C, A> { + self._advertiser_ids.push(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) -> PlacementListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementListCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement by ID. +/// +/// A builder for the *get* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementGetCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].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 ["id", "profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement ID. + /// + /// Sets the *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 id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._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) -> PlacementGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGetCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new placement. +/// +/// A builder for the *insert* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().insert(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementInsertCall<'a, C, A> {} + +impl<'a, C, A> PlacementInsertCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementInsertCall<'a, C, A> { + self._profile_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) -> PlacementInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementInsertCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing placement. +/// +/// A builder for the *update* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// use dfareporting2d6::Placement; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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 = Placement::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.placements().update(req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _request: Placement, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementUpdateCall<'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, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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: Placement) -> PlacementUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementUpdateCall<'a, C, A> { + self._profile_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) -> PlacementUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementUpdateCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Generates tags for a placement. +/// +/// A builder for the *generatetags* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d6 as dfareporting2d6; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d6::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Dfareporting::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.placements().generatetags("profileId") +/// .add_tag_formats("dolor") +/// .add_placement_ids("diam") +/// .campaign_id("no") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGeneratetagCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting, + _profile_id: String, + _tag_formats: Vec, + _placement_ids: Vec, + _campaign_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for PlacementGeneratetagCall<'a, C, A> {} + +impl<'a, C, A> PlacementGeneratetagCall<'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, PlacementsGenerateTagsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.generatetags", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if self._tag_formats.len() > 0 { + for f in self._tag_formats.iter() { + params.push(("tagFormats", f.to_string())); + } + } + if self._placement_ids.len() > 0 { + for f in self._placement_ids.iter() { + params.push(("placementIds", f.to_string())); + } + } + if let Some(value) = self._campaign_id { + params.push(("campaignId", value.to_string())); + } + for &field in ["alt", "profileId", "tagFormats", "placementIds", "campaignId"].iter() { + if self._additional_params.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/dfareporting/v2.6/userprofiles/{profileId}/placements/generatetags".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].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 ["profileId"].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) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile 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 profile_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Tag formats to generate for these placements. + /// + /// Append the given value to the *tag formats* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_tag_formats(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._tag_formats.push(new_value.to_string()); + self + } + /// Generate tags for these placements. + /// + /// Append the given value to the *placement ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_placement_ids(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._placement_ids.push(new_value.to_string()); + self + } + /// Generate placements belonging to this campaign. This is a required field. + /// + /// Sets the *campaign id* query property to the given value. + pub fn campaign_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C, A> { + self._campaign_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) -> PlacementGeneratetagCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> PlacementGeneratetagCall<'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::Dfatrafficking`. + /// + /// 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) -> PlacementGeneratetagCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/discovery1-cli/Cargo.toml b/gen/discovery1-cli/Cargo.toml index 24f191528d..514f6e44e2 100644 --- a/gen/discovery1-cli/Cargo.toml +++ b/gen/discovery1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "discovery1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-discovery1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-discovery1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-discovery1] diff --git a/gen/discovery1-cli/src/main.rs b/gen/discovery1-cli/src/main.rs index 077ddd399f..74283b504a 100644 --- a/gen/discovery1-cli/src/main.rs +++ b/gen/discovery1-cli/src/main.rs @@ -303,7 +303,7 @@ fn main() { let mut app = App::new("discovery1") .author("Sebastian Thiel ") .version("0.3.6+00000000") - .about("Lets you discover information about other Google APIs, such as what APIs are available, the resource and method details for each API.") + .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") .long("config-dir") diff --git a/gen/discovery1/Cargo.toml b/gen/discovery1/Cargo.toml index e8c1f889b6..b58b3072bc 100644 --- a/gen/discovery1/Cargo.toml +++ b/gen/discovery1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dns1-cli/Cargo.toml b/gen/dns1-cli/Cargo.toml index b65416dcae..3422d11437 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+20160224" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "dns1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-dns1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-dns1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-dns1] diff --git a/gen/dns1-cli/README.md b/gen/dns1-cli/README.md index 459bd86f4e..70bd84c544 100644 --- a/gen/dns1-cli/README.md +++ b/gen/dns1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *dns* API at revision *20160224*. The CLI is at version *0.3.6*. +This documentation was generated from the *dns* API at revision *20160825*. The CLI is at version *0.3.6*. ```bash dns1 [options] diff --git a/gen/dns1-cli/mkdocs.yml b/gen/dns1-cli/mkdocs.yml index 46b5f0ca08..5192002436 100644 --- a/gen/dns1-cli/mkdocs.yml +++ b/gen/dns1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: dns v0.3.6+20160224 +site_name: dns v0.3.6+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 1801f8ee35..cec07d9a69 100644 --- a/gen/dns1-cli/src/main.rs +++ b/gen/dns1-cli/src/main.rs @@ -1025,8 +1025,8 @@ fn main() { let mut app = App::new("dns1") .author("Sebastian Thiel ") - .version("0.3.6+20160224") - .about("The Google Cloud DNS API provides services for configuring and serving authoritative DNS records.") + .version("0.3.6+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") .long("scope") diff --git a/gen/dns1/Cargo.toml b/gen/dns1/Cargo.toml index 03b87a3d46..046bee8749 100644 --- a/gen/dns1/Cargo.toml +++ b/gen/dns1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-dns1" -version = "0.1.14+20160224" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/dns1/README.md b/gen/dns1/README.md index 56080a741e..a7b172fefd 100644 --- a/gen/dns1/README.md +++ b/gen/dns1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-dns1` library allows access to all features of the *Google dns* service. -This documentation was generated from *dns* crate version *0.1.14+20160224*, where *20160224* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *dns* crate version *0.1.14+20160825*, where *20160825* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *dns* *v1* API can be found at the [official documentation site](https://developers.google.com/cloud-dns). diff --git a/gen/dns1/src/lib.rs b/gen/dns1/src/lib.rs index c6708462af..52beb6f182 100644 --- a/gen/dns1/src/lib.rs +++ b/gen/dns1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *dns* crate version *0.1.14+20160224*, where *20160224* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *dns* crate version *0.1.14+20160825*, where *20160825* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *dns* *v1* API can be found at the //! [official documentation site](https://developers.google.com/cloud-dns). diff --git a/gen/dns1/src/lib.rs.in b/gen/dns1/src/lib.rs.in index 060cad0996..144e3ee8b6 100644 --- a/gen/dns1/src/lib.rs.in +++ b/gen/dns1/src/lib.rs.in @@ -206,7 +206,7 @@ pub struct ManagedZone { /// Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users will leave this field unset. #[serde(rename="nameServerSet")] pub name_server_set: Option, - /// User assigned name for this resource. Must be unique within the project. The name must be 1-32 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes. + /// User assigned name for this resource. Must be unique within the project. The name must be 1-63 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes. pub name: Option, } diff --git a/gen/doubleclickbidmanager1-cli/Cargo.toml b/gen/doubleclickbidmanager1-cli/Cargo.toml index 3b24042cbe..7463718960 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+20160225" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "doubleclickbidmanager1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-doubleclickbidmanager1/ni with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-doubleclickbidmanager1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-doubleclickbidmanager1] diff --git a/gen/doubleclickbidmanager1-cli/README.md b/gen/doubleclickbidmanager1-cli/README.md index b151d9d9e9..07b2c0db3c 100644 --- a/gen/doubleclickbidmanager1-cli/README.md +++ b/gen/doubleclickbidmanager1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *DoubleClick Bid Manager* API at revision *20160225*. 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 *0.3.6*. ```bash doubleclickbidmanager1 [options] diff --git a/gen/doubleclickbidmanager1-cli/mkdocs.yml b/gen/doubleclickbidmanager1-cli/mkdocs.yml index bb9548623e..5fbe34e6e0 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+20160225 +site_name: DoubleClick Bid Manager v0.3.6+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 753368cd84..8f05fedb4c 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+20160225") + .version("0.3.6+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/doubleclickbidmanager1/Cargo.toml b/gen/doubleclickbidmanager1/Cargo.toml index c1b7377d00..a2961e810d 100644 --- a/gen/doubleclickbidmanager1/Cargo.toml +++ b/gen/doubleclickbidmanager1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclickbidmanager1" -version = "0.1.14+20160225" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/doubleclickbidmanager1/README.md b/gen/doubleclickbidmanager1/README.md index c94d4b2721..e57664397c 100644 --- a/gen/doubleclickbidmanager1/README.md +++ b/gen/doubleclickbidmanager1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-doubleclickbidmanager1` library allows access to all features of the *Google DoubleClick Bid Manager* service. -This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.14+20160225*, where *20160225* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.14+20160608*, where *20160608* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *DoubleClick Bid Manager* *v1* API can be found at the [official documentation site](https://developers.google.com/bid-manager/). diff --git a/gen/doubleclickbidmanager1/src/lib.rs b/gen/doubleclickbidmanager1/src/lib.rs index da0a0fac14..922429f95b 100644 --- a/gen/doubleclickbidmanager1/src/lib.rs +++ b/gen/doubleclickbidmanager1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.14+20160225*, where *20160225* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *DoubleClick Bid Manager* crate version *0.1.14+20160608*, where *20160608* is the exact revision of the *doubleclickbidmanager:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *DoubleClick Bid Manager* *v1* API can be found at the //! [official documentation site](https://developers.google.com/bid-manager/). diff --git a/gen/doubleclicksearch2-cli/Cargo.toml b/gen/doubleclicksearch2-cli/Cargo.toml index 795dfac4a0..4acafb4e39 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+20160401" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "doubleclicksearch2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-doubleclicksearch2/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-doubleclicksearch2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-doubleclicksearch2] diff --git a/gen/doubleclicksearch2-cli/README.md b/gen/doubleclicksearch2-cli/README.md index 6f7316e881..6d9e9ccedc 100644 --- a/gen/doubleclicksearch2-cli/README.md +++ b/gen/doubleclicksearch2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *doubleclicksearch* API at revision *20160401*. The CLI is at version *0.3.6*. +This documentation was generated from the *doubleclicksearch* API at revision *20160831*. The CLI is at version *0.3.6*. ```bash doubleclicksearch2 [options] diff --git a/gen/doubleclicksearch2-cli/mkdocs.yml b/gen/doubleclicksearch2-cli/mkdocs.yml index 96329c1af0..99fbb37c0d 100644 --- a/gen/doubleclicksearch2-cli/mkdocs.yml +++ b/gen/doubleclicksearch2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: doubleclicksearch v0.3.6+20160401 +site_name: doubleclicksearch v0.3.6+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 9ffc421543..c4f411eef6 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+20160401") + .version("0.3.6+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/doubleclicksearch2/Cargo.toml b/gen/doubleclicksearch2/Cargo.toml index 0c75e17aac..718316d842 100644 --- a/gen/doubleclicksearch2/Cargo.toml +++ b/gen/doubleclicksearch2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-doubleclicksearch2" -version = "0.1.14+20160401" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/doubleclicksearch2/README.md b/gen/doubleclicksearch2/README.md index 37c0f04053..e3df300b79 100644 --- a/gen/doubleclicksearch2/README.md +++ b/gen/doubleclicksearch2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-doubleclicksearch2` library allows access to all features of the *Google doubleclicksearch* service. -This documentation was generated from *doubleclicksearch* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *doubleclicksearch* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *doubleclicksearch* *v2* API can be found at the [official documentation site](https://developers.google.com/doubleclick-search/). diff --git a/gen/doubleclicksearch2/src/lib.rs b/gen/doubleclicksearch2/src/lib.rs index c77d03f857..0cd0b59f16 100644 --- a/gen/doubleclicksearch2/src/lib.rs +++ b/gen/doubleclicksearch2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *doubleclicksearch* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *doubleclicksearch* crate version *0.1.14+20160831*, where *20160831* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *doubleclicksearch* *v2* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-search/). diff --git a/gen/drive2-cli/Cargo.toml b/gen/drive2-cli/Cargo.toml index c364beb81a..dd17c0841a 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+20160331" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "drive2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-drive2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-drive2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-drive2] diff --git a/gen/drive2-cli/README.md b/gen/drive2-cli/README.md index bd9ef2f9b4..ceb2a0929e 100644 --- a/gen/drive2-cli/README.md +++ b/gen/drive2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *drive* API at revision *20160331*. The CLI is at version *0.3.6*. +This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *0.3.6*. ```bash drive2 [options] diff --git a/gen/drive2-cli/mkdocs.yml b/gen/drive2-cli/mkdocs.yml index 6f36efd2cd..f2ebfc1e89 100644 --- a/gen/drive2-cli/mkdocs.yml +++ b/gen/drive2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: drive v0.3.6+20160331 +site_name: drive v0.3.6+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 89a6df31da..849369fe66 100644 --- a/gen/drive2-cli/src/main.rs +++ b/gen/drive2-cli/src/main.rs @@ -1386,11 +1386,12 @@ impl<'n> Engine<'n> { "user-permission.auth-key" => Some(("userPermission.authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.etag" => Some(("userPermission.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.email-address" => Some(("userPermission.emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.expiration-date" => Some(("userPermission.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.role" => Some(("userPermission.role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.type" => Some(("userPermission.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.additional-roles" => Some(("userPermission.additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "user-permission.self-link" => Some(("userPermission.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "spaces" => Some(("spaces", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "shareable" => Some(("shareable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "original-filename" => Some(("originalFilename", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1399,7 +1400,7 @@ impl<'n> Engine<'n> { "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "modified-date" => Some(("modifiedDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "expiration-date", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1876,11 +1877,12 @@ impl<'n> Engine<'n> { "user-permission.auth-key" => Some(("userPermission.authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.etag" => Some(("userPermission.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.email-address" => Some(("userPermission.emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.expiration-date" => Some(("userPermission.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.role" => Some(("userPermission.role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.type" => Some(("userPermission.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.additional-roles" => Some(("userPermission.additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "user-permission.self-link" => Some(("userPermission.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "spaces" => Some(("spaces", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "shareable" => Some(("shareable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "original-filename" => Some(("originalFilename", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1889,7 +1891,7 @@ impl<'n> Engine<'n> { "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "modified-date" => Some(("modifiedDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "expiration-date", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2169,11 +2171,12 @@ impl<'n> Engine<'n> { "user-permission.auth-key" => Some(("userPermission.authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.etag" => Some(("userPermission.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.email-address" => Some(("userPermission.emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.expiration-date" => Some(("userPermission.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.role" => Some(("userPermission.role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.type" => Some(("userPermission.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.additional-roles" => Some(("userPermission.additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "user-permission.self-link" => Some(("userPermission.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "spaces" => Some(("spaces", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "shareable" => Some(("shareable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "original-filename" => Some(("originalFilename", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2182,7 +2185,7 @@ impl<'n> Engine<'n> { "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "modified-date" => Some(("modifiedDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "expiration-date", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2555,11 +2558,12 @@ impl<'n> Engine<'n> { "user-permission.auth-key" => Some(("userPermission.authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.etag" => Some(("userPermission.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.email-address" => Some(("userPermission.emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.expiration-date" => Some(("userPermission.expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.role" => Some(("userPermission.role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.type" => Some(("userPermission.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "user-permission.additional-roles" => Some(("userPermission.additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "user-permission.self-link" => Some(("userPermission.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "user-permission.photo-link" => Some(("userPermission.photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "spaces" => Some(("spaces", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "shareable" => Some(("shareable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "original-filename" => Some(("originalFilename", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2568,7 +2572,7 @@ impl<'n> Engine<'n> { "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "modified-date" => Some(("modifiedDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "alternate-link", "altitude", "aperture", "app-data-contents", "auth-key", "camera-make", "camera-model", "can-comment", "can-read-revisions", "color-space", "copyable", "created-date", "date", "default-open-with-link", "description", "display-name", "domain", "download-url", "duration-millis", "editable", "email-address", "embed-link", "etag", "expiration-date", "explicitly-trashed", "export-links", "exposure-bias", "exposure-mode", "exposure-time", "file-extension", "file-size", "flash-used", "focal-length", "folder-color-rgb", "full-file-extension", "head-revision-id", "height", "hidden", "icon-link", "id", "image", "image-media-metadata", "indexable-text", "is-app-authorized", "is-authenticated-user", "iso-speed", "kind", "labels", "last-modifying-user", "last-modifying-user-name", "last-viewed-by-me-date", "latitude", "lens", "location", "longitude", "marked-viewed-by-me-date", "max-aperture-value", "md5-checksum", "metering-mode", "mime-type", "modified-by-me-date", "modified-date", "name", "open-with-links", "original-filename", "owned-by-me", "owner-names", "permission-id", "photo-link", "picture", "quota-bytes-used", "restricted", "role", "rotation", "self-link", "sensor", "shareable", "shared", "shared-with-me-date", "sharing-user", "spaces", "starred", "subject-distance", "text", "thumbnail", "thumbnail-link", "title", "trashed", "type", "url", "user-permission", "value", "version", "video-media-metadata", "viewed", "web-content-link", "web-view-link", "white-balance", "width", "with-link", "writers-can-share"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3205,13 +3209,14 @@ impl<'n> Engine<'n> { "auth-key" => Some(("authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expiration-date" => Some(("expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "additional-roles" => Some(("additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "expiration-date", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3362,13 +3367,14 @@ impl<'n> Engine<'n> { "auth-key" => Some(("authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expiration-date" => Some(("expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "additional-roles" => Some(("additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "expiration-date", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3385,6 +3391,9 @@ impl<'n> Engine<'n> { "transfer-ownership" => { call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); }, + "remove-expiration" => { + call = call.remove_expiration(arg_from_str(value.unwrap_or("false"), err, "remove-expiration", "boolean")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3398,7 +3407,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["transfer-ownership"].iter().map(|v|*v)); + v.extend(["transfer-ownership", "remove-expiration"].iter().map(|v|*v)); v } )); } } @@ -3464,13 +3473,14 @@ impl<'n> Engine<'n> { "auth-key" => Some(("authKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expiration-date" => Some(("expirationDate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "additional-roles" => Some(("additionalRoles", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-roles", "auth-key", "domain", "email-address", "etag", "expiration-date", "id", "kind", "name", "photo-link", "role", "self-link", "type", "value", "with-link"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3487,6 +3497,9 @@ impl<'n> Engine<'n> { "transfer-ownership" => { call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); }, + "remove-expiration" => { + call = call.remove_expiration(arg_from_str(value.unwrap_or("false"), err, "remove-expiration", "boolean")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3500,7 +3513,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["transfer-ownership"].iter().map(|v|*v)); + v.extend(["transfer-ownership", "remove-expiration"].iter().map(|v|*v)); v } )); } } @@ -6881,8 +6894,8 @@ fn main() { let mut app = App::new("drive2") .author("Sebastian Thiel ") - .version("0.3.6+20160331") - .about("The API to interact with Drive.") + .version("0.3.6+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") .long("scope") diff --git a/gen/drive2/Cargo.toml b/gen/drive2/Cargo.toml index 6e0b761d69..3baf173b51 100644 --- a/gen/drive2/Cargo.toml +++ b/gen/drive2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive2" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/drive2/README.md b/gen/drive2/README.md index 2c90912fa3..5ac1678147 100644 --- a/gen/drive2/README.md +++ b/gen/drive2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-drive2` library allows access to all features of the *Google drive* service. -This documentation was generated from *drive* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *drive* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *drive* *v2* API can be found at the [official documentation site](https://developers.google.com/drive/). diff --git a/gen/drive2/src/lib.rs b/gen/drive2/src/lib.rs index d7e9202c51..2b879364e8 100644 --- a/gen/drive2/src/lib.rs +++ b/gen/drive2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *drive* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *drive* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *drive:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *drive* *v2* API can be found at the //! [official documentation site](https://developers.google.com/drive/). @@ -160,17 +160,17 @@ //! let result = hub.files().patch(req, "fileId") //! .use_content_as_indexable_text(false) //! .update_viewed_date(true) -//! .timed_text_track_name("dolor") -//! .timed_text_language("sanctus") -//! .set_modified_date(true) -//! .remove_parents("Lorem") +//! .timed_text_track_name("dolore") +//! .timed_text_language("Lorem") +//! .set_modified_date(false) +//! .remove_parents("consetetur") //! .pinned(false) -//! .ocr_language("consetetur") +//! .ocr_language("labore") //! .ocr(false) -//! .new_revision(true) -//! .modified_date_behavior("gubergren") +//! .new_revision(false) +//! .modified_date_behavior("sadipscing") //! .convert(false) -//! .add_parents("sadipscing") +//! .add_parents("magna") //! .doit(); //! //! match result { diff --git a/gen/drive2/src/lib.rs.in b/gen/drive2/src/lib.rs.in index b1025b9172..1ebac539fa 100644 --- a/gen/drive2/src/lib.rs.in +++ b/gen/drive2/src/lib.rs.in @@ -381,7 +381,7 @@ pub struct About { /// The total number of quota bytes. #[serde(rename="quotaBytesTotal")] pub quota_bytes_total: Option, - /// The number of remaining change ids. + /// The number of remaining change ids, limited to no more than 2500. #[serde(rename="remainingChangeIds")] pub remaining_change_ids: Option, /// The ETag of the item. @@ -1117,7 +1117,7 @@ pub struct Permission { pub name: Option, /// This is always drive#permission. pub kind: Option, - /// The email address or domain name for the entity. This is used during inserts and is not populated in responses. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified. + /// The email address or domain name for the entity. This is used during inserts and is not populated in responses. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type anyone, in which case both id and value are ignored. pub value: Option, /// Additional roles for this user. Only commenter is currently allowed. #[serde(rename="additionalRoles")] @@ -1130,9 +1130,9 @@ pub struct Permission { /// The email address of the user or group this permission refers to. This is an output-only field which is present when the permission type is user or group. #[serde(rename="emailAddress")] pub email_address: Option, - /// A link to the profile photo, if available. - #[serde(rename="photoLink")] - pub photo_link: Option, + /// The time at which this permission will expire (RFC 3339 date-time). + #[serde(rename="expirationDate")] + pub expiration_date: Option, /// The primary role for this user. Allowed values are: /// - owner /// - reader @@ -1145,11 +1145,14 @@ pub struct Permission { /// - anyone #[serde(rename="type")] pub type_: Option, - /// The ID of the user this permission refers to, and identical to the permissionId in the About and Files resources. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified. + /// The ID of the user this permission refers to, and identical to the permissionId in the About and Files resources. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type anyone, in which case both id and value are ignored. pub id: Option, /// A link back to this permission. #[serde(rename="selfLink")] pub self_link: Option, + /// A link to the profile photo, if available. + #[serde(rename="photoLink")] + pub photo_link: Option, } impl RequestValue for Permission {} @@ -2964,6 +2967,7 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _transfer_ownership: Default::default(), + _remove_expiration: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3003,6 +3007,7 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _transfer_ownership: Default::default(), + _remove_expiration: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -15066,6 +15071,7 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut, /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().patch(req, "fileId", "permissionId") /// .transfer_ownership(false) +/// .remove_expiration(true) /// .doit(); /// # } /// ``` @@ -15077,6 +15083,7 @@ pub struct PermissionPatchCall<'a, C, A> _file_id: String, _permission_id: String, _transfer_ownership: Option, + _remove_expiration: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -15098,13 +15105,16 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "drive.permissions.patch", http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("fileId", self._file_id.to_string())); params.push(("permissionId", self._permission_id.to_string())); if let Some(value) = self._transfer_ownership { params.push(("transferOwnership", value.to_string())); } - for &field in ["alt", "fileId", "permissionId", "transferOwnership"].iter() { + if let Some(value) = self._remove_expiration { + params.push(("removeExpiration", value.to_string())); + } + for &field in ["alt", "fileId", "permissionId", "transferOwnership", "removeExpiration"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15270,6 +15280,13 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut, self._transfer_ownership = Some(new_value); self } + /// Whether to remove the expiration date. + /// + /// Sets the *remove expiration* query property to the given value. + pub fn remove_expiration(mut self, new_value: bool) -> PermissionPatchCall<'a, C, A> { + self._remove_expiration = 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. /// @@ -15591,6 +15608,7 @@ impl<'a, C, A> PermissionListCall<'a, C, A> where C: BorrowMut, A /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().update(req, "fileId", "permissionId") /// .transfer_ownership(true) +/// .remove_expiration(true) /// .doit(); /// # } /// ``` @@ -15602,6 +15620,7 @@ pub struct PermissionUpdateCall<'a, C, A> _file_id: String, _permission_id: String, _transfer_ownership: Option, + _remove_expiration: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -15623,13 +15642,16 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "drive.permissions.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("fileId", self._file_id.to_string())); params.push(("permissionId", self._permission_id.to_string())); if let Some(value) = self._transfer_ownership { params.push(("transferOwnership", value.to_string())); } - for &field in ["alt", "fileId", "permissionId", "transferOwnership"].iter() { + if let Some(value) = self._remove_expiration { + params.push(("removeExpiration", value.to_string())); + } + for &field in ["alt", "fileId", "permissionId", "transferOwnership", "removeExpiration"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15795,6 +15817,13 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut, self._transfer_ownership = Some(new_value); self } + /// Whether to remove the expiration date. + /// + /// Sets the *remove expiration* query property to the given value. + pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, C, A> { + self._remove_expiration = 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. /// @@ -16362,11 +16391,11 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut ChangeWatchCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().list() -/// .start_change_id("ipsum") -/// .spaces("justo") -/// .page_token("dolore") -/// .max_results(-26) -/// .include_subscribed(false) +/// .start_change_id("dolore") +/// .spaces("vero") +/// .page_token("dolor") +/// .max_results(-58) +/// .include_subscribed(true) /// .include_deleted(false) /// .doit(); /// # } @@ -17176,7 +17205,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().patch(req, "fileId", "propertyKey") -/// .visibility("sed") +/// .visibility("invidunt") /// .doit(); /// # } /// ``` @@ -17460,7 +17489,7 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().delete("fileId", "propertyKey") -/// .visibility("rebum.") +/// .visibility("aliquyam") /// .doit(); /// # } /// ``` @@ -18215,7 +18244,7 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().update(req, "fileId", "propertyKey") -/// .visibility("sea") +/// .visibility("At") /// .doit(); /// # } /// ``` @@ -18499,7 +18528,7 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().get("fileId", "propertyKey") -/// .visibility("sea") +/// .visibility("diam") /// .doit(); /// # } /// ``` diff --git a/gen/drive3-cli/Cargo.toml b/gen/drive3-cli/Cargo.toml index 60a4aa2f74..90d62f905b 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+20160331" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "drive3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-drive3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-drive3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-drive3] diff --git a/gen/drive3-cli/README.md b/gen/drive3-cli/README.md index f986d68523..46ad7f3a34 100644 --- a/gen/drive3-cli/README.md +++ b/gen/drive3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *drive* API at revision *20160331*. The CLI is at version *0.3.6*. +This documentation was generated from the *drive* API at revision *20160901*. The CLI is at version *0.3.6*. ```bash drive3 [options] diff --git a/gen/drive3-cli/mkdocs.yml b/gen/drive3-cli/mkdocs.yml index 9e41f0119e..d3e7d17602 100644 --- a/gen/drive3-cli/mkdocs.yml +++ b/gen/drive3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: drive v0.3.6+20160331 +site_name: drive v0.3.6+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 eed5d023d3..43ca4bca8b 100644 --- a/gen/drive3-cli/src/main.rs +++ b/gen/drive3-cli/src/main.rs @@ -1796,10 +1796,11 @@ impl<'n> Engine<'n> { "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expiration-time" => Some(("expirationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-file-discovery", "display-name", "domain", "email-address", "id", "kind", "photo-link", "role", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-file-discovery", "display-name", "domain", "email-address", "expiration-time", "id", "kind", "photo-link", "role", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2047,10 +2048,11 @@ impl<'n> Engine<'n> { "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "photo-link" => Some(("photoLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expiration-time" => Some(("expirationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-file-discovery", "display-name", "domain", "email-address", "id", "kind", "photo-link", "role", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-file-discovery", "display-name", "domain", "email-address", "expiration-time", "id", "kind", "photo-link", "role", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2067,6 +2069,9 @@ impl<'n> Engine<'n> { "transfer-ownership" => { call = call.transfer_ownership(arg_from_str(value.unwrap_or("false"), err, "transfer-ownership", "boolean")); }, + "remove-expiration" => { + call = call.remove_expiration(arg_from_str(value.unwrap_or("false"), err, "remove-expiration", "boolean")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2080,7 +2085,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["transfer-ownership"].iter().map(|v|*v)); + v.extend(["transfer-ownership", "remove-expiration"].iter().map(|v|*v)); v } )); } } @@ -3878,8 +3883,8 @@ fn main() { let mut app = App::new("drive3") .author("Sebastian Thiel ") - .version("0.3.6+20160331") - .about("The API to interact with Drive.") + .version("0.3.6+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") .long("scope") diff --git a/gen/drive3/Cargo.toml b/gen/drive3/Cargo.toml index ee6f49b5a8..f2eb11c83a 100644 --- a/gen/drive3/Cargo.toml +++ b/gen/drive3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-drive3" -version = "0.1.14+20160331" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/drive3/README.md b/gen/drive3/README.md index 92fb027658..c73fe32852 100644 --- a/gen/drive3/README.md +++ b/gen/drive3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-drive3` library allows access to all features of the *Google drive* service. -This documentation was generated from *drive* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *drive:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *drive* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *drive:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *drive* *v3* API can be found at the [official documentation site](https://developers.google.com/drive/). diff --git a/gen/drive3/src/lib.rs b/gen/drive3/src/lib.rs index 5281ef3dc2..4681cd40f4 100644 --- a/gen/drive3/src/lib.rs +++ b/gen/drive3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *drive* crate version *0.1.14+20160331*, where *20160331* is the exact revision of the *drive:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *drive* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *drive:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *drive* *v3* API can be found at the //! [official documentation site](https://developers.google.com/drive/). @@ -145,10 +145,10 @@ //! // Values shown here are possibly random and not representative ! //! let result = hub.files().update(req, "fileId") //! .use_content_as_indexable_text(false) -//! .remove_parents("sit") -//! .ocr_language("eirmod") -//! .keep_revision_forever(true) -//! .add_parents("labore") +//! .remove_parents("eirmod") +//! .ocr_language("consetetur") +//! .keep_revision_forever(false) +//! .add_parents("sed") //! .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); //! //! match result { diff --git a/gen/drive3/src/lib.rs.in b/gen/drive3/src/lib.rs.in index 199b294da4..e26879da50 100644 --- a/gen/drive3/src/lib.rs.in +++ b/gen/drive3/src/lib.rs.in @@ -228,7 +228,7 @@ impl<'a, C, A> Drive pub struct Comment { /// Whether the comment has been resolved by one of its replies. pub resolved: Option, - /// This is always drive#comment. + /// Identifies what kind of resource this is. Value: the fixed string "drive#comment". pub kind: Option, /// The last time the comment or any of its replies was modified (RFC 3339 date-time). #[serde(rename="modifiedTime")] @@ -272,7 +272,7 @@ impl ResponseResult for Comment {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct About { - /// This is always drive#about. + /// Identifies what kind of resource this is. Value: the fixed string "drive#about". pub kind: Option, /// A map of source MIME type to possible targets for all supported exports. #[serde(rename="exportFormats")] @@ -333,7 +333,7 @@ pub struct ChangeList { /// The page token for the next page of changes. This will be absent if the end of the current changes list has been reached. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// This is always drive#changeList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#changeList". pub kind: Option, /// The page of changes. pub changes: Option>, @@ -359,7 +359,7 @@ pub struct ReplyList { /// The page token for the next page of replies. This will be absent if the end of the replies list has been reached. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// This is always drive#replyList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#replyList". pub kind: Option, /// The page of replies. pub replies: Option>, @@ -463,7 +463,7 @@ impl Part for FileImageMediaMetadata {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RevisionList { - /// This is always drive#revisionList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#revisionList". pub kind: Option, /// The full list of revisions. pub revisions: Option>, @@ -485,7 +485,7 @@ impl ResponseResult for RevisionList {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Reply { - /// This is always drive#reply. + /// Identifies what kind of resource this is. Value: the fixed string "drive#reply". pub kind: Option, /// The last time the reply was modified (RFC 3339 date-time). #[serde(rename="modifiedTime")] @@ -525,7 +525,7 @@ impl ResponseResult for Reply {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeneratedIds { - /// This is always drive#generatedIds + /// Identifies what kind of resource this is. Value: the fixed string "drive#generatedIds". pub kind: Option, /// The IDs generated for the requesting user in the specified space. pub ids: Option>, @@ -613,7 +613,7 @@ pub struct Revision { /// The MIME type of the revision. #[serde(rename="mimeType")] pub mime_type: Option, - /// This is always drive#revision. + /// Identifies what kind of resource this is. Value: the fixed string "drive#revision". pub kind: Option, /// The last time the revision was modified (RFC 3339 date-time). #[serde(rename="modifiedTime")] @@ -664,7 +664,7 @@ pub struct CommentList { /// The page token for the next page of comments. This will be absent if the end of the comments list has been reached. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// This is always drive#commentList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#commentList". pub kind: Option, /// The page of comments. pub comments: Option>, @@ -714,7 +714,7 @@ pub struct Permission { /// Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type domain or anyone. #[serde(rename="allowFileDiscovery")] pub allow_file_discovery: Option, - /// This is always drive#permission. + /// Identifies what kind of resource this is. Value: the fixed string "drive#permission". pub kind: Option, /// The email address of the user or group to which this permission refers. #[serde(rename="emailAddress")] @@ -728,6 +728,9 @@ pub struct Permission { /// - commenter /// - reader pub role: Option, + /// The time at which this permission will expire (RFC 3339 date-time). + #[serde(rename="expirationTime")] + pub expiration_time: Option, /// The type of the grantee. Valid values are: /// - user /// - group @@ -809,7 +812,7 @@ pub struct FileList { /// The page token for the next page of files. This will be absent if the end of the files list has been reached. #[serde(rename="nextPageToken")] pub next_page_token: Option, - /// This is always drive#fileList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#fileList". pub kind: Option, } @@ -824,7 +827,7 @@ impl ResponseResult for FileList {} pub struct User { /// Whether this user is the requesting user. pub me: Option, - /// This is always drive#user. + /// Identifies what kind of resource this is. Value: the fixed string "drive#user". pub kind: Option, /// A plain text displayable name for this user. #[serde(rename="displayName")] @@ -947,7 +950,7 @@ pub struct File { /// Whether the file has been viewed by this user. #[serde(rename="viewedByMe")] pub viewed_by_me: Option, - /// This is always drive#file. + /// Identifies what kind of resource this is. Value: the fixed string "drive#file". pub kind: Option, /// The time at which the file was created (RFC 3339 date-time). #[serde(rename="createdTime")] @@ -1006,7 +1009,7 @@ impl ResponseResult for File {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionList { - /// This is always drive#permissionList. + /// Identifies what kind of resource this is. Value: the fixed string "drive#permissionList". pub kind: Option, /// The full list of permissions. pub permissions: Option>, @@ -1045,7 +1048,7 @@ impl Part for FileVideoMediaMetadata {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StartPageToken { - /// This is always drive#startPageToken. + /// Identifies what kind of resource this is. Value: the fixed string "drive#startPageToken". pub kind: Option, /// The starting page token for listing changes. #[serde(rename="startPageToken")] @@ -1068,7 +1071,7 @@ impl ResponseResult for StartPageToken {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Change { - /// This is always drive#change. + /// Identifies what kind of resource this is. Value: the fixed string "drive#change". pub kind: Option, /// Whether the file has been removed from the view of the changes list, for example by deletion or lost access. pub removed: Option, @@ -2022,6 +2025,7 @@ impl<'a, C, A> PermissionMethods<'a, C, A> { _file_id: file_id.to_string(), _permission_id: permission_id.to_string(), _transfer_ownership: Default::default(), + _remove_expiration: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -10343,6 +10347,7 @@ impl<'a, C, A> PermissionListCall<'a, C, A> where C: BorrowMut, A /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().update(req, "fileId", "permissionId") /// .transfer_ownership(false) +/// .remove_expiration(true) /// .doit(); /// # } /// ``` @@ -10354,6 +10359,7 @@ pub struct PermissionUpdateCall<'a, C, A> _file_id: String, _permission_id: String, _transfer_ownership: Option, + _remove_expiration: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -10375,13 +10381,16 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "drive.permissions.update", http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("fileId", self._file_id.to_string())); params.push(("permissionId", self._permission_id.to_string())); if let Some(value) = self._transfer_ownership { params.push(("transferOwnership", value.to_string())); } - for &field in ["alt", "fileId", "permissionId", "transferOwnership"].iter() { + if let Some(value) = self._remove_expiration { + params.push(("removeExpiration", value.to_string())); + } + for &field in ["alt", "fileId", "permissionId", "transferOwnership", "removeExpiration"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -10547,6 +10556,13 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut, self._transfer_ownership = Some(new_value); self } + /// Whether to remove the expiration date. + /// + /// Sets the *remove expiration* query property to the given value. + pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, C, A> { + self._remove_expiration = 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. /// @@ -10879,9 +10895,9 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.permissions().create(req, "fileId") -/// .transfer_ownership(false) +/// .transfer_ownership(true) /// .send_notification_email(true) -/// .email_message("nonumy") +/// .email_message("sed") /// .doit(); /// # } /// ``` diff --git a/gen/fitness1-cli/Cargo.toml b/gen/fitness1-cli/Cargo.toml index 9021f16d5a..5f1245d540 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+20151021" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "fitness1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-fitness1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-fitness1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-fitness1] diff --git a/gen/fitness1-cli/README.md b/gen/fitness1-cli/README.md index 02d19746b4..139060c144 100644 --- a/gen/fitness1-cli/README.md +++ b/gen/fitness1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *fitness* API at revision *20151021*. The CLI is at version *0.3.6*. +This documentation was generated from the *fitness* API at revision *20160801*. The CLI is at version *0.3.6*. ```bash fitness1 [options] diff --git a/gen/fitness1-cli/mkdocs.yml b/gen/fitness1-cli/mkdocs.yml index 21c4a06e7b..ed4d603ed9 100644 --- a/gen/fitness1-cli/mkdocs.yml +++ b/gen/fitness1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fitness v0.3.6+20151021 +site_name: fitness v0.3.6+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 fe430c797a..87739193bb 100644 --- a/gen/fitness1-cli/src/main.rs +++ b/gen/fitness1-cli/src/main.rs @@ -71,6 +71,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-stream-name" => Some(("dataStreamName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-type.name" => Some(("dataType.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "data-quality-standard" => Some(("dataQualityStandard", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "application.package-name" => Some(("application.packageName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.version" => Some(("application.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.name" => Some(("application.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -83,7 +84,7 @@ impl<'n> Engine<'n> { "data-stream-id" => Some(("dataStreamId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-quality-standard", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -531,6 +532,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-stream-name" => Some(("dataStreamName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-type.name" => Some(("dataType.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "data-quality-standard" => Some(("dataQualityStandard", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "application.package-name" => Some(("application.packageName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.version" => Some(("application.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.name" => Some(("application.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -543,7 +545,7 @@ impl<'n> Engine<'n> { "data-stream-id" => Some(("dataStreamId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-quality-standard", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -629,6 +631,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-stream-name" => Some(("dataStreamName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "data-type.name" => Some(("dataType.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "data-quality-standard" => Some(("dataQualityStandard", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "application.package-name" => Some(("application.packageName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.version" => Some(("application.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "application.name" => Some(("application.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -641,7 +644,7 @@ impl<'n> Engine<'n> { "data-stream-id" => Some(("dataStreamId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["application", "data-quality-standard", "data-stream-id", "data-stream-name", "data-type", "details-url", "device", "manufacturer", "model", "name", "package-name", "type", "uid", "version"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -731,9 +734,13 @@ impl<'n> Engine<'n> { "bucket-by-activity-type.activity-data-source-id" => Some(("bucketByActivityType.activityDataSourceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "bucket-by-activity-type.min-duration-millis" => Some(("bucketByActivityType.minDurationMillis", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "start-time-millis" => Some(("startTimeMillis", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "filtered-data-quality-standard" => Some(("filteredDataQualityStandard", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "bucket-by-time.duration-millis" => Some(("bucketByTime.durationMillis", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "bucket-by-time.period.time-zone-id" => Some(("bucketByTime.period.timeZoneId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "bucket-by-time.period.type" => Some(("bucketByTime.period.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "bucket-by-time.period.value" => Some(("bucketByTime.period.value", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["activity-data-source-id", "bucket-by-activity-segment", "bucket-by-activity-type", "bucket-by-session", "bucket-by-time", "duration-millis", "end-time-millis", "min-duration-millis", "start-time-millis"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["activity-data-source-id", "bucket-by-activity-segment", "bucket-by-activity-type", "bucket-by-session", "bucket-by-time", "duration-millis", "end-time-millis", "filtered-data-quality-standard", "min-duration-millis", "period", "start-time-millis", "time-zone-id", "type", "value"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1272,7 +1279,7 @@ fn main() { Some(false)), ]), ("data-sources-delete", - Some(r##"Delete the data source if there are no datapoints associated with it"##), + Some(r##"Deletes the specified data source. The request will fail if the data source contains any data points."##), "Details at http://byron.github.io/google-apis-rs/google_fitness1_cli/users_data-sources-delete", vec![ (Some(r##"user-id"##), @@ -1300,7 +1307,7 @@ fn main() { Some(false)), ]), ("data-sources-get", - Some(r##"Returns a data source identified by a data stream ID."##), + Some(r##"Returns the specified data source."##), "Details at http://byron.github.io/google-apis-rs/google_fitness1_cli/users_data-sources-get", vec![ (Some(r##"user-id"##), @@ -1328,7 +1335,7 @@ fn main() { Some(false)), ]), ("data-sources-list", - Some(r##"Lists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive: the user may have private data sources that are only visible to other developers or calls using other scopes."##), + Some(r##"Lists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive; the user may have private data sources that are only visible to other developers, or calls using other scopes."##), "Details at http://byron.github.io/google-apis-rs/google_fitness1_cli/users_data-sources-list", vec![ (Some(r##"user-id"##), @@ -1350,9 +1357,9 @@ fn main() { Some(false)), ]), ("data-sources-patch", - Some(r##"Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. + Some(r##"Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. - Data sources are identified by their data stream ID. This method supports patch semantics."##), + Data sources are identified by their dataStreamId. This method supports patch semantics."##), "Details at http://byron.github.io/google-apis-rs/google_fitness1_cli/users_data-sources-patch", vec![ (Some(r##"user-id"##), @@ -1386,9 +1393,9 @@ fn main() { Some(false)), ]), ("data-sources-update", - Some(r##"Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. + Some(r##"Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. - Data sources are identified by their data stream ID."##), + Data sources are identified by their dataStreamId."##), "Details at http://byron.github.io/google-apis-rs/google_fitness1_cli/users_data-sources-update", vec![ (Some(r##"user-id"##), @@ -1533,8 +1540,8 @@ fn main() { let mut app = App::new("fitness1") .author("Sebastian Thiel ") - .version("0.3.6+20151021") - .about("Google Fit API") + .version("0.3.6+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") .long("scope") diff --git a/gen/fitness1/Cargo.toml b/gen/fitness1/Cargo.toml index 87e59385ed..56867d7b66 100644 --- a/gen/fitness1/Cargo.toml +++ b/gen/fitness1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fitness1" -version = "0.1.14+20151021" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/fitness1/README.md b/gen/fitness1/README.md index 3d95b2a5d3..66855d07a8 100644 --- a/gen/fitness1/README.md +++ b/gen/fitness1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-fitness1` library allows access to all features of the *Google fitness* service. -This documentation was generated from *fitness* crate version *0.1.14+20151021*, where *20151021* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *fitness* crate version *0.1.14+20160801*, where *20160801* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *fitness* *v1* API can be found at the [official documentation site](https://developers.google.com/fit/rest/). diff --git a/gen/fitness1/src/lib.rs b/gen/fitness1/src/lib.rs index fdee82a601..0056b65521 100644 --- a/gen/fitness1/src/lib.rs +++ b/gen/fitness1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *fitness* crate version *0.1.14+20151021*, where *20151021* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *fitness* crate version *0.1.14+20160801*, where *20160801* is the exact revision of the *fitness:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *fitness* *v1* API can be found at the //! [official documentation site](https://developers.google.com/fit/rest/). diff --git a/gen/fitness1/src/lib.rs.in b/gen/fitness1/src/lib.rs.in index b1c6e5b813..a7ff8c4f3e 100644 --- a/gen/fitness1/src/lib.rs.in +++ b/gen/fitness1/src/lib.rs.in @@ -48,11 +48,17 @@ pub enum Scope { /// View your stored location data in Google Fit LocationRead, - /// View your activity information in Google Fit - ActivityRead, + /// View and store nutrition information in Google Fit + NutritionWrite, /// View and store your activity information in Google Fit ActivityWrite, + + /// View nutrition information in Google Fit + NutritionRead, + + /// View your activity information in Google Fit + ActivityRead, } impl AsRef for Scope { @@ -62,8 +68,10 @@ impl AsRef for Scope { Scope::BodyWrite => "https://www.googleapis.com/auth/fitness.body.write", Scope::LocationWrite => "https://www.googleapis.com/auth/fitness.location.write", Scope::LocationRead => "https://www.googleapis.com/auth/fitness.location.read", - Scope::ActivityRead => "https://www.googleapis.com/auth/fitness.activity.read", + Scope::NutritionWrite => "https://www.googleapis.com/auth/fitness.nutrition.write", Scope::ActivityWrite => "https://www.googleapis.com/auth/fitness.activity.write", + Scope::NutritionRead => "https://www.googleapis.com/auth/fitness.nutrition.read", + Scope::ActivityRead => "https://www.googleapis.com/auth/fitness.activity.read", } } } @@ -252,7 +260,7 @@ pub struct ListDataSourcesResponse { impl ResponseResult for ListDataSourcesResponse {} -/// See: google3/java/com/google/android/apps/heart/platform/api/Application.java +/// /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -409,6 +417,9 @@ pub struct AggregateRequest { /// The start of a window of time. Data that intersects with this time window will be aggregated. The time is in milliseconds since epoch, inclusive. #[serde(rename="startTimeMillis")] pub start_time_millis: Option, + /// A list of acceptable data quality standards. Only data points which conform to at least one of the specified data quality standards will be returned. If the list is empty, all data points are returned. + #[serde(rename="filteredDataQualityStandard")] + pub filtered_data_quality_standard: Option>, /// Specifies that data be aggregated by a single time interval. Mutually exclusive of other bucketing specifications. #[serde(rename="bucketByTime")] pub bucket_by_time: Option, @@ -417,7 +428,7 @@ pub struct AggregateRequest { impl RequestValue for AggregateRequest {} -/// See: google3/java/com/google/android/apps/heart/platform/api/DataType.java +/// /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -552,6 +563,25 @@ pub struct MapValue { impl Part for MapValue {} +/// 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 BucketByTimePeriod { + /// org.joda.timezone.DateTimeZone + #[serde(rename="timeZoneId")] + pub time_zone_id: Option, + /// no description provided + #[serde(rename="type")] + pub type_: Option, + /// no description provided + pub value: Option, +} + +impl Part for BucketByTimePeriod {} + + /// Representation of an integrated device (such as a phone or a wearable) that can hold sensors. Each sensor is exposed as a data source. /// /// The main purpose of the device information contained in this class is to identify the hardware of a particular data source. This can be useful in different ways, including: @@ -608,6 +638,8 @@ pub struct BucketByTime { /// Specifies that result buckets aggregate data by exactly durationMillis time frames. Time frames that contain no data will be included in the response with an empty dataset. #[serde(rename="durationMillis")] pub duration_millis: Option, + /// no description provided + pub period: Option, } impl Part for BucketByTime {} @@ -632,18 +664,21 @@ impl Part for BucketByTime {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DataSource { + /// An end-user visible name for this data source. + pub name: Option, + /// + #[serde(rename="dataQualityStandard")] + pub data_quality_standard: Option>, + /// The data type defines the schema for a stream of data being collected by, inserted into, or queried from the Fitness API. + #[serde(rename="dataType")] + pub data_type: Option, + /// The stream name uniquely identifies this particular data source among other data sources of the same type from the same underlying producer. Setting the stream name is optional, but should be done whenever an application exposes two streams for the same data type, or when a device has two equivalent sensors. + #[serde(rename="dataStreamName")] + pub data_stream_name: Option, /// Information about an application which feeds sensor data into the platform. pub application: Option, /// Representation of an integrated device (such as a phone or a wearable) that can hold sensors. pub device: Option, - /// An end-user visible name for this data source. - pub name: Option, - /// The stream name uniquely identifies this particular data source among other data sources of the same type from the same underlying producer. Setting the stream name is optional, but should be done whenever an application exposes two streams for the same data type, or when a device has two equivalent sensors. - #[serde(rename="dataStreamName")] - pub data_stream_name: Option, - /// The data type defines the schema for a stream of data being collected by, inserted into, or queried from the Fitness API. - #[serde(rename="dataType")] - pub data_type: Option, /// A unique identifier for the data stream produced by this data source. The identifier includes: /// /// @@ -734,7 +769,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Delete the data source if there are no datapoints associated with it + /// Deletes the specified data source. The request will fail if the data source contains any data points. /// /// # Arguments /// @@ -862,7 +897,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns a data source identified by a data stream ID. + /// Returns the specified data source. /// /// # Arguments /// @@ -881,9 +916,9 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. + /// Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. /// - /// Data sources are identified by their data stream ID. + /// Data sources are identified by their dataStreamId. /// /// # Arguments /// @@ -947,9 +982,9 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. + /// Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. /// - /// Data sources are identified by their data stream ID. This method supports patch semantics. + /// Data sources are identified by their dataStreamId. This method supports patch semantics. /// /// # Arguments /// @@ -970,7 +1005,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive: the user may have private data sources that are only visible to other developers or calls using other scopes. + /// Lists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive; the user may have private data sources that are only visible to other developers, or calls using other scopes. /// /// # Arguments /// @@ -1261,7 +1296,7 @@ impl<'a, C, A> UserDatasetAggregateCall<'a, C, A> where C: BorrowMut UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut UserDataSourceDatasetGetCall<'a, C, A> { @@ -2879,7 +2914,7 @@ impl<'a, C, A> UserSessionDeleteCall<'a, C, A> where C: BorrowMut } -/// Returns a data source identified by a data stream ID. +/// Returns the specified data source. /// /// A builder for the *dataSources.get* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. @@ -3126,9 +3161,9 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut } -/// Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. +/// Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. /// -/// Data sources are identified by their data stream ID. +/// Data sources are identified by their dataStreamId. /// /// A builder for the *dataSources.update* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. @@ -3979,9 +4014,9 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut } -/// Updates a given data source. It is an error to modify the data source's data stream ID, data type, type, stream name or device information apart from the device version. Changing these fields would require a new unique data stream ID and separate data source. +/// Updates the specified data source. The dataStreamId, dataType, type, dataStreamName, and device properties with the exception of version, cannot be modified. /// -/// Data sources are identified by their data stream ID. This method supports patch semantics. +/// Data sources are identified by their dataStreamId. This method supports patch semantics. /// /// A builder for the *dataSources.patch* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. @@ -4259,7 +4294,7 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut"] description = "A complete library to interact with fusiontables (protocol v2)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/fusiontables2-cli" @@ -19,10 +19,10 @@ name = "fusiontables2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-fusiontables2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-fusiontables2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-fusiontables2] diff --git a/gen/fusiontables2-cli/README.md b/gen/fusiontables2-cli/README.md index 3433a83bc7..ae058517dd 100644 --- a/gen/fusiontables2-cli/README.md +++ b/gen/fusiontables2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *fusiontables* API at revision *20160317*. The CLI is at version *0.3.6*. +This documentation was generated from the *fusiontables* API at revision *20160526*. The CLI is at version *0.3.6*. ```bash fusiontables2 [options] diff --git a/gen/fusiontables2-cli/mkdocs.yml b/gen/fusiontables2-cli/mkdocs.yml index 49a1b51a29..c45070400c 100644 --- a/gen/fusiontables2-cli/mkdocs.yml +++ b/gen/fusiontables2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fusiontables v0.3.6+20160317 +site_name: fusiontables v0.3.6+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 644ec9dbca..11fa8875ac 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+20160317") + .version("0.3.6+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/fusiontables2/Cargo.toml b/gen/fusiontables2/Cargo.toml index b6d41d1d46..f703e94f60 100644 --- a/gen/fusiontables2/Cargo.toml +++ b/gen/fusiontables2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-fusiontables2" -version = "0.1.14+20160317" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/fusiontables2/README.md b/gen/fusiontables2/README.md index 24dce23dc3..6a6036cee3 100644 --- a/gen/fusiontables2/README.md +++ b/gen/fusiontables2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-fusiontables2` library allows access to all features of the *Google fusiontables* service. -This documentation was generated from *fusiontables* crate version *0.1.14+20160317*, where *20160317* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *fusiontables* crate version *0.1.14+20160526*, where *20160526* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *fusiontables* *v2* API can be found at the [official documentation site](https://developers.google.com/fusiontables). diff --git a/gen/fusiontables2/src/lib.rs b/gen/fusiontables2/src/lib.rs index e428328e33..186562db3c 100644 --- a/gen/fusiontables2/src/lib.rs +++ b/gen/fusiontables2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *fusiontables* crate version *0.1.14+20160317*, where *20160317* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *fusiontables* crate version *0.1.14+20160526*, where *20160526* is the exact revision of the *fusiontables:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *fusiontables* *v2* API can be found at the //! [official documentation site](https://developers.google.com/fusiontables). diff --git a/gen/fusiontables2/src/lib.rs.in b/gen/fusiontables2/src/lib.rs.in index d2e8efab7b..50cc78d73a 100644 --- a/gen/fusiontables2/src/lib.rs.in +++ b/gen/fusiontables2/src/lib.rs.in @@ -237,7 +237,7 @@ pub struct Column { #[serde(rename="columnPropertiesJson")] pub column_properties_json: Option, /// Format pattern. - /// Acceptable values are DT_DATE_MEDIUMe.g Dec 24, 2008 DT_DATE_SHORTfor example 12/24/08 DT_DATE_TIME_MEDIUMfor example Dec 24, 2008 8:30:45 PM DT_DATE_TIME_SHORTfor example 12/24/08 8:30 PM DT_DAY_MONTH_2_DIGIT_YEARfor example 24/12/08 DT_DAY_MONTH_2_DIGIT_YEAR_TIMEfor example 24/12/08 20:30 DT_DAY_MONTH_2_DIGIT_YEAR_TIME_MERIDIANfor example 24/12/08 8:30 PM DT_DAY_MONTH_4_DIGIT_YEARfor example 24/12/2008 DT_DAY_MONTH_4_DIGIT_YEAR_TIMEfor example 24/12/2008 20:30 DT_DAY_MONTH_4_DIGIT_YEAR_TIME_MERIDIANfor example 24/12/2008 8:30 PM DT_ISO_YEAR_MONTH_DAYfor example 2008-12-24 DT_ISO_YEAR_MONTH_DAY_TIMEfor example 2008-12-24 20:30:45 DT_MONTH_DAY_4_DIGIT_YEARfor example 12/24/2008 DT_TIME_LONGfor example 8:30:45 PM UTC-6 DT_TIME_MEDIUMfor example 8:30:45 PM DT_TIME_SHORTfor example 8:30 PM DT_YEAR_ONLYfor example 2008 HIGHLIGHT_UNTYPED_CELLSHighlight cell data that does not match the data type NONENo formatting (default) NUMBER_CURRENCYfor example $1234.56 NUMBER_DEFAULTfor example 1,234.56 NUMBER_INTEGERfor example 1235 NUMBER_NO_SEPARATORfor example 1234.56 NUMBER_PERCENTfor example 123,456% NUMBER_SCIENTIFICfor example 1E3 STRING_EIGHT_LINE_IMAGEDisplays thumbnail images as tall as eight lines of text STRING_FOUR_LINE_IMAGEDisplays thumbnail images as tall as four lines of text STRING_JSON_TEXTAllows JSON editing of text in UI STRING_LINKTreats cell as a link (must start with http:// or https://) STRING_ONE_LINE_IMAGEDisplays thumbnail images as tall as one line of text STRING_VIDEO_OR_MAPDisplay a video or map thumbnail + /// Acceptable values are DT_DATE_MEDIUMe.g Dec 24, 2008 DT_DATE_SHORTfor example 12/24/08 DT_DATE_TIME_MEDIUMfor example Dec 24, 2008 8:30:45 PM DT_DATE_TIME_SHORTfor example 12/24/08 8:30 PM DT_DAY_MONTH_2_DIGIT_YEARfor example 24/12/08 DT_DAY_MONTH_2_DIGIT_YEAR_TIMEfor example 24/12/08 20:30 DT_DAY_MONTH_2_DIGIT_YEAR_TIME_MERIDIANfor example 24/12/08 8:30 PM DT_DAY_MONTH_4_DIGIT_YEARfor example 24/12/2008 DT_DAY_MONTH_4_DIGIT_YEAR_TIMEfor example 24/12/2008 20:30 DT_DAY_MONTH_4_DIGIT_YEAR_TIME_MERIDIANfor example 24/12/2008 8:30 PM DT_ISO_YEAR_MONTH_DAYfor example 2008-12-24 DT_ISO_YEAR_MONTH_DAY_TIMEfor example 2008-12-24 20:30:45 DT_MONTH_DAY_4_DIGIT_YEARfor example 12/24/2008 DT_TIME_LONGfor example 8:30:45 PM UTC-6 DT_TIME_MEDIUMfor example 8:30:45 PM DT_TIME_SHORTfor example 8:30 PM DT_YEAR_ONLYfor example 2008 HIGHLIGHT_UNTYPED_CELLSHighlight cell data that does not match the data type NONENo formatting (default) NUMBER_CURRENCYfor example $1234.56 NUMBER_DEFAULTfor example 1,234.56 NUMBER_INTEGERfor example 1235 NUMBER_NO_SEPARATORfor example 1234.56 NUMBER_PERCENTfor example 123,456% NUMBER_SCIENTIFICfor example 1E3 STRING_EIGHT_LINE_IMAGEDisplays thumbnail images as tall as eight lines of text STRING_FOUR_LINE_IMAGEDisplays thumbnail images as tall as four lines of text STRING_JSON_TEXTAllows editing of text as JSON in UI STRING_JSON_LISTAllows editing of text as a JSON list in UI STRING_LINKTreats cell as a link (must start with http:// or https://) STRING_ONE_LINE_IMAGEDisplays thumbnail images as tall as one line of text STRING_VIDEO_OR_MAPDisplay a video or map thumbnail #[serde(rename="formatPattern")] pub format_pattern: Option, /// JSON schema for interpreting JSON in this column. diff --git a/gen/games1-cli/Cargo.toml b/gen/games1-cli/Cargo.toml index 1d9213bf8f..2f5704e09d 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+20160401" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "games1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-games1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-games1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-games1] diff --git a/gen/games1-cli/README.md b/gen/games1-cli/README.md index 297eed9748..55147ae717 100644 --- a/gen/games1-cli/README.md +++ b/gen/games1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Games* API at revision *20160401*. The CLI is at version *0.3.6*. +This documentation was generated from the *Games* API at revision *20160901*. The CLI is at version *0.3.6*. ```bash games1 [options] diff --git a/gen/games1-cli/mkdocs.yml b/gen/games1-cli/mkdocs.yml index 37cfa1054c..713aa0562f 100644 --- a/gen/games1-cli/mkdocs.yml +++ b/gen/games1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Games v0.3.6+20160401 +site_name: Games v0.3.6+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 37a43d4c05..83e97709d0 100644 --- a/gen/games1-cli/src/main.rs +++ b/gen/games1-cli/src/main.rs @@ -60,6 +60,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -73,7 +76,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -117,6 +120,9 @@ impl<'n> Engine<'n> { "request-id" => { call = call.request_id(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -130,7 +136,7 @@ impl<'n> Engine<'n> { 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.extend(["consistency-token", "request-id"].iter().map(|v|*v)); v } )); } } @@ -182,6 +188,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -195,7 +204,7 @@ impl<'n> Engine<'n> { 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", "state", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "state", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -235,6 +244,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -248,6 +260,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -288,6 +301,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -301,6 +317,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -340,6 +357,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -353,6 +373,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -425,6 +446,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -438,6 +462,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -483,6 +508,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -496,7 +524,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["platform-type", "language"].iter().map(|v|*v)); + v.extend(["consistency-token", "platform-type", "language"].iter().map(|v|*v)); v } )); } } @@ -536,6 +564,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -549,6 +580,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -580,6 +612,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -593,6 +628,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -641,6 +677,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -654,7 +693,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -703,6 +742,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -716,7 +758,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -794,6 +836,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -807,7 +852,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -850,6 +895,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -863,7 +911,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -912,6 +960,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -925,7 +976,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -965,6 +1016,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -978,6 +1032,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1026,6 +1081,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1039,7 +1097,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -1082,6 +1140,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1095,7 +1156,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1144,6 +1205,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1157,7 +1221,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -1232,6 +1296,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1245,6 +1312,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1314,6 +1382,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1327,6 +1398,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1358,6 +1430,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1371,6 +1446,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1405,6 +1481,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1418,7 +1497,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1467,6 +1546,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1480,7 +1562,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -1520,6 +1602,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1533,6 +1618,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1625,6 +1711,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1638,7 +1727,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1681,6 +1770,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1694,7 +1786,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1734,6 +1826,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1747,6 +1842,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -1781,6 +1877,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1794,7 +1893,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1880,6 +1979,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1893,7 +1995,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -1977,6 +2079,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -1990,7 +2095,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2039,6 +2144,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2052,7 +2160,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -2128,6 +2236,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2141,7 +2252,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2193,6 +2304,9 @@ impl<'n> Engine<'n> { "include-rank-type" => { call = call.include_rank_type(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2206,7 +2320,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results", "include-rank-type"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results", "include-rank-type"].iter().map(|v|*v)); v } )); } } @@ -2255,6 +2369,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2268,7 +2385,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -2323,6 +2440,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2336,7 +2456,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["return-top-if-absent", "results-above", "language", "max-results", "page-token"].iter().map(|v|*v)); + v.extend(["language", "return-top-if-absent", "results-above", "max-results", "page-token", "consistency-token"].iter().map(|v|*v)); v } )); } } @@ -2382,6 +2502,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2395,7 +2518,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language", "score-tag"].iter().map(|v|*v)); + v.extend(["consistency-token", "language", "score-tag"].iter().map(|v|*v)); v } )); } } @@ -2471,6 +2594,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2484,7 +2610,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2527,6 +2653,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2540,7 +2669,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2589,6 +2718,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2602,7 +2734,7 @@ impl<'n> Engine<'n> { 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", "language", "max-results"].iter().map(|v|*v)); + v.extend(["page-token", "consistency-token", "language", "max-results"].iter().map(|v|*v)); v } )); } } @@ -2642,6 +2774,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2655,6 +2790,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -2729,6 +2865,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2742,7 +2881,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2785,6 +2924,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2798,7 +2940,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2838,6 +2980,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2851,6 +2996,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["consistency-token"].iter().map(|v|*v)); v } )); } } @@ -2921,6 +3067,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2934,7 +3083,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -2980,6 +3129,9 @@ impl<'n> Engine<'n> { "include-match-data" => { call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "boolean")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2993,7 +3145,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language", "include-match-data"].iter().map(|v|*v)); + v.extend(["consistency-token", "language", "include-match-data"].iter().map(|v|*v)); v } )); } } @@ -3036,6 +3188,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3049,7 +3204,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -3092,6 +3247,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3105,7 +3263,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -3152,6 +3310,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3165,7 +3326,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language", "pending-participant-id"].iter().map(|v|*v)); + v.extend(["consistency-token", "language", "pending-participant-id"].iter().map(|v|*v)); v } )); } } @@ -3220,6 +3381,9 @@ impl<'n> Engine<'n> { "include-match-data" => { call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "boolean")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3233,7 +3397,7 @@ impl<'n> Engine<'n> { 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", "max-completed-matches", "language", "max-results", "include-match-data"].iter().map(|v|*v)); + v.extend(["max-completed-matches", "language", "max-results", "include-match-data", "page-token", "consistency-token"].iter().map(|v|*v)); v } )); } } @@ -3279,6 +3443,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3292,7 +3459,7 @@ impl<'n> Engine<'n> { 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", "language"].iter().map(|v|*v)); + v.extend(["consistency-token", "request-id", "language"].iter().map(|v|*v)); v } )); } } @@ -3347,6 +3514,9 @@ impl<'n> Engine<'n> { "include-match-data" => { call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "boolean")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3360,7 +3530,7 @@ impl<'n> Engine<'n> { 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", "max-completed-matches", "language", "max-results", "include-match-data"].iter().map(|v|*v)); + v.extend(["max-completed-matches", "language", "max-results", "include-match-data", "page-token", "consistency-token"].iter().map(|v|*v)); v } )); } } @@ -3440,6 +3610,9 @@ impl<'n> Engine<'n> { "language" => { call = call.language(value.unwrap_or("")); }, + "consistency-token" => { + call = call.consistency_token(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -3453,7 +3626,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["language"].iter().map(|v|*v)); + v.extend(["consistency-token", "language"].iter().map(|v|*v)); v } )); } } @@ -5086,7 +5259,7 @@ fn main() { let mut app = App::new("games1") .author("Sebastian Thiel ") - .version("0.3.6+20160401") + .version("0.3.6+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/games1/Cargo.toml b/gen/games1/Cargo.toml index ce09854026..fd4adb7991 100644 --- a/gen/games1/Cargo.toml +++ b/gen/games1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-games1" -version = "0.1.14+20160401" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/games1/README.md b/gen/games1/README.md index 98d0814620..25b6b08b7e 100644 --- a/gen/games1/README.md +++ b/gen/games1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-games1` library allows access to all features of the *Google Games* service. -This documentation was generated from *Games* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Games* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Games* *v1* API can be found at the [official documentation site](https://developers.google.com/games/services/). @@ -130,6 +130,7 @@ let mut hub = Games::new(hyper::Client::new(), auth); let result = hub.turn_based_matches().leave_turn("matchId", -48) .pending_participant_id("Stet") .language("sed") + .consistency_token("et") .doit(); match result { diff --git a/gen/games1/src/lib.rs b/gen/games1/src/lib.rs index 785f15b486..6a73d9c5e0 100644 --- a/gen/games1/src/lib.rs +++ b/gen/games1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Games* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *games:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Games* *v1* API can be found at the //! [official documentation site](https://developers.google.com/games/services/). @@ -128,9 +128,10 @@ //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! -//! let result = hub.turn_based_matches().leave_turn("matchId", -48) -//! .pending_participant_id("diam") -//! .language("kasd") +//! let result = hub.turn_based_matches().leave_turn("matchId", -46) +//! .pending_participant_id("sea") +//! .language("elitr") +//! .consistency_token("At") //! .doit(); //! //! match result { diff --git a/gen/games1/src/lib.rs.in b/gen/games1/src/lib.rs.in index aabfff0a16..f64a490012 100644 --- a/gen/games1/src/lib.rs.in +++ b/gen/games1/src/lib.rs.in @@ -99,9 +99,10 @@ impl Default for Scope { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.turn_based_matches().leave_turn("matchId", -18) -/// .pending_participant_id("kasd") -/// .language("accusam") +/// let result = hub.turn_based_matches().leave_turn("matchId", -63) +/// .pending_participant_id("accusam") +/// .language("takimata") +/// .consistency_token("justo") /// .doit(); /// /// match result { @@ -220,6 +221,33 @@ pub struct Category { impl Part for Category {} +/// This is a JSON template for an event period update 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*). +/// +/// * [record events](struct.EventRecordCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventRecordRequest { + /// A list of the time period updates being made in this request. + #[serde(rename="timePeriods")] + pub time_periods: Option>, + /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventRecordRequest. + pub kind: Option, + /// The request ID used to identify this attempt to record events. + #[serde(rename="requestId")] + pub request_id: Option, + /// The current time when this update was sent, in milliseconds, since 1970 UTC (Unix Epoch). + #[serde(rename="currentTimeMillis")] + pub current_time_millis: Option, +} + +impl RequestValue for EventRecordRequest {} + + /// This is a JSON template for a third party player list response. /// /// # Activities @@ -1812,28 +1840,6 @@ pub struct LeaderboardEntry { impl Part for LeaderboardEntry {} -/// This is a JSON template for an turn-based auto-match criteria 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 TurnBasedAutoMatchingCriteria { - /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedAutoMatchingCriteria. - pub kind: Option, - /// The minimum number of players that should be added to the match by auto-matching. - #[serde(rename="minAutoMatchingPlayers")] - pub min_auto_matching_players: Option, - /// A bitmask indicating when auto-matches are valid. When ANDed with other exclusive bitmasks, the result must be zero. Can be used to support exclusive roles within a game. - #[serde(rename="exclusiveBitmask")] - pub exclusive_bitmask: Option, - /// The maximum number of players that should be added to the match by auto-matching. - #[serde(rename="maxAutoMatchingPlayers")] - pub max_auto_matching_players: Option, -} - -impl Part for TurnBasedAutoMatchingCriteria {} - - /// This is a JSON template for a room creation request. /// /// # Activities @@ -1896,6 +1902,22 @@ pub struct PeerSessionDiagnostics { impl Part for PeerSessionDiagnostics {} +/// This is a JSON template for profile settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProfileSettings { + /// Uniquely identifies the type of this resource. Value is always the fixed string games#profileSettings. + pub kind: Option, + /// The player's current profile visibility. This field is visible to both 1P and 3P APIs. + #[serde(rename="profileVisible")] + pub profile_visible: Option, +} + +impl Part for ProfileSettings {} + + /// This is a JSON template for a list of quest objects. /// /// # Activities @@ -2663,31 +2685,26 @@ pub struct TurnBasedMatch { impl ResponseResult for TurnBasedMatch {} -/// This is a JSON template for an event period update resource. +/// This is a JSON template for an turn-based auto-match criteria 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*). -/// -/// * [record events](struct.EventRecordCall.html) (request) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct EventRecordRequest { - /// A list of the time period updates being made in this request. - #[serde(rename="timePeriods")] - pub time_periods: Option>, - /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventRecordRequest. +pub struct TurnBasedAutoMatchingCriteria { + /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedAutoMatchingCriteria. pub kind: Option, - /// The request ID used to identify this attempt to record events. - #[serde(rename="requestId")] - pub request_id: Option, - /// The current time when this update was sent, in milliseconds, since 1970 UTC (Unix Epoch). - #[serde(rename="currentTimeMillis")] - pub current_time_millis: Option, + /// The minimum number of players that should be added to the match by auto-matching. + #[serde(rename="minAutoMatchingPlayers")] + pub min_auto_matching_players: Option, + /// A bitmask indicating when auto-matches are valid. When ANDed with other exclusive bitmasks, the result must be zero. Can be used to support exclusive roles within a game. + #[serde(rename="exclusiveBitmask")] + pub exclusive_bitmask: Option, + /// The maximum number of players that should be added to the match by auto-matching. + #[serde(rename="maxAutoMatchingPlayers")] + pub max_auto_matching_players: Option, } -impl RequestValue for EventRecordRequest {} +impl Part for TurnBasedAutoMatchingCriteria {} /// This is a JSON template for the Web details resource. @@ -2787,14 +2804,17 @@ pub struct Player { /// The url to the portrait mode player banner image. #[serde(rename="bannerUrlPortrait")] pub banner_url_portrait: Option, - /// The player's title rewarded for their game activities. - pub title: Option, + /// The player's profile settings. Controls whether or not the player's profile is visible to other players. + #[serde(rename="profileSettings")] + pub profile_settings: Option, /// An object to represent Play Game experience information for the player. #[serde(rename="experienceInfo")] pub experience_info: Option, /// The url to the landscape mode player banner image. #[serde(rename="bannerUrlLandscape")] pub banner_url_landscape: Option, + /// The player's title rewarded for their game activities. + pub title: Option, /// The base URL for the image that represents the player. #[serde(rename="avatarImageUrl")] pub avatar_image_url: Option, @@ -2985,6 +3005,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3005,6 +3026,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { _achievement_id: achievement_id.to_string(), _steps_to_increment: steps_to_increment, _request_id: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3024,6 +3046,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { hub: self.hub, _achievement_id: achievement_id.to_string(), _steps: steps, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3041,6 +3064,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { AchievementUpdateMultipleCall { hub: self.hub, _request: request, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3058,6 +3082,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { AchievementRevealCall { hub: self.hub, _achievement_id: achievement_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3075,6 +3100,7 @@ impl<'a, C, A> AchievementMethods<'a, C, A> { AchievementUnlockCall { hub: self.hub, _achievement_id: achievement_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3134,6 +3160,7 @@ impl<'a, C, A> LeaderboardMethods<'a, C, A> { hub: self.hub, _leaderboard_id: leaderboard_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3149,6 +3176,7 @@ impl<'a, C, A> LeaderboardMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3212,6 +3240,7 @@ impl<'a, C, A> MetagameMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3224,6 +3253,7 @@ impl<'a, C, A> MetagameMethods<'a, C, A> { pub fn get_metagame_config(&self) -> MetagameGetMetagameConfigCall<'a, C, A> { MetagameGetMetagameConfigCall { hub: self.hub, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3285,6 +3315,7 @@ impl<'a, C, A> PlayerMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3303,6 +3334,7 @@ impl<'a, C, A> PlayerMethods<'a, C, A> { hub: self.hub, _player_id: player_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3362,6 +3394,7 @@ impl<'a, C, A> QuestMethods<'a, C, A> { hub: self.hub, _quest_id: quest_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3382,6 +3415,7 @@ impl<'a, C, A> QuestMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3441,6 +3475,7 @@ impl<'a, C, A> SnapshotMethods<'a, C, A> { hub: self.hub, _snapshot_id: snapshot_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3461,6 +3496,7 @@ impl<'a, C, A> SnapshotMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3519,6 +3555,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { TurnBasedMatcheDismisCall { hub: self.hub, _match_id: match_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3536,6 +3573,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _max_completed_matches: Default::default(), _language: Default::default(), _include_match_data: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3554,6 +3592,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { hub: self.hub, _match_id: match_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3573,6 +3612,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _match_id: match_id.to_string(), _language: Default::default(), _include_match_data: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3591,6 +3631,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { hub: self.hub, _request: request, _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3609,6 +3650,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { hub: self.hub, _match_id: match_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3630,6 +3672,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _match_version: match_version, _pending_participant_id: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3647,6 +3690,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { TurnBasedMatcheCancelCall { hub: self.hub, _match_id: match_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3667,6 +3711,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _request: request, _match_id: match_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3685,6 +3730,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { hub: self.hub, _match_id: match_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3702,6 +3748,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _max_completed_matches: Default::default(), _language: Default::default(), _include_match_data: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3722,6 +3769,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _request: request, _match_id: match_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3741,6 +3789,7 @@ impl<'a, C, A> TurnBasedMatcheMethods<'a, C, A> { _match_id: match_id.to_string(), _request_id: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3799,6 +3848,7 @@ impl<'a, C, A> ApplicationMethods<'a, C, A> { ApplicationVerifyCall { hub: self.hub, _application_id: application_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3818,6 +3868,7 @@ impl<'a, C, A> ApplicationMethods<'a, C, A> { _application_id: application_id.to_string(), _platform_type: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3830,6 +3881,7 @@ impl<'a, C, A> ApplicationMethods<'a, C, A> { pub fn played(&self) -> ApplicationPlayedCall<'a, C, A> { ApplicationPlayedCall { hub: self.hub, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3889,6 +3941,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { hub: self.hub, _room_id: room_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3909,6 +3962,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { _request: request, _room_id: room_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3924,6 +3978,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3944,6 +3999,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { _request: request, _room_id: room_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3962,6 +4018,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { hub: self.hub, _request: request, _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3980,6 +4037,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { hub: self.hub, _room_id: room_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3997,6 +4055,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { RoomDismisCall { hub: self.hub, _room_id: room_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4017,6 +4076,7 @@ impl<'a, C, A> RoomMethods<'a, C, A> { _request: request, _room_id: room_id.to_string(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4079,6 +4139,7 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { _score: score.to_string(), _score_tag: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4103,6 +4164,7 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4129,6 +4191,7 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { _max_results: Default::default(), _language: Default::default(), _include_rank_type: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4147,6 +4210,7 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { hub: self.hub, _request: request, _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4173,6 +4237,7 @@ impl<'a, C, A> ScoreMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4231,6 +4296,7 @@ impl<'a, C, A> PushtokenMethods<'a, C, A> { PushtokenRemoveCall { hub: self.hub, _request: request, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4248,6 +4314,7 @@ impl<'a, C, A> PushtokenMethods<'a, C, A> { PushtokenUpdateCall { hub: self.hub, _request: request, + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4311,6 +4378,7 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { RevisionCheckCall { hub: self.hub, _client_revision: client_revision.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4367,6 +4435,7 @@ impl<'a, C, A> EventMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4385,6 +4454,7 @@ impl<'a, C, A> EventMethods<'a, C, A> { hub: self.hub, _request: request, _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4400,6 +4470,7 @@ impl<'a, C, A> EventMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4462,6 +4533,7 @@ impl<'a, C, A> QuestMilestoneMethods<'a, C, A> { _quest_id: quest_id.to_string(), _milestone_id: milestone_id.to_string(), _request_id: request_id.to_string(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4518,6 +4590,7 @@ impl<'a, C, A> AchievementDefinitionMethods<'a, C, A> { _page_token: Default::default(), _max_results: Default::default(), _language: Default::default(), + _consistency_token: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -4560,10 +4633,11 @@ impl<'a, C, A> AchievementDefinitionMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.achievements().list("playerId") -/// .state("justo") -/// .page_token("amet.") -/// .max_results(-81) -/// .language("labore") +/// .state("erat") +/// .page_token("labore") +/// .max_results(-9) +/// .language("nonumy") +/// .consistency_token("dolores") /// .doit(); /// # } /// ``` @@ -4576,6 +4650,7 @@ pub struct AchievementListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -4597,7 +4672,7 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.achievements.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); if let Some(value) = self._state { params.push(("state", value.to_string())); @@ -4611,7 +4686,10 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "playerId", "state", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "playerId", "state", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4764,6 +4842,13 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut, self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> AchievementListCall<'a, C, A> { + self._consistency_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. /// @@ -4842,8 +4927,9 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.achievements().increment("achievementId", -90) -/// .request_id("dolores") +/// let result = hub.achievements().increment("achievementId", -95) +/// .request_id("aliquyam") +/// .consistency_token("ea") /// .doit(); /// # } /// ``` @@ -4854,6 +4940,7 @@ pub struct AchievementIncrementCall<'a, C, A> _achievement_id: String, _steps_to_increment: i32, _request_id: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -4875,13 +4962,16 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("achievementId", self._achievement_id.to_string())); params.push(("stepsToIncrement", self._steps_to_increment.to_string())); if let Some(value) = self._request_id { params.push(("requestId", value.to_string())); } - for &field in ["alt", "achievementId", "stepsToIncrement", "requestId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "achievementId", "stepsToIncrement", "requestId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5023,6 +5113,13 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut AchievementIncrementCall<'a, C, A> { + self._consistency_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. /// @@ -5101,7 +5198,8 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut hub: &'a Games, _achievement_id: String, _steps: i32, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -5132,10 +5231,13 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("achievementId", self._achievement_id.to_string())); params.push(("steps", self._steps.to_string())); - for &field in ["alt", "achievementId", "steps"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "achievementId", "steps", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5270,6 +5372,13 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut AchievementSetStepsAtLeastCall<'a, C, A> { + self._consistency_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. /// @@ -5355,6 +5464,7 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut hub: &'a Games, _request: AchievementUpdateMultipleRequest, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -5384,8 +5495,11 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5503,6 +5617,13 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut AchievementUpdateMultipleCall<'a, C, A> { + self._consistency_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. /// @@ -5582,6 +5703,7 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut hub: &'a Games, _achievement_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -5611,9 +5734,12 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut }; dlg.begin(MethodInfo { id: "games.achievements.reveal", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("achievementId", self._achievement_id.to_string())); - for &field in ["alt", "achievementId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "achievementId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5738,6 +5864,13 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut self._achievement_id = new_value.to_string(); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> AchievementRevealCall<'a, C, A> { + self._consistency_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. /// @@ -5817,6 +5950,7 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.achievements().unlock("achievementId") +/// .consistency_token("Lorem") /// .doit(); /// # } /// ``` @@ -5825,6 +5959,7 @@ pub struct AchievementUnlockCall<'a, C, A> hub: &'a Games, _achievement_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -5846,9 +5981,12 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut }; dlg.begin(MethodInfo { id: "games.achievements.unlock", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("achievementId", self._achievement_id.to_string())); - for &field in ["alt", "achievementId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "achievementId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5973,6 +6111,13 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut self._achievement_id = new_value.to_string(); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> AchievementUnlockCall<'a, C, A> { + self._consistency_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. /// @@ -6052,7 +6197,8 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.leaderboards().get("leaderboardId") -/// .language("justo") +/// .language("duo") +/// .consistency_token("aliquyam") /// .doit(); /// # } /// ``` @@ -6062,6 +6208,7 @@ pub struct LeaderboardGetCall<'a, C, A> hub: &'a Games, _leaderboard_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -6083,12 +6230,15 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut, A }; dlg.begin(MethodInfo { id: "games.leaderboards.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("leaderboardId", self._leaderboard_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "leaderboardId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "leaderboardId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6220,6 +6370,13 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut, A self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> LeaderboardGetCall<'a, C, A> { + self._consistency_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. /// @@ -6299,9 +6456,10 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.leaderboards().list() -/// .page_token("justo") -/// .max_results(-34) -/// .language("et") +/// .page_token("sea") +/// .max_results(-55) +/// .language("eos") +/// .consistency_token("erat") /// .doit(); /// # } /// ``` @@ -6312,6 +6470,7 @@ pub struct LeaderboardListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -6333,7 +6492,7 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.leaderboards.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -6343,7 +6502,10 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6458,6 +6620,13 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut, self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> LeaderboardListCall<'a, C, A> { + self._consistency_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. /// @@ -6537,9 +6706,10 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.metagame().list_categories_by_player("playerId", "collection") -/// .page_token("Lorem") -/// .max_results(-21) -/// .language("duo") +/// .page_token("eirmod") +/// .max_results(-43) +/// .language("amet") +/// .consistency_token("no") /// .doit(); /// # } /// ``` @@ -6552,6 +6722,7 @@ pub struct MetagameListCategoriesByPlayerCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -6573,7 +6744,7 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); params.push(("collection", self._collection.to_string())); if let Some(value) = self._page_token { @@ -6585,7 +6756,10 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut MetagameListCategoriesByPlayerCall<'a, C, A> { + self._consistency_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. /// @@ -6820,6 +7001,7 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { hub: &'a Games, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -6848,8 +7031,11 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((2 + self._additional_params.len())); - for &field in ["alt"].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6943,6 +7129,13 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut MetagameGetMetagameConfigCall<'a, C, A> { + self._consistency_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. /// @@ -7022,9 +7215,10 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -7057,7 +7252,7 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut, A: oa }; dlg.begin(MethodInfo { id: "games.players.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("collection", self._collection.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -7068,7 +7263,10 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut, A: oa if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "collection", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "collection", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7214,6 +7412,13 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut, A: oa self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> PlayerListCall<'a, C, A> { + self._consistency_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. /// @@ -7293,7 +7498,8 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.players().get("playerId") -/// .language("sadipscing") +/// .language("sea") +/// .consistency_token("et") /// .doit(); /// # } /// ``` @@ -7303,6 +7509,7 @@ pub struct PlayerGetCall<'a, C, A> hub: &'a Games, _player_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -7324,12 +7531,15 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut, A: oau }; dlg.begin(MethodInfo { id: "games.players.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "playerId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "playerId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7461,6 +7671,13 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut, A: oau self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> PlayerGetCall<'a, C, A> { + self._consistency_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. /// @@ -7540,7 +7757,8 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.quests().accept("questId") -/// .language("eirmod") +/// .language("et") +/// .consistency_token("eirmod") /// .doit(); /// # } /// ``` @@ -7550,6 +7768,7 @@ pub struct QuestAcceptCall<'a, C, A> hub: &'a Games, _quest_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -7571,12 +7790,15 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "games.quests.accept", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("questId", self._quest_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "questId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "questId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7708,6 +7930,13 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut, A: o self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> QuestAcceptCall<'a, C, A> { + self._consistency_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. /// @@ -7787,9 +8016,10 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.quests().list("playerId") -/// .page_token("amet") -/// .max_results(-60) -/// .language("labore") +/// .page_token("et") +/// .max_results(-46) +/// .language("et") +/// .consistency_token("consetetur") /// .doit(); /// # } /// ``` @@ -7801,6 +8031,7 @@ pub struct QuestListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -7822,7 +8053,7 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut, A: oau }; dlg.begin(MethodInfo { id: "games.quests.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -7833,7 +8064,10 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut, A: oau if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "playerId", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "playerId", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7979,6 +8213,13 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut, A: oau self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> QuestListCall<'a, C, A> { + self._consistency_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. /// @@ -8058,7 +8299,8 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.snapshots().get("snapshotId") -/// .language("dolore") +/// .language("ea") +/// .consistency_token("sed") /// .doit(); /// # } /// ``` @@ -8068,6 +8310,7 @@ pub struct SnapshotGetCall<'a, C, A> hub: &'a Games, _snapshot_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8089,12 +8332,15 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "games.snapshots.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("snapshotId", self._snapshot_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "snapshotId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "snapshotId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8226,6 +8472,13 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> SnapshotGetCall<'a, C, A> { + self._consistency_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. /// @@ -8305,9 +8558,10 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.snapshots().list("playerId") -/// .page_token("aliquyam") -/// .max_results(-73) -/// .language("Lorem") +/// .page_token("dolor") +/// .max_results(-48) +/// .language("et") +/// .consistency_token("consetetur") /// .doit(); /// # } /// ``` @@ -8319,6 +8573,7 @@ pub struct SnapshotListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8340,7 +8595,7 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "games.snapshots.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -8351,7 +8606,10 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "playerId", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "playerId", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8497,6 +8755,13 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> SnapshotListCall<'a, C, A> { + self._consistency_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. /// @@ -8576,6 +8841,7 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.turn_based_matches().dismiss("matchId") +/// .consistency_token("voluptua.") /// .doit(); /// # } /// ``` @@ -8584,6 +8850,7 @@ pub struct TurnBasedMatcheDismisCall<'a, C, A> hub: &'a Games, _match_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8605,9 +8872,12 @@ impl<'a, C, A> TurnBasedMatcheDismisCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((2 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); - for &field in ["matchId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["matchId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8721,6 +8991,13 @@ impl<'a, C, A> TurnBasedMatcheDismisCall<'a, C, A> where C: BorrowMut TurnBasedMatcheDismisCall<'a, C, A> { + self._consistency_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. /// @@ -8800,11 +9077,12 @@ impl<'a, C, A> TurnBasedMatcheDismisCall<'a, C, A> where C: BorrowMut _max_completed_matches: Option, _language: Option, _include_match_data: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -8838,7 +9117,7 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -8854,7 +9133,10 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut TurnBasedMatcheSyncCall<'a, C, A> { + self._consistency_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. /// @@ -9062,7 +9351,8 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut hub: &'a Games, _match_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -9093,12 +9384,15 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "matchId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "matchId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9230,6 +9524,13 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut TurnBasedMatcheDeclineCall<'a, C, A> { + self._consistency_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. /// @@ -9309,8 +9610,9 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut _match_id: String, _language: Option, _include_match_data: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -9342,7 +9645,7 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); @@ -9350,7 +9653,10 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut TurnBasedMatcheGetCall<'a, C, A> { + self._consistency_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. /// @@ -9574,7 +9887,8 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut hub: &'a Games, _request: TurnBasedMatchCreateRequest, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -9605,11 +9920,14 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9734,6 +10052,13 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut TurnBasedMatcheCreateCall<'a, C, A> { + self._consistency_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. /// @@ -9813,7 +10138,8 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut hub: &'a Games, _match_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -9844,12 +10171,15 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "matchId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "matchId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -9981,6 +10311,13 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut TurnBasedMatcheJoinCall<'a, C, A> { + self._consistency_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. /// @@ -10059,9 +10396,10 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut _match_version: i32, _pending_participant_id: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -10094,7 +10433,7 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); params.push(("matchVersion", self._match_version.to_string())); if let Some(value) = self._pending_participant_id { @@ -10103,7 +10442,10 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut TurnBasedMatcheLeaveTurnCall<'a, C, A> { + self._consistency_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. /// @@ -10331,6 +10680,7 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut hub: &'a Games, _match_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -10360,9 +10711,12 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((2 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); - for &field in ["matchId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["matchId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -10476,6 +10830,13 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut TurnBasedMatcheCancelCall<'a, C, A> { + self._consistency_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. /// @@ -10561,7 +10922,8 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut _request: TurnBasedMatchResults, _match_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -10593,12 +10956,15 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "matchId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "matchId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -10754,6 +11120,13 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut TurnBasedMatcheFinishCall<'a, C, A> { + self._consistency_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. /// @@ -10833,7 +11206,8 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut hub: &'a Games, _match_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -10864,12 +11239,15 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "matchId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "matchId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -11001,6 +11379,13 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut TurnBasedMatcheLeaveCall<'a, C, A> { + self._consistency_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. /// @@ -11080,11 +11465,12 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut _max_completed_matches: Option, _language: Option, _include_match_data: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -11118,7 +11505,7 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -11134,7 +11521,10 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut TurnBasedMatcheListCall<'a, C, A> { + self._consistency_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. /// @@ -11348,7 +11745,8 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut _request: TurnBasedMatchTurn, _match_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -11380,12 +11779,15 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "matchId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "matchId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -11541,6 +11943,13 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut TurnBasedMatcheTakeTurnCall<'a, C, A> { + self._consistency_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. /// @@ -11620,8 +12029,9 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut _match_id: String, _request_id: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -11653,7 +12064,7 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("matchId", self._match_id.to_string())); if let Some(value) = self._request_id { params.push(("requestId", value.to_string())); @@ -11661,7 +12072,10 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut TurnBasedMatcheRematchCall<'a, C, A> { + self._consistency_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. /// @@ -11879,6 +12300,7 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut hub: &'a Games, _application_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -11908,9 +12331,12 @@ impl<'a, C, A> ApplicationVerifyCall<'a, C, A> where C: BorrowMut }; dlg.begin(MethodInfo { id: "games.applications.verify", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("applicationId", self._application_id.to_string())); - for &field in ["alt", "applicationId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "applicationId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12035,6 +12461,13 @@ impl<'a, C, A> ApplicationVerifyCall<'a, C, A> where C: BorrowMut self._application_id = new_value.to_string(); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ApplicationVerifyCall<'a, C, A> { + self._consistency_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. /// @@ -12114,8 +12547,9 @@ impl<'a, C, A> ApplicationVerifyCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.applications().get("applicationId") -/// .platform_type("aliquyam") -/// .language("Lorem") +/// .platform_type("ipsum") +/// .language("aliquyam") +/// .consistency_token("dolores") /// .doit(); /// # } /// ``` @@ -12126,6 +12560,7 @@ pub struct ApplicationGetCall<'a, C, A> _application_id: String, _platform_type: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -12147,7 +12582,7 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut, A }; dlg.begin(MethodInfo { id: "games.applications.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("applicationId", self._application_id.to_string())); if let Some(value) = self._platform_type { params.push(("platformType", value.to_string())); @@ -12155,7 +12590,10 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut, A if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "applicationId", "platformType", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "applicationId", "platformType", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12294,6 +12732,13 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut, A self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ApplicationGetCall<'a, C, A> { + self._consistency_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. /// @@ -12373,6 +12818,7 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.applications().played() +/// .consistency_token("sit") /// .doit(); /// # } /// ``` @@ -12380,6 +12826,7 @@ pub struct ApplicationPlayedCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Games, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -12401,8 +12848,11 @@ impl<'a, C, A> ApplicationPlayedCall<'a, C, A> where C: BorrowMut }; dlg.begin(MethodInfo { id: "games.applications.played", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((1 + self._additional_params.len())); - for &field in [].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12485,6 +12935,13 @@ impl<'a, C, A> ApplicationPlayedCall<'a, C, A> where C: BorrowMut } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ApplicationPlayedCall<'a, C, A> { + self._consistency_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. /// @@ -12564,7 +13021,8 @@ impl<'a, C, A> ApplicationPlayedCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().get("roomId") -/// .language("clita") +/// .language("ut") +/// .consistency_token("justo") /// .doit(); /// # } /// ``` @@ -12574,6 +13032,7 @@ pub struct RoomGetCall<'a, C, A> hub: &'a Games, _room_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -12595,12 +13054,15 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut, A: oauth }; dlg.begin(MethodInfo { id: "games.rooms.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "roomId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "roomId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12732,6 +13194,13 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut, A: oauth self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomGetCall<'a, C, A> { + self._consistency_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. /// @@ -12817,7 +13286,8 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().leave(req, "roomId") -/// .language("takimata") +/// .language("amet") +/// .consistency_token("accusam") /// .doit(); /// # } /// ``` @@ -12828,6 +13298,7 @@ pub struct RoomLeaveCall<'a, C, A> _request: RoomLeaveRequest, _room_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -12849,12 +13320,15 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut, A: oau }; dlg.begin(MethodInfo { id: "games.rooms.leave", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "roomId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "roomId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13010,6 +13484,13 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut, A: oau self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomLeaveCall<'a, C, A> { + self._consistency_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. /// @@ -13089,9 +13570,10 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().list() -/// .page_token("nonumy") -/// .max_results(-13) -/// .language("sanctus") +/// .page_token("clita") +/// .max_results(-79) +/// .language("justo") +/// .consistency_token("est") /// .doit(); /// # } /// ``` @@ -13102,6 +13584,7 @@ pub struct RoomListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13123,7 +13606,7 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut, A: oaut }; dlg.begin(MethodInfo { id: "games.rooms.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -13133,7 +13616,10 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut, A: oaut if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13248,6 +13734,13 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut, A: oaut self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomListCall<'a, C, A> { + self._consistency_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. /// @@ -13333,7 +13826,8 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().report_status(req, "roomId") -/// .language("At") +/// .language("invidunt") +/// .consistency_token("ut") /// .doit(); /// # } /// ``` @@ -13344,6 +13838,7 @@ pub struct RoomReportStatuCall<'a, C, A> _request: RoomP2PStatuses, _room_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13365,12 +13860,15 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.rooms.reportStatus", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "roomId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "roomId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13526,6 +14024,13 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut, self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomReportStatuCall<'a, C, A> { + self._consistency_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. /// @@ -13611,7 +14116,8 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().create(req) -/// .language("labore") +/// .language("dolores") +/// .consistency_token("eos") /// .doit(); /// # } /// ``` @@ -13621,6 +14127,7 @@ pub struct RoomCreateCall<'a, C, A> hub: &'a Games, _request: RoomCreateRequest, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13642,11 +14149,14 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut, A: oa }; dlg.begin(MethodInfo { id: "games.rooms.create", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13771,6 +14281,13 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut, A: oa self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomCreateCall<'a, C, A> { + self._consistency_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. /// @@ -13850,7 +14367,8 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().decline("roomId") -/// .language("ea") +/// .language("duo") +/// .consistency_token("sed") /// .doit(); /// # } /// ``` @@ -13860,6 +14378,7 @@ pub struct RoomDeclineCall<'a, C, A> hub: &'a Games, _room_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13881,12 +14400,15 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "games.rooms.decline", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "roomId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "roomId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14018,6 +14540,13 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut, A: o self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomDeclineCall<'a, C, A> { + self._consistency_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. /// @@ -14097,6 +14626,7 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().dismiss("roomId") +/// .consistency_token("ea") /// .doit(); /// # } /// ``` @@ -14105,6 +14635,7 @@ pub struct RoomDismisCall<'a, C, A> hub: &'a Games, _room_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -14126,9 +14657,12 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut, A: oa }; dlg.begin(MethodInfo { id: "games.rooms.dismiss", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); - for &field in ["roomId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["roomId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14242,6 +14776,13 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut, A: oa self._room_id = new_value.to_string(); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomDismisCall<'a, C, A> { + self._consistency_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. /// @@ -14327,7 +14868,8 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.rooms().join(req, "roomId") -/// .language("dolore") +/// .language("et") +/// .consistency_token("dolor") /// .doit(); /// # } /// ``` @@ -14338,6 +14880,7 @@ pub struct RoomJoinCall<'a, C, A> _request: RoomJoinRequest, _room_id: String, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -14359,12 +14902,15 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut, A: oaut }; dlg.begin(MethodInfo { id: "games.rooms.join", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("roomId", self._room_id.to_string())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "roomId", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "roomId", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14520,6 +15066,13 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut, A: oaut self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RoomJoinCall<'a, C, A> { + self._consistency_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. /// @@ -14599,8 +15152,9 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.scores().submit("leaderboardId", "score") -/// .score_tag("aliquyam") -/// .language("sit") +/// .score_tag("invidunt") +/// .language("rebum.") +/// .consistency_token("Lorem") /// .doit(); /// # } /// ``` @@ -14612,6 +15166,7 @@ pub struct ScoreSubmitCall<'a, C, A> _score: String, _score_tag: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -14633,7 +15188,7 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "games.scores.submit", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("leaderboardId", self._leaderboard_id.to_string())); params.push(("score", self._score.to_string())); if let Some(value) = self._score_tag { @@ -14642,7 +15197,10 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut, A: o if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "leaderboardId", "score", "scoreTag", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "leaderboardId", "score", "scoreTag", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -14791,6 +15349,13 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut, A: o self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ScoreSubmitCall<'a, C, A> { + self._consistency_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. /// @@ -14870,9 +15435,10 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.scores().list("leaderboardId", "collection", "timeSpan") -/// .page_token("sed") -/// .max_results(-16) -/// .language("gubergren") +/// .page_token("At") +/// .max_results(-96) +/// .language("et") +/// .consistency_token("sed") /// .doit(); /// # } /// ``` @@ -14886,6 +15452,7 @@ pub struct ScoreListCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -14907,7 +15474,7 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut, A: oau }; dlg.begin(MethodInfo { id: "games.scores.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); params.push(("leaderboardId", self._leaderboard_id.to_string())); params.push(("collection", self._collection.to_string())); params.push(("timeSpan", self._time_span.to_string())); @@ -14920,7 +15487,10 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut, A: oau if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "leaderboardId", "collection", "timeSpan", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "leaderboardId", "collection", "timeSpan", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15086,6 +15656,13 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut, A: oau self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ScoreListCall<'a, C, A> { + self._consistency_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. /// @@ -15166,10 +15743,11 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.scores().get("playerId", "leaderboardId", "timeSpan") -/// .page_token("sea") -/// .max_results(-85) -/// .language("ipsum") -/// .include_rank_type("aliquyam") +/// .page_token("nonumy") +/// .max_results(-15) +/// .language("Lorem") +/// .include_rank_type("Lorem") +/// .consistency_token("diam") /// .doit(); /// # } /// ``` @@ -15184,6 +15762,7 @@ pub struct ScoreGetCall<'a, C, A> _max_results: Option, _language: Option, _include_rank_type: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -15205,7 +15784,7 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut, A: oaut }; dlg.begin(MethodInfo { id: "games.scores.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); params.push(("playerId", self._player_id.to_string())); params.push(("leaderboardId", self._leaderboard_id.to_string())); params.push(("timeSpan", self._time_span.to_string())); @@ -15221,7 +15800,10 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut, A: oaut if let Some(value) = self._include_rank_type { params.push(("includeRankType", value.to_string())); } - for &field in ["alt", "playerId", "leaderboardId", "timeSpan", "pageToken", "maxResults", "language", "includeRankType"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "playerId", "leaderboardId", "timeSpan", "pageToken", "maxResults", "language", "includeRankType", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15394,6 +15976,13 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut, A: oaut self._include_rank_type = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ScoreGetCall<'a, C, A> { + self._consistency_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. /// @@ -15479,7 +16068,8 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.scores().submit_multiple(req) -/// .language("dolores") +/// .language("ut") +/// .consistency_token("ut") /// .doit(); /// # } /// ``` @@ -15489,6 +16079,7 @@ pub struct ScoreSubmitMultipleCall<'a, C, A> hub: &'a Games, _request: PlayerScoreSubmissionList, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -15510,11 +16101,14 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15639,6 +16233,13 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut ScoreSubmitMultipleCall<'a, C, A> { + self._consistency_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. /// @@ -15718,11 +16319,12 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -15759,7 +16362,7 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.scores.listWindow", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); params.push(("leaderboardId", self._leaderboard_id.to_string())); params.push(("collection", self._collection.to_string())); params.push(("timeSpan", self._time_span.to_string())); @@ -15778,7 +16381,10 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "leaderboardId", "collection", "timeSpan", "returnTopIfAbsent", "resultsAbove", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "leaderboardId", "collection", "timeSpan", "returnTopIfAbsent", "resultsAbove", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -15958,6 +16564,13 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut, self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> ScoreListWindowCall<'a, C, A> { + self._consistency_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. /// @@ -16043,6 +16656,7 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.pushtokens().remove(req) +/// .consistency_token("dolor") /// .doit(); /// # } /// ``` @@ -16051,6 +16665,7 @@ pub struct PushtokenRemoveCall<'a, C, A> hub: &'a Games, _request: PushTokenId, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -16072,8 +16687,11 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.pushtokens.remove", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - for &field in [].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -16180,6 +16798,13 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut, self._request = new_value; self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> PushtokenRemoveCall<'a, C, A> { + self._consistency_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. /// @@ -16265,6 +16890,7 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.pushtokens().update(req) +/// .consistency_token("et") /// .doit(); /// # } /// ``` @@ -16273,6 +16899,7 @@ pub struct PushtokenUpdateCall<'a, C, A> hub: &'a Games, _request: PushToken, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -16294,8 +16921,11 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "games.pushtokens.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); - for &field in [].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -16402,6 +17032,13 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut, self._request = new_value; self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> PushtokenUpdateCall<'a, C, A> { + self._consistency_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. /// @@ -16481,6 +17118,7 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.revisions().check("clientRevision") +/// .consistency_token("vero") /// .doit(); /// # } /// ``` @@ -16489,6 +17127,7 @@ pub struct RevisionCheckCall<'a, C, A> hub: &'a Games, _client_revision: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -16510,9 +17149,12 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "games.revisions.check", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("clientRevision", self._client_revision.to_string())); - for &field in ["alt", "clientRevision"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "clientRevision", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -16621,6 +17263,13 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut, A: self._client_revision = new_value.to_string(); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> RevisionCheckCall<'a, C, A> { + self._consistency_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. /// @@ -16700,9 +17349,10 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.events().list_definitions() -/// .page_token("justo") -/// .max_results(-57) -/// .language("clita") +/// .page_token("ut") +/// .max_results(-30) +/// .language("et") +/// .consistency_token("ipsum") /// .doit(); /// # } /// ``` @@ -16713,6 +17363,7 @@ pub struct EventListDefinitionCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -16734,7 +17385,7 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -16744,7 +17395,10 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut EventListDefinitionCall<'a, C, A> where C: BorrowMut EventListDefinitionCall<'a, C, A> { + self._consistency_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. /// @@ -16944,7 +17605,8 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut hub: &'a Games, _request: EventRecordRequest, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -16975,11 +17638,14 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut, A: o }; dlg.begin(MethodInfo { id: "games.events.record", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17104,6 +17770,13 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut, A: o self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> EventRecordCall<'a, C, A> { + self._consistency_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. /// @@ -17183,9 +17856,10 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.events().list_by_player() -/// .page_token("ut") -/// .max_results(-19) -/// .language("eos") +/// .page_token("vero") +/// .max_results(-99) +/// .language("takimata") +/// .consistency_token("et") /// .doit(); /// # } /// ``` @@ -17196,6 +17870,7 @@ pub struct EventListByPlayerCall<'a, C, A> _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -17217,7 +17892,7 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut }; dlg.begin(MethodInfo { id: "games.events.listByPlayer", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -17227,7 +17902,10 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut if let Some(value) = self._language { params.push(("language", value.to_string())); } - for &field in ["alt", "pageToken", "maxResults", "language"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["alt", "pageToken", "maxResults", "language", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17342,6 +18020,13 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut self._language = Some(new_value.to_string()); self } + /// The last-seen mutation timestamp. + /// + /// Sets the *consistency token* query property to the given value. + pub fn consistency_token(mut self, new_value: &str) -> EventListByPlayerCall<'a, C, A> { + self._consistency_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. /// @@ -17421,6 +18106,7 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.quest_milestones().claim("questId", "milestoneId", "requestId") +/// .consistency_token("no") /// .doit(); /// # } /// ``` @@ -17431,6 +18117,7 @@ pub struct QuestMilestoneClaimCall<'a, C, A> _quest_id: String, _milestone_id: String, _request_id: String, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -17452,11 +18139,14 @@ impl<'a, C, A> QuestMilestoneClaimCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("questId", self._quest_id.to_string())); params.push(("milestoneId", self._milestone_id.to_string())); params.push(("requestId", self._request_id.to_string())); - for &field in ["questId", "milestoneId", "requestId"].iter() { + if let Some(value) = self._consistency_token { + params.push(("consistencyToken", value.to_string())); + } + for &field in ["questId", "milestoneId", "requestId", "consistencyToken"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17590,6 +18280,13 @@ impl<'a, C, A> QuestMilestoneClaimCall<'a, C, A> where C: BorrowMut QuestMilestoneClaimCall<'a, C, A> { + self._consistency_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. /// @@ -17669,9 +18366,10 @@ impl<'a, C, A> QuestMilestoneClaimCall<'a, C, A> where C: BorrowMut _page_token: Option, _max_results: Option, _language: Option, + _consistency_token: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -17703,7 +18402,7 @@ impl<'a, C, A> AchievementDefinitionListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -17713,7 +18412,10 @@ impl<'a, C, A> AchievementDefinitionListCall<'a, C, A> where C: BorrowMut AchievementDefinitionListCall<'a, C, A> where C: BorrowMut AchievementDefinitionListCall<'a, C, A> { + self._consistency_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. /// diff --git a/gen/gamesconfiguration1_configuration-cli/Cargo.toml b/gen/gamesconfiguration1_configuration-cli/Cargo.toml index 149d862fb1..b56eced644 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+20160401" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "gamesconfiguration1-configuration" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-gamesconfiguration1_confi with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gamesconfiguration1_configuration/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gamesconfiguration1_configuration] diff --git a/gen/gamesconfiguration1_configuration-cli/README.md b/gen/gamesconfiguration1_configuration-cli/README.md index 1f440cc18c..f2cd023987 100644 --- a/gen/gamesconfiguration1_configuration-cli/README.md +++ b/gen/gamesconfiguration1_configuration-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Games Configuration* API at revision *20160401*. 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 *0.3.6*. ```bash gamesconfiguration1-configuration [options] diff --git a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml index cb79f44e32..4d5342d242 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+20160401 +site_name: Games Configuration v0.3.6+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 4bda9c9905..ac9b66dd15 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+20160401") + .version("0.3.6+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/gamesconfiguration1_configuration/Cargo.toml b/gen/gamesconfiguration1_configuration/Cargo.toml index 542b10434e..451bc79b1a 100644 --- a/gen/gamesconfiguration1_configuration/Cargo.toml +++ b/gen/gamesconfiguration1_configuration/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesconfiguration1_configuration" -version = "0.1.14+20160401" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/gamesconfiguration1_configuration/README.md b/gen/gamesconfiguration1_configuration/README.md index 34a2fb5dc0..f0126b0df0 100644 --- a/gen/gamesconfiguration1_configuration/README.md +++ b/gen/gamesconfiguration1_configuration/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gamesconfiguration1_configuration` library allows access to all features of the *Google Games Configuration* service. -This documentation was generated from *Games Configuration* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Games Configuration* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Games Configuration* *v1_configuration* API can be found at the [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesconfiguration1_configuration/src/lib.rs b/gen/gamesconfiguration1_configuration/src/lib.rs index 75019aed73..4cbb6921d1 100644 --- a/gen/gamesconfiguration1_configuration/src/lib.rs +++ b/gen/gamesconfiguration1_configuration/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games Configuration* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Games Configuration* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *gamesConfiguration:v1configuration* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Games Configuration* *v1_configuration* API can be found at the //! [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesmanagement1_management-cli/Cargo.toml b/gen/gamesmanagement1_management-cli/Cargo.toml index c5a43f65e1..439397d288 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+20160401" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "gamesmanagement1-management" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-gamesmanagement1_manageme with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gamesmanagement1_management/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gamesmanagement1_management] diff --git a/gen/gamesmanagement1_management-cli/README.md b/gen/gamesmanagement1_management-cli/README.md index 94b6a68e28..5ac9eb7dca 100644 --- a/gen/gamesmanagement1_management-cli/README.md +++ b/gen/gamesmanagement1_management-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Games Management* API at revision *20160401*. 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 *0.3.6*. ```bash gamesmanagement1-management [options] diff --git a/gen/gamesmanagement1_management-cli/mkdocs.yml b/gen/gamesmanagement1_management-cli/mkdocs.yml index 102234d9c1..efa96a2250 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+20160401 +site_name: Games Management v0.3.6+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 9a1802c459..fbb2e4f5f2 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+20160401") + .version("0.3.6+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/gamesmanagement1_management/Cargo.toml b/gen/gamesmanagement1_management/Cargo.toml index d1f2cbae6f..56a022ade8 100644 --- a/gen/gamesmanagement1_management/Cargo.toml +++ b/gen/gamesmanagement1_management/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gamesmanagement1_management" -version = "0.1.14+20160401" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/gamesmanagement1_management/README.md b/gen/gamesmanagement1_management/README.md index 82eadc7e75..1af9e9a548 100644 --- a/gen/gamesmanagement1_management/README.md +++ b/gen/gamesmanagement1_management/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gamesmanagement1_management` library allows access to all features of the *Google Games Management* service. -This documentation was generated from *Games Management* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Games Management* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Games Management* *v1_management* API can be found at the [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesmanagement1_management/src/lib.rs b/gen/gamesmanagement1_management/src/lib.rs index b2ece254d3..ec420ed920 100644 --- a/gen/gamesmanagement1_management/src/lib.rs +++ b/gen/gamesmanagement1_management/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Games Management* crate version *0.1.14+20160401*, where *20160401* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Games Management* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *gamesManagement:v1management* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Games Management* *v1_management* API can be found at the //! [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesmanagement1_management/src/lib.rs.in b/gen/gamesmanagement1_management/src/lib.rs.in index 8014c4caf5..083084aa08 100644 --- a/gen/gamesmanagement1_management/src/lib.rs.in +++ b/gen/gamesmanagement1_management/src/lib.rs.in @@ -206,6 +206,22 @@ pub struct AchievementResetResponse { impl ResponseResult for AchievementResetResponse {} +/// This is a JSON template for profile settings +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProfileSettings { + /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#profileSettings. + pub kind: Option, + /// The player's current profile visibility. This field is visible to both 1P and 3P APIs. + #[serde(rename="profileVisible")] + pub profile_visible: Option, +} + +impl Part for ProfileSettings {} + + /// An object representation of the individual components of the player's name. For some players, these fields may not be present. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -355,14 +371,17 @@ pub struct Player { /// The url to the portrait mode player banner image. #[serde(rename="bannerUrlPortrait")] pub banner_url_portrait: Option, - /// The player's title rewarded for their game activities. - pub title: Option, + /// The player's profile settings. Controls whether or not the player's profile is visible to other players. + #[serde(rename="profileSettings")] + pub profile_settings: Option, /// An object to represent Play Game experience information for the player. #[serde(rename="experienceInfo")] pub experience_info: Option, /// The url to the landscape mode player banner image. #[serde(rename="bannerUrlLandscape")] pub banner_url_landscape: Option, + /// The player's title rewarded for their game activities. + pub title: Option, /// The base URL for the image that represents the player. #[serde(rename="avatarImageUrl")] pub avatar_image_url: Option, diff --git a/gen/gan1_beta1-cli/Cargo.toml b/gen/gan1_beta1-cli/Cargo.toml index d068c081e5..2479a63a2f 100644 --- a/gen/gan1_beta1-cli/Cargo.toml +++ b/gen/gan1_beta1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "gan1-beta1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gan1_beta1] diff --git a/gen/gan1_beta1/Cargo.toml b/gen/gan1_beta1/Cargo.toml index 4bd1789237..aaa78f1242 100644 --- a/gen/gan1_beta1/Cargo.toml +++ b/gen/gan1_beta1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/genomics1-cli/Cargo.toml b/gen/genomics1-cli/Cargo.toml index 23f9f827b4..784cd7cd49 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+20160407" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "genomics1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-genomics1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-genomics1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-genomics1] diff --git a/gen/genomics1-cli/README.md b/gen/genomics1-cli/README.md index ed969f1119..1191c37250 100644 --- a/gen/genomics1-cli/README.md +++ b/gen/genomics1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *genomics* API at revision *20160407*. The CLI is at version *0.3.6*. +This documentation was generated from the *genomics* API at revision *20160905*. The CLI is at version *0.3.6*. ```bash genomics1 [options] diff --git a/gen/genomics1-cli/mkdocs.yml b/gen/genomics1-cli/mkdocs.yml index 952783fb1e..c29ae5a5a5 100644 --- a/gen/genomics1-cli/mkdocs.yml +++ b/gen/genomics1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: genomics v0.3.6+20160407 +site_name: genomics v0.3.6+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 bff684337b..be930811b1 100644 --- a/gen/genomics1-cli/src/main.rs +++ b/gen/genomics1-cli/src/main.rs @@ -68,8 +68,9 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "request-id" => Some(("requestId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec![]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["request-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3906,11 +3907,13 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reference-set-id" => Some(("referenceSetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-id" => Some(("datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "id", "reference-set-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "description", "id", "name", "reference-set-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -4186,11 +4189,13 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reference-set-id" => Some(("referenceSetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "dataset-id" => Some(("datasetId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "id", "reference-set-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["dataset-id", "description", "id", "name", "reference-set-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -4712,7 +4717,7 @@ fn main() { Some(false)), ]), ("create", - Some(r##"Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * `exons.start` * `exons.end` All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field."##), + Some(r##"Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * exons.start * exons.end All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field."##), "Details at http://byron.github.io/google-apis-rs/google_genomics1_cli/annotations_create", vec![ (Some(r##"kv"##), @@ -5413,7 +5418,7 @@ fn main() { Some(false)), ]), ("export", - Some(r##"Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See [ImportReadGroupSets](google.genomics.v1.ReadServiceV1.ImportReadGroupSets) for caveats."##), + Some(r##"Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See ImportReadGroupSets for caveats."##), "Details at http://byron.github.io/google-apis-rs/google_genomics1_cli/readgroupsets_export", vec![ (Some(r##"read-group-set-id"##), @@ -6035,8 +6040,8 @@ fn main() { let mut app = App::new("genomics1") .author("Sebastian Thiel ") - .version("0.3.6+20160407") - .about("Stores, processes, explores and shares genomic data. This API implements the Global Alliance for Genomics and Health (GA4GH) v0.5.1 API as well as several extensions.") + .version("0.3.6+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") .long("scope") diff --git a/gen/genomics1/Cargo.toml b/gen/genomics1/Cargo.toml index f7085fbfb2..b3d3882c91 100644 --- a/gen/genomics1/Cargo.toml +++ b/gen/genomics1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-genomics1" -version = "0.1.14+20160407" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/genomics1/README.md b/gen/genomics1/README.md index 62d444a26d..aa65090ebe 100644 --- a/gen/genomics1/README.md +++ b/gen/genomics1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-genomics1` library allows access to all features of the *Google genomics* service. -This documentation was generated from *genomics* crate version *0.1.14+20160407*, where *20160407* is the exact revision of the *genomics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *genomics* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *genomics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *genomics* *v1* API can be found at the [official documentation site](https://cloud.google.com/genomics/). diff --git a/gen/genomics1/src/lib.rs b/gen/genomics1/src/lib.rs index e05c1a3973..982e5d9a6a 100644 --- a/gen/genomics1/src/lib.rs +++ b/gen/genomics1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *genomics* crate version *0.1.14+20160407*, where *20160407* is the exact revision of the *genomics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *genomics* crate version *0.1.14+20160905*, where *20160905* is the exact revision of the *genomics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *genomics* *v1* API can be found at the //! [official documentation site](https://cloud.google.com/genomics/). diff --git a/gen/genomics1/src/lib.rs.in b/gen/genomics1/src/lib.rs.in index 62d088302c..e45cc5dee6 100644 --- a/gen/genomics1/src/lib.rs.in +++ b/gen/genomics1/src/lib.rs.in @@ -279,7 +279,7 @@ impl RequestValue for SearchVariantSetsRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExportReadGroupSetRequest { - /// Required. The Google Developers Console project ID that owns this export. The caller must have WRITE access to this project. + /// Required. The Google Cloud project ID that owns this export. The caller must have WRITE access to this project. #[serde(rename="projectId")] pub project_id: Option, /// The reference names to export. If this is not specified, all reference sequences, including unmapped reads, are exported. Use `*` to export only unmapped reads. @@ -528,13 +528,13 @@ impl ResponseResult for SearchAnnotationsResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Transcript { - /// The range of the coding sequence for this transcript, if any. To determine the exact ranges of coding sequence, intersect this range with those of the `exons`, if any. If there are any `exons`, the `codingSequence` must start and end within them. Note that in some cases, the reference genome will not exactly match the observed mRNA transcript e.g. due to variance in the source genome from reference. In these cases, `exon.frame` will not necessarily match the expected reference reading frame and coding exon reference bases cannot necessarily be concatenated to produce the original transcript mRNA. + /// The range of the coding sequence for this transcript, if any. To determine the exact ranges of coding sequence, intersect this range with those of the exons, if any. If there are any exons, the codingSequence must start and end within them. Note that in some cases, the reference genome will not exactly match the observed mRNA transcript e.g. due to variance in the source genome from reference. In these cases, exon.frame will not necessarily match the expected reference reading frame and coding exon reference bases cannot necessarily be concatenated to produce the original transcript mRNA. #[serde(rename="codingSequence")] pub coding_sequence: Option, /// The annotation ID of the gene from which this transcript is transcribed. #[serde(rename="geneId")] pub gene_id: Option, - /// The exons that compose this transcript. This field should be unset for genomes where transcript splicing does not occur, for example prokaryotes. Introns are regions of the transcript that are not included in the spliced RNA product. Though not explicitly modeled here, intron ranges can be deduced; all regions of this transcript that are not exons are introns. Exonic sequences do not necessarily code for a translational product (amino acids). Only the regions of exons bounded by the `codingSequence` correspond to coding DNA sequence. Exons are ordered by start position and may not overlap. + /// The exons that compose this transcript. This field should be unset for genomes where transcript splicing does not occur, for example prokaryotes. Introns are regions of the transcript that are not included in the spliced RNA product. Though not explicitly modeled here, intron ranges can be deduced; all regions of this transcript that are not exons are introns. Exonic sequences do not necessarily code for a translational product (amino acids). Only the regions of exons bounded by the codingSequence correspond to coding DNA sequence. Exons are ordered by start position and may not overlap. pub exons: Option>, } @@ -1193,7 +1193,7 @@ pub struct SearchVariantsRequest { pub max_calls: Option, /// The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. If unspecified, defaults to 0. pub start: Option, - /// Only return variant calls which belong to call sets with these ids. Leaving this blank returns all variant calls. If a variant has no calls belonging to any of these call sets, it won't be returned at all. Currently, variants with no calls from any call set will never be returned. + /// Only return variant calls which belong to call sets with these ids. Leaving this blank returns all variant calls. If a variant has no calls belonging to any of these call sets, it won't be returned at all. #[serde(rename="callSetIds")] pub call_set_ids: Option>, /// Only return variants which have exactly this name. @@ -1360,7 +1360,7 @@ impl ResponseResult for SearchAnnotationSetsResponse {} pub struct Exon { /// The start position of the exon on this annotation's reference sequence, 0-based inclusive. Note that this is relative to the reference start, and **not** the containing annotation start. pub start: Option, - /// The frame of this exon. Contains a value of 0, 1, or 2, which indicates the offset of the first coding base of the exon within the reading frame of the coding DNA sequence, if any. This field is dependent on the strandedness of this annotation (see Annotation.reverse_strand). For forward stranded annotations, this offset is relative to the `exon.start`. For reverse strand annotations, this offset is relative to the `exon.end - 1`. Unset if this exon does not intersect the coding sequence. Upon creation of a transcript, the frame must be populated for all or none of the coding exons. + /// The frame of this exon. Contains a value of 0, 1, or 2, which indicates the offset of the first coding base of the exon within the reading frame of the coding DNA sequence, if any. This field is dependent on the strandedness of this annotation (see Annotation.reverse_strand). For forward stranded annotations, this offset is relative to the exon.start. For reverse strand annotations, this offset is relative to the exon.end `- 1`. Unset if this exon does not intersect the coding sequence. Upon creation of a transcript, the frame must be populated for all or none of the coding exons. pub frame: Option, /// The end position of the exon on this annotation's reference sequence, 0-based exclusive. Note that this is relative to the reference start, and *not* the containing annotation start. pub end: Option, @@ -1418,6 +1418,9 @@ impl Part for CodingSequence {} pub struct BatchCreateAnnotationsRequest { /// The annotations to be created. At most 4096 can be specified in a single request. pub annotations: Option>, + /// A unique request ID which enables the server to detect duplicated requests. If provided, duplicated requests will result in the same response; if not provided, duplicated requests may result in duplicated data. For a given annotation set, callers should not reuse `request_id`s when writing different batches of annotations - behavior in this case is undefined. A common approach is to use a UUID. For batch jobs where worker crashes are a possibility, consider using some unique variant of a worker or run ID. + #[serde(rename="requestId")] + pub request_id: Option, } impl RequestValue for BatchCreateAnnotationsRequest {} @@ -1496,9 +1499,13 @@ impl ResponseResult for ReferenceSet {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VariantSet { + /// User-specified, mutable name. + pub name: Option, /// A list of all references used by the variants in a variant set with associated coordinate upper bounds for each one. #[serde(rename="referenceBounds")] pub reference_bounds: Option>, + /// The metadata associated with this variant set. + pub metadata: Option>, /// The reference set to which the variant set is mapped. The reference set describes the alignment provenance of the variant set, while the `referenceBounds` describe the shape of the actual variant data. The reference set's reference names are a superset of those found in the `referenceBounds`. For example, given a variant set that is mapped to the GRCh38 reference set and contains a single variant on reference 'X', `referenceBounds` would contain only an entry for 'X', while the associated reference set enumerates all possible references: '1', '2', 'X', 'Y', 'MT', etc. #[serde(rename="referenceSetId")] pub reference_set_id: Option, @@ -1507,8 +1514,8 @@ pub struct VariantSet { /// The dataset to which this variant set belongs. #[serde(rename="datasetId")] pub dataset_id: Option, - /// The metadata associated with this variant set. - pub metadata: Option>, + /// A textual description of this variant set. + pub description: Option, } impl RequestValue for VariantSet {} @@ -1711,7 +1718,7 @@ pub struct StreamVariantsRequest { /// Required. Only return variants in this reference sequence. #[serde(rename="referenceName")] pub reference_name: Option, - /// The Google Developers Console project ID or number which will be billed for this access. The caller must have WRITE access to this project. Required. + /// The Google Cloud project ID which will be billed for this access. The caller must have WRITE access to this project. Required. #[serde(rename="projectId")] pub project_id: Option, /// Only return variant calls which belong to call sets with these IDs. Leaving this blank returns all variant calls. @@ -1782,7 +1789,7 @@ pub struct StreamReadsRequest { /// The reference sequence name, for example `chr1`, `1`, or `chrX`. If set to *, only unmapped reads are returned. #[serde(rename="referenceName")] pub reference_name: Option, - /// The Google Developers Console project ID or number which will be billed for this access. The caller must have WRITE access to this project. Required. + /// The Google Cloud project ID which will be billed for this access. The caller must have WRITE access to this project. Required. #[serde(rename="projectId")] pub project_id: Option, /// Restricts results to a shard containing approximately `1/totalShards` of the normal response payload for this query. Results from a sharded request are disjoint from those returned by all queries which differ only in their shard parameter. A shard may yield 0 results; this is especially likely for large values of `totalShards`. Valid values are `[0, totalShards)`. @@ -1907,7 +1914,7 @@ impl Part for CigarUnit {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Dataset { - /// The Google Developers Console project ID that this dataset belongs to. + /// The Google Cloud project ID that this dataset belongs to. #[serde(rename="projectId")] pub project_id: Option, /// The server-generated dataset ID, unique across all datasets. @@ -2673,7 +2680,7 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See [ImportReadGroupSets](google.genomics.v1.ReadServiceV1.ImportReadGroupSets) for caveats. + /// Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See ImportReadGroupSets for caveats. /// /// # Arguments /// @@ -3191,7 +3198,7 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * `exons.start` * `exons.end` All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field. + /// Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * exons.start * exons.end All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field. /// /// # Arguments /// @@ -6021,7 +6028,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o } - /// Required. The project to list datasets for. + /// Required. The Google Cloud project ID to list datasets for. /// /// Sets the *project id* query property to the given value. pub fn project_id(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { @@ -8862,7 +8869,7 @@ impl<'a, C, A> ReadStreamCall<'a, C, A> where C: BorrowMut, A: oa } -/// Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See [ImportReadGroupSets](google.genomics.v1.ReadServiceV1.ImportReadGroupSets) for caveats. +/// Exports a read group set to a BAM file in Google Cloud Storage. For the definitions of read group sets and other genomics resources, see [Fundamentals of Google Genomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics) Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. See ImportReadGroupSets for caveats. /// /// A builder for the *export* method supported by a *readgroupset* resource. /// It is not used directly, but through a `ReadgroupsetMethods` instance. @@ -14426,7 +14433,7 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut, } -/// Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * `exons.start` * `exons.end` All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field. +/// Creates a new annotation. Caller must have WRITE permission for the associated annotation set. The following fields are required: * annotationSetId * referenceName or referenceId ### Transcripts For annotations of type TRANSCRIPT, the following fields of transcript must be provided: * exons.start * exons.end All other fields may be optionally specified, unless documented as being server-generated (for example, the `id` field). The annotated range must be no longer than 100Mbp (mega base pairs). See the Annotation resource for additional restrictions on each field. /// /// A builder for the *create* method supported by a *annotation* resource. /// It is not used directly, but through a `AnnotationMethods` instance. @@ -17119,7 +17126,7 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut, self._variant_set_id = new_value.to_string(); self } - /// An optional mask specifying which fields to update. Supported fields: * metadata. Leaving `updateMask` unset is equivalent to specifying all mutable fields. + /// An optional mask specifying which fields to update. Supported fields: * metadata. * name. * description. Leaving `updateMask` unset is equivalent to specifying all mutable fields. /// /// Sets the *update mask* query property to the given value. pub fn update_mask(mut self, new_value: &str) -> VariantsetPatchCall<'a, C, A> { diff --git a/gen/gmail1-cli/Cargo.toml b/gen/gmail1-cli/Cargo.toml index 5c9029788d..12e66a3a33 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+20160316" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "gmail1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-gmail1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-gmail1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-gmail1] diff --git a/gen/gmail1-cli/README.md b/gen/gmail1-cli/README.md index 2ff3acd7e7..309b4bf9c0 100644 --- a/gen/gmail1-cli/README.md +++ b/gen/gmail1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *gmail* API at revision *20160316*. The CLI is at version *0.3.6*. +This documentation was generated from the *gmail* API at revision *20160711*. The CLI is at version *0.3.6*. ```bash gmail1 [options] @@ -54,6 +54,29 @@ gmail1 [options] messages-send (-r )... (-u (simple|resumable) -f [-m ]) [-p ]... [-o ] messages-trash [-p ]... [-o ] messages-untrash [-p ]... [-o ] + settings-filters-create (-r )... [-p ]... [-o ] + settings-filters-delete [-p ]... + settings-filters-get [-p ]... [-o ] + settings-filters-list [-p ]... [-o ] + settings-forwarding-addresses-create (-r )... [-p ]... [-o ] + settings-forwarding-addresses-delete [-p ]... + settings-forwarding-addresses-get [-p ]... [-o ] + settings-forwarding-addresses-list [-p ]... [-o ] + settings-get-auto-forwarding [-p ]... [-o ] + settings-get-imap [-p ]... [-o ] + settings-get-pop [-p ]... [-o ] + settings-get-vacation [-p ]... [-o ] + settings-send-as-create (-r )... [-p ]... [-o ] + settings-send-as-delete [-p ]... + settings-send-as-get [-p ]... [-o ] + settings-send-as-list [-p ]... [-o ] + settings-send-as-patch (-r )... [-p ]... [-o ] + settings-send-as-update (-r )... [-p ]... [-o ] + settings-send-as-verify [-p ]... + settings-update-auto-forwarding (-r )... [-p ]... [-o ] + settings-update-imap (-r )... [-p ]... [-o ] + settings-update-pop (-r )... [-p ]... [-o ] + settings-update-vacation (-r )... [-p ]... [-o ] stop [-p ]... threads-delete [-p ]... threads-get [-p ]... [-o ] diff --git a/gen/gmail1-cli/mkdocs.yml b/gen/gmail1-cli/mkdocs.yml index 91af9a5a4b..0c6b572165 100644 --- a/gen/gmail1-cli/mkdocs.yml +++ b/gen/gmail1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: gmail v0.3.6+20160316 +site_name: gmail v0.3.6+20160711 site_url: http://byron.github.io/google-apis-rs/google-gmail1-cli site_description: Write integrating applications with bcore @@ -34,6 +34,29 @@ pages: - ['users_messages-send.md', 'Users', 'Messages Send'] - ['users_messages-trash.md', 'Users', 'Messages Trash'] - ['users_messages-untrash.md', 'Users', 'Messages Untrash'] +- ['users_settings-filters-create.md', 'Users', 'Settings Filters Create'] +- ['users_settings-filters-delete.md', 'Users', 'Settings Filters Delete'] +- ['users_settings-filters-get.md', 'Users', 'Settings Filters Get'] +- ['users_settings-filters-list.md', 'Users', 'Settings Filters List'] +- ['users_settings-forwarding-addresses-create.md', 'Users', 'Settings Forwarding Addresses Create'] +- ['users_settings-forwarding-addresses-delete.md', 'Users', 'Settings Forwarding Addresses Delete'] +- ['users_settings-forwarding-addresses-get.md', 'Users', 'Settings Forwarding Addresses Get'] +- ['users_settings-forwarding-addresses-list.md', 'Users', 'Settings Forwarding Addresses List'] +- ['users_settings-get-auto-forwarding.md', 'Users', 'Settings Get Auto Forwarding'] +- ['users_settings-get-imap.md', 'Users', 'Settings Get Imap'] +- ['users_settings-get-pop.md', 'Users', 'Settings Get Pop'] +- ['users_settings-get-vacation.md', 'Users', 'Settings Get Vacation'] +- ['users_settings-send-as-create.md', 'Users', 'Settings Send As Create'] +- ['users_settings-send-as-delete.md', 'Users', 'Settings Send As Delete'] +- ['users_settings-send-as-get.md', 'Users', 'Settings Send As Get'] +- ['users_settings-send-as-list.md', 'Users', 'Settings Send As List'] +- ['users_settings-send-as-patch.md', 'Users', 'Settings Send As Patch'] +- ['users_settings-send-as-update.md', 'Users', 'Settings Send As Update'] +- ['users_settings-send-as-verify.md', 'Users', 'Settings Send As Verify'] +- ['users_settings-update-auto-forwarding.md', 'Users', 'Settings Update Auto Forwarding'] +- ['users_settings-update-imap.md', 'Users', 'Settings Update Imap'] +- ['users_settings-update-pop.md', 'Users', 'Settings Update Pop'] +- ['users_settings-update-vacation.md', 'Users', 'Settings Update Vacation'] - ['users_stop.md', 'Users', 'Stop'] - ['users_threads-delete.md', 'Users', 'Threads Delete'] - ['users_threads-get.md', 'Users', 'Threads Get'] diff --git a/gen/gmail1-cli/src/main.rs b/gen/gmail1-cli/src/main.rs index cf2a91c7ef..70bdbb9d72 100644 --- a/gen/gmail1-cli/src/main.rs +++ b/gen/gmail1-cli/src/main.rs @@ -254,6 +254,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "q" => { + call = call.q(value.unwrap_or("")); + }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, @@ -276,7 +279,7 @@ impl<'n> Engine<'n> { 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", "max-results", "include-spam-trash"].iter().map(|v|*v)); + v.extend(["q", "page-token", "max-results", "include-spam-trash"].iter().map(|v|*v)); v } )); } } @@ -1876,6 +1879,1529 @@ impl<'n> Engine<'n> { } } + fn _users_settings_filters_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()[..] { + "action.forward" => Some(("action.forward", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "action.remove-label-ids" => Some(("action.removeLabelIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "action.add-label-ids" => Some(("action.addLabelIds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.from" => Some(("criteria.from", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.has-attachment" => Some(("criteria.hasAttachment", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "criteria.subject" => Some(("criteria.subject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.size-comparison" => Some(("criteria.sizeComparison", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.to" => Some(("criteria.to", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.query" => Some(("criteria.query", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.exclude-chats" => Some(("criteria.excludeChats", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "criteria.negated-query" => Some(("criteria.negatedQuery", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "criteria.size" => Some(("criteria.size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "add-label-ids", "criteria", "exclude-chats", "forward", "from", "has-attachment", "id", "negated-query", "query", "remove-label-ids", "size", "size-comparison", "subject", "to"]); + 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::Filter = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_filters_create(request, opt.value_of("user-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 _users_settings_filters_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_filters_delete(opt.value_of("user-id").unwrap_or(""), opt.value_of("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); + } + match match protocol { + CallType::Standard => call.doit(), + _ => unreachable!() + } { + Err(api_err) => Err(DoitError::ApiError(api_err)), + Ok(mut response) => { + Ok(()) + } + } + } + } + + fn _users_settings_filters_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_filters_get(opt.value_of("user-id").unwrap_or(""), opt.value_of("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 _users_settings_filters_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_filters_list(opt.value_of("user-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 _users_settings_forwarding_addresses_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()[..] { + "forwarding-email" => Some(("forwardingEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "verification-status" => Some(("verificationStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["forwarding-email", "verification-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::ForwardingAddress = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_forwarding_addresses_create(request, opt.value_of("user-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 _users_settings_forwarding_addresses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_forwarding_addresses_delete(opt.value_of("user-id").unwrap_or(""), opt.value_of("forwarding-email").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 _users_settings_forwarding_addresses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_forwarding_addresses_get(opt.value_of("user-id").unwrap_or(""), opt.value_of("forwarding-email").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 _users_settings_forwarding_addresses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_forwarding_addresses_list(opt.value_of("user-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 _users_settings_get_auto_forwarding(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_get_auto_forwarding(opt.value_of("user-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 _users_settings_get_imap(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_get_imap(opt.value_of("user-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 _users_settings_get_pop(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_get_pop(opt.value_of("user-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 _users_settings_get_vacation(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_get_vacation(opt.value_of("user-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 _users_settings_send_as_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()[..] { + "smtp-msa.username" => Some(("smtpMsa.username", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.host" => Some(("smtpMsa.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.password" => Some(("smtpMsa.password", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.security-mode" => Some(("smtpMsa.securityMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.port" => Some(("smtpMsa.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reply-to-address" => Some(("replyToAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "signature" => Some(("signature", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "treat-as-alias" => Some(("treatAsAlias", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "send-as-email" => Some(("sendAsEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-primary" => Some(("isPrimary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "verification-status" => Some(("verificationStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-default" => Some(("isDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["display-name", "host", "is-default", "is-primary", "password", "port", "reply-to-address", "security-mode", "send-as-email", "signature", "smtp-msa", "treat-as-alias", "username", "verification-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::SendAs = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_send_as_create(request, opt.value_of("user-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 _users_settings_send_as_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_send_as_delete(opt.value_of("user-id").unwrap_or(""), opt.value_of("send-as-email").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 _users_settings_send_as_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_send_as_get(opt.value_of("user-id").unwrap_or(""), opt.value_of("send-as-email").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 _users_settings_send_as_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_send_as_list(opt.value_of("user-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 _users_settings_send_as_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()[..] { + "smtp-msa.username" => Some(("smtpMsa.username", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.host" => Some(("smtpMsa.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.password" => Some(("smtpMsa.password", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.security-mode" => Some(("smtpMsa.securityMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.port" => Some(("smtpMsa.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reply-to-address" => Some(("replyToAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "signature" => Some(("signature", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "treat-as-alias" => Some(("treatAsAlias", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "send-as-email" => Some(("sendAsEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-primary" => Some(("isPrimary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "verification-status" => Some(("verificationStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-default" => Some(("isDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["display-name", "host", "is-default", "is-primary", "password", "port", "reply-to-address", "security-mode", "send-as-email", "signature", "smtp-msa", "treat-as-alias", "username", "verification-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::SendAs = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_send_as_patch(request, opt.value_of("user-id").unwrap_or(""), opt.value_of("send-as-email").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 _users_settings_send_as_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()[..] { + "smtp-msa.username" => Some(("smtpMsa.username", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.host" => Some(("smtpMsa.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.password" => Some(("smtpMsa.password", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.security-mode" => Some(("smtpMsa.securityMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "smtp-msa.port" => Some(("smtpMsa.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "reply-to-address" => Some(("replyToAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "signature" => Some(("signature", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "treat-as-alias" => Some(("treatAsAlias", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "send-as-email" => Some(("sendAsEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-primary" => Some(("isPrimary", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "verification-status" => Some(("verificationStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "is-default" => Some(("isDefault", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["display-name", "host", "is-default", "is-primary", "password", "port", "reply-to-address", "security-mode", "send-as-email", "signature", "smtp-msa", "treat-as-alias", "username", "verification-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::SendAs = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_send_as_update(request, opt.value_of("user-id").unwrap_or(""), opt.value_of("send-as-email").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 _users_settings_send_as_verify(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.users().settings_send_as_verify(opt.value_of("user-id").unwrap_or(""), opt.value_of("send-as-email").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 _users_settings_update_auto_forwarding(&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()[..] { + "enabled" => Some(("enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "email-address" => Some(("emailAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "disposition" => Some(("disposition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["disposition", "email-address", "enabled"]); + 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::AutoForwarding = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_update_auto_forwarding(request, opt.value_of("user-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 _users_settings_update_imap(&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()[..] { + "auto-expunge" => Some(("autoExpunge", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "expunge-behavior" => Some(("expungeBehavior", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enabled" => Some(("enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "max-folder-size" => Some(("maxFolderSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-expunge", "enabled", "expunge-behavior", "max-folder-size"]); + 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::ImapSettings = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_update_imap(request, opt.value_of("user-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 _users_settings_update_pop(&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()[..] { + "disposition" => Some(("disposition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "access-window" => Some(("accessWindow", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["access-window", "disposition"]); + 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::PopSettings = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_update_pop(request, opt.value_of("user-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 _users_settings_update_vacation(&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()[..] { + "response-subject" => Some(("responseSubject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "response-body-plain-text" => Some(("responseBodyPlainText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "restrict-to-contacts" => Some(("restrictToContacts", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "enable-auto-reply" => Some(("enableAutoReply", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "response-body-html" => Some(("responseBodyHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "restrict-to-domain" => Some(("restrictToDomain", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["enable-auto-reply", "end-time", "response-body-html", "response-body-plain-text", "response-subject", "restrict-to-contacts", "restrict-to-domain", "start-time"]); + 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::VacationSettings = json::value::from_value(object).unwrap(); + let mut call = self.hub.users().settings_update_vacation(request, opt.value_of("user-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 _users_stop(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.users().stop(opt.value_of("user-id").unwrap_or("")); @@ -2450,6 +3976,75 @@ impl<'n> Engine<'n> { ("messages-untrash", Some(opt)) => { call_result = self._users_messages_untrash(opt, dry_run, &mut err); }, + ("settings-filters-create", Some(opt)) => { + call_result = self._users_settings_filters_create(opt, dry_run, &mut err); + }, + ("settings-filters-delete", Some(opt)) => { + call_result = self._users_settings_filters_delete(opt, dry_run, &mut err); + }, + ("settings-filters-get", Some(opt)) => { + call_result = self._users_settings_filters_get(opt, dry_run, &mut err); + }, + ("settings-filters-list", Some(opt)) => { + call_result = self._users_settings_filters_list(opt, dry_run, &mut err); + }, + ("settings-forwarding-addresses-create", Some(opt)) => { + call_result = self._users_settings_forwarding_addresses_create(opt, dry_run, &mut err); + }, + ("settings-forwarding-addresses-delete", Some(opt)) => { + call_result = self._users_settings_forwarding_addresses_delete(opt, dry_run, &mut err); + }, + ("settings-forwarding-addresses-get", Some(opt)) => { + call_result = self._users_settings_forwarding_addresses_get(opt, dry_run, &mut err); + }, + ("settings-forwarding-addresses-list", Some(opt)) => { + call_result = self._users_settings_forwarding_addresses_list(opt, dry_run, &mut err); + }, + ("settings-get-auto-forwarding", Some(opt)) => { + call_result = self._users_settings_get_auto_forwarding(opt, dry_run, &mut err); + }, + ("settings-get-imap", Some(opt)) => { + call_result = self._users_settings_get_imap(opt, dry_run, &mut err); + }, + ("settings-get-pop", Some(opt)) => { + call_result = self._users_settings_get_pop(opt, dry_run, &mut err); + }, + ("settings-get-vacation", Some(opt)) => { + call_result = self._users_settings_get_vacation(opt, dry_run, &mut err); + }, + ("settings-send-as-create", Some(opt)) => { + call_result = self._users_settings_send_as_create(opt, dry_run, &mut err); + }, + ("settings-send-as-delete", Some(opt)) => { + call_result = self._users_settings_send_as_delete(opt, dry_run, &mut err); + }, + ("settings-send-as-get", Some(opt)) => { + call_result = self._users_settings_send_as_get(opt, dry_run, &mut err); + }, + ("settings-send-as-list", Some(opt)) => { + call_result = self._users_settings_send_as_list(opt, dry_run, &mut err); + }, + ("settings-send-as-patch", Some(opt)) => { + call_result = self._users_settings_send_as_patch(opt, dry_run, &mut err); + }, + ("settings-send-as-update", Some(opt)) => { + call_result = self._users_settings_send_as_update(opt, dry_run, &mut err); + }, + ("settings-send-as-verify", Some(opt)) => { + call_result = self._users_settings_send_as_verify(opt, dry_run, &mut err); + }, + ("settings-update-auto-forwarding", Some(opt)) => { + call_result = self._users_settings_update_auto_forwarding(opt, dry_run, &mut err); + }, + ("settings-update-imap", Some(opt)) => { + call_result = self._users_settings_update_imap(opt, dry_run, &mut err); + }, + ("settings-update-pop", Some(opt)) => { + call_result = self._users_settings_update_pop(opt, dry_run, &mut err); + }, + ("settings-update-vacation", Some(opt)) => { + call_result = self._users_settings_update_vacation(opt, dry_run, &mut err); + }, ("stop", Some(opt)) => { call_result = self._users_stop(opt, dry_run, &mut err); }, @@ -2563,7 +4158,7 @@ fn main() { let mut exit_status = 0i32; let upload_value_names = ["mode", "file"]; let arg_data = [ - ("users", "methods: 'drafts-create', 'drafts-delete', 'drafts-get', 'drafts-list', 'drafts-send', 'drafts-update', 'get-profile', 'history-list', 'labels-create', 'labels-delete', 'labels-get', 'labels-list', 'labels-patch', 'labels-update', 'messages-attachments-get', 'messages-batch-delete', 'messages-delete', 'messages-get', 'messages-import', 'messages-insert', 'messages-list', 'messages-modify', 'messages-send', 'messages-trash', 'messages-untrash', 'stop', 'threads-delete', 'threads-get', 'threads-list', 'threads-modify', 'threads-trash', 'threads-untrash' and 'watch'", vec![ + ("users", "methods: 'drafts-create', 'drafts-delete', 'drafts-get', 'drafts-list', 'drafts-send', 'drafts-update', 'get-profile', 'history-list', 'labels-create', 'labels-delete', 'labels-get', 'labels-list', 'labels-patch', 'labels-update', 'messages-attachments-get', 'messages-batch-delete', 'messages-delete', 'messages-get', 'messages-import', 'messages-insert', 'messages-list', 'messages-modify', 'messages-send', 'messages-trash', 'messages-untrash', 'settings-filters-create', 'settings-filters-delete', 'settings-filters-get', 'settings-filters-list', 'settings-forwarding-addresses-create', 'settings-forwarding-addresses-delete', 'settings-forwarding-addresses-get', 'settings-forwarding-addresses-list', 'settings-get-auto-forwarding', 'settings-get-imap', 'settings-get-pop', 'settings-get-vacation', 'settings-send-as-create', 'settings-send-as-delete', 'settings-send-as-get', 'settings-send-as-list', 'settings-send-as-patch', 'settings-send-as-update', 'settings-send-as-verify', 'settings-update-auto-forwarding', 'settings-update-imap', 'settings-update-pop', 'settings-update-vacation', 'stop', 'threads-delete', 'threads-get', 'threads-list', 'threads-modify', 'threads-trash', 'threads-untrash' and 'watch'", vec![ ("drafts-create", Some(r##"Creates a new draft with the DRAFT label."##), "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_drafts-create", @@ -3270,6 +4865,596 @@ fn main() { 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)), + ]), + ("settings-filters-create", + Some(r##"Creates a filter."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-filters-create", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-filters-delete", + Some(r##"Deletes a filter."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-filters-delete", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"The ID of the filter to be deleted."##), + 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)), + ]), + ("settings-filters-get", + Some(r##"Gets a filter."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-filters-get", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"id"##), + None, + Some(r##"The ID of the filter to be fetched."##), + 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)), + ]), + ("settings-filters-list", + Some(r##"Lists the message filters of a Gmail user."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-filters-list", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-forwarding-addresses-create", + Some(r##"Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-forwarding-addresses-create", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-forwarding-addresses-delete", + Some(r##"Deletes the specified forwarding address and revokes any verification that may have been required."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-forwarding-addresses-delete", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"forwarding-email"##), + None, + Some(r##"The forwarding address to be deleted."##), + 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)), + ]), + ("settings-forwarding-addresses-get", + Some(r##"Gets the specified forwarding address."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-forwarding-addresses-get", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"forwarding-email"##), + None, + Some(r##"The forwarding address to be retrieved."##), + 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)), + ]), + ("settings-forwarding-addresses-list", + Some(r##"Lists the forwarding addresses for the specified account."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-forwarding-addresses-list", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-get-auto-forwarding", + Some(r##"Gets the auto-forwarding setting for the specified account."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-get-auto-forwarding", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-get-imap", + Some(r##"Gets IMAP settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-get-imap", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-get-pop", + Some(r##"Gets POP settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-get-pop", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-get-vacation", + Some(r##"Gets vacation responder settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-get-vacation", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-send-as-create", + Some(r##"Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-create", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-send-as-delete", + Some(r##"Deletes the specified send-as alias. Revokes any verification that may have been required for using it."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-delete", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"send-as-email"##), + None, + Some(r##"The send-as alias to be deleted."##), + 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)), + ]), + ("settings-send-as-get", + Some(r##"Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-get", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"send-as-email"##), + None, + Some(r##"The send-as alias to be retrieved."##), + 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)), + ]), + ("settings-send-as-list", + Some(r##"Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-list", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-send-as-patch", + Some(r##"Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. This method supports patch semantics."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-patch", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"send-as-email"##), + None, + Some(r##"The send-as alias to be 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)), + ]), + ("settings-send-as-update", + Some(r##"Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-update", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"send-as-email"##), + None, + Some(r##"The send-as alias to be 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)), + ]), + ("settings-send-as-verify", + Some(r##"Sends a verification email to the specified send-as alias address. The verification status must be pending."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-send-as-verify", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + Some(true), + Some(false)), + + (Some(r##"send-as-email"##), + None, + Some(r##"The send-as alias to be verified."##), + 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)), + ]), + ("settings-update-auto-forwarding", + Some(r##"Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-update-auto-forwarding", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-update-imap", + Some(r##"Updates IMAP settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-update-imap", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-update-pop", + Some(r##"Updates POP settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-update-pop", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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)), + ]), + ("settings-update-vacation", + Some(r##"Updates vacation responder settings."##), + "Details at http://byron.github.io/google-apis-rs/google_gmail1_cli/users_settings-update-vacation", + vec![ + (Some(r##"user-id"##), + None, + Some(r##"User's email address. The special value "me" can be used to indicate the authenticated user."##), + 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"##), @@ -3488,7 +5673,7 @@ fn main() { let mut app = App::new("gmail1") .author("Sebastian Thiel ") - .version("0.3.6+20160316") + .version("0.3.6+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/gmail1/Cargo.toml b/gen/gmail1/Cargo.toml index 2f0924aa3a..b81f4ab392 100644 --- a/gen/gmail1/Cargo.toml +++ b/gen/gmail1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-gmail1" -version = "0.1.14+20160316" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/gmail1/README.md b/gen/gmail1/README.md index 1a13440d2f..aaeef62927 100644 --- a/gen/gmail1/README.md +++ b/gen/gmail1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-gmail1` library allows access to all features of the *Google gmail* service. -This documentation was generated from *gmail* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *gmail* crate version *0.1.14+20160711*, where *20160711* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *gmail* *v1* API can be found at the [official documentation site](https://developers.google.com/gmail/api/). @@ -14,7 +14,7 @@ Everything else about the *gmail* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_gmail1/struct.Gmail.html) ... * users - * [*drafts create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftCreateCall.html), [*drafts delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftDeleteCall.html), [*drafts get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftGetCall.html), [*drafts list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftListCall.html), [*drafts send*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftSendCall.html), [*drafts update*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftUpdateCall.html), [*get profile*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserGetProfileCall.html), [*history list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserHistoryListCall.html), [*labels create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelCreateCall.html), [*labels delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelDeleteCall.html), [*labels get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelGetCall.html), [*labels list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelListCall.html), [*labels patch*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelPatchCall.html), [*labels update*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelUpdateCall.html), [*messages attachments get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageAttachmentGetCall.html), [*messages batch delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageBatchDeleteCall.html), [*messages delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageDeleteCall.html), [*messages get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageGetCall.html), [*messages import*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageImportCall.html), [*messages insert*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageInsertCall.html), [*messages list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageListCall.html), [*messages modify*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageModifyCall.html), [*messages send*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageSendCall.html), [*messages trash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageTrashCall.html), [*messages untrash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageUntrashCall.html), [*stop*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserStopCall.html), [*threads delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadDeleteCall.html), [*threads get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadGetCall.html), [*threads list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadListCall.html), [*threads modify*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadModifyCall.html), [*threads trash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadTrashCall.html), [*threads untrash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadUntrashCall.html) and [*watch*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserWatchCall.html) + * [*drafts create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftCreateCall.html), [*drafts delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftDeleteCall.html), [*drafts get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftGetCall.html), [*drafts list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftListCall.html), [*drafts send*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftSendCall.html), [*drafts update*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftUpdateCall.html), [*get profile*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserGetProfileCall.html), [*history list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserHistoryListCall.html), [*labels create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelCreateCall.html), [*labels delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelDeleteCall.html), [*labels get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelGetCall.html), [*labels list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelListCall.html), [*labels patch*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelPatchCall.html), [*labels update*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserLabelUpdateCall.html), [*messages attachments get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageAttachmentGetCall.html), [*messages batch delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageBatchDeleteCall.html), [*messages delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageDeleteCall.html), [*messages get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageGetCall.html), [*messages import*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageImportCall.html), [*messages insert*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageInsertCall.html), [*messages list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageListCall.html), [*messages modify*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageModifyCall.html), [*messages send*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageSendCall.html), [*messages trash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageTrashCall.html), [*messages untrash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageUntrashCall.html), [*settings filters create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingFilterCreateCall.html), [*settings filters delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingFilterDeleteCall.html), [*settings filters get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingFilterGetCall.html), [*settings filters list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingFilterListCall.html), [*settings forwarding addresses create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingForwardingAddresseCreateCall.html), [*settings forwarding addresses delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingForwardingAddresseDeleteCall.html), [*settings forwarding addresses get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingForwardingAddresseGetCall.html), [*settings forwarding addresses list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingForwardingAddresseListCall.html), [*settings get auto forwarding*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingGetAutoForwardingCall.html), [*settings get imap*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingGetImapCall.html), [*settings get pop*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingGetPopCall.html), [*settings get vacation*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingGetVacationCall.html), [*settings send as create*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendACreateCall.html), [*settings send as delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendADeleteCall.html), [*settings send as get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendAGetCall.html), [*settings send as list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendAListCall.html), [*settings send as patch*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendAPatchCall.html), [*settings send as update*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendAUpdateCall.html), [*settings send as verify*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingSendAVerifyCall.html), [*settings update auto forwarding*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingUpdateAutoForwardingCall.html), [*settings update imap*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingUpdateImapCall.html), [*settings update pop*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingUpdatePopCall.html), [*settings update vacation*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserSettingUpdateVacationCall.html), [*stop*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserStopCall.html), [*threads delete*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadDeleteCall.html), [*threads get*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadGetCall.html), [*threads list*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadListCall.html), [*threads modify*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadModifyCall.html), [*threads trash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadTrashCall.html), [*threads untrash*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserThreadUntrashCall.html) and [*watch*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserWatchCall.html) Upload supported by ... @@ -22,8 +22,8 @@ Upload supported by ... * [*messages import users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageImportCall.html) * [*drafts create users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftCreateCall.html) * [*drafts send users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftSendCall.html) -* [*drafts update users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftUpdateCall.html) * [*messages send users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageSendCall.html) +* [*drafts update users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserDraftUpdateCall.html) * [*messages insert users*](http://byron.github.io/google-apis-rs/google_gmail1/struct.UserMessageInsertCall.html) diff --git a/gen/gmail1/src/lib.rs b/gen/gmail1/src/lib.rs index 7c54378113..eb0b5c210c 100644 --- a/gen/gmail1/src/lib.rs +++ b/gen/gmail1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *gmail* crate version *0.1.14+20160316*, where *20160316* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *gmail* crate version *0.1.14+20160711*, where *20160711* is the exact revision of the *gmail:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *gmail* *v1* API can be found at the //! [official documentation site](https://developers.google.com/gmail/api/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Gmail.html) ... //! //! * users -//! * [*drafts create*](struct.UserDraftCreateCall.html), [*drafts delete*](struct.UserDraftDeleteCall.html), [*drafts get*](struct.UserDraftGetCall.html), [*drafts list*](struct.UserDraftListCall.html), [*drafts send*](struct.UserDraftSendCall.html), [*drafts update*](struct.UserDraftUpdateCall.html), [*get profile*](struct.UserGetProfileCall.html), [*history list*](struct.UserHistoryListCall.html), [*labels create*](struct.UserLabelCreateCall.html), [*labels delete*](struct.UserLabelDeleteCall.html), [*labels get*](struct.UserLabelGetCall.html), [*labels list*](struct.UserLabelListCall.html), [*labels patch*](struct.UserLabelPatchCall.html), [*labels update*](struct.UserLabelUpdateCall.html), [*messages attachments get*](struct.UserMessageAttachmentGetCall.html), [*messages batch delete*](struct.UserMessageBatchDeleteCall.html), [*messages delete*](struct.UserMessageDeleteCall.html), [*messages get*](struct.UserMessageGetCall.html), [*messages import*](struct.UserMessageImportCall.html), [*messages insert*](struct.UserMessageInsertCall.html), [*messages list*](struct.UserMessageListCall.html), [*messages modify*](struct.UserMessageModifyCall.html), [*messages send*](struct.UserMessageSendCall.html), [*messages trash*](struct.UserMessageTrashCall.html), [*messages untrash*](struct.UserMessageUntrashCall.html), [*stop*](struct.UserStopCall.html), [*threads delete*](struct.UserThreadDeleteCall.html), [*threads get*](struct.UserThreadGetCall.html), [*threads list*](struct.UserThreadListCall.html), [*threads modify*](struct.UserThreadModifyCall.html), [*threads trash*](struct.UserThreadTrashCall.html), [*threads untrash*](struct.UserThreadUntrashCall.html) and [*watch*](struct.UserWatchCall.html) +//! * [*drafts create*](struct.UserDraftCreateCall.html), [*drafts delete*](struct.UserDraftDeleteCall.html), [*drafts get*](struct.UserDraftGetCall.html), [*drafts list*](struct.UserDraftListCall.html), [*drafts send*](struct.UserDraftSendCall.html), [*drafts update*](struct.UserDraftUpdateCall.html), [*get profile*](struct.UserGetProfileCall.html), [*history list*](struct.UserHistoryListCall.html), [*labels create*](struct.UserLabelCreateCall.html), [*labels delete*](struct.UserLabelDeleteCall.html), [*labels get*](struct.UserLabelGetCall.html), [*labels list*](struct.UserLabelListCall.html), [*labels patch*](struct.UserLabelPatchCall.html), [*labels update*](struct.UserLabelUpdateCall.html), [*messages attachments get*](struct.UserMessageAttachmentGetCall.html), [*messages batch delete*](struct.UserMessageBatchDeleteCall.html), [*messages delete*](struct.UserMessageDeleteCall.html), [*messages get*](struct.UserMessageGetCall.html), [*messages import*](struct.UserMessageImportCall.html), [*messages insert*](struct.UserMessageInsertCall.html), [*messages list*](struct.UserMessageListCall.html), [*messages modify*](struct.UserMessageModifyCall.html), [*messages send*](struct.UserMessageSendCall.html), [*messages trash*](struct.UserMessageTrashCall.html), [*messages untrash*](struct.UserMessageUntrashCall.html), [*settings filters create*](struct.UserSettingFilterCreateCall.html), [*settings filters delete*](struct.UserSettingFilterDeleteCall.html), [*settings filters get*](struct.UserSettingFilterGetCall.html), [*settings filters list*](struct.UserSettingFilterListCall.html), [*settings forwarding addresses create*](struct.UserSettingForwardingAddresseCreateCall.html), [*settings forwarding addresses delete*](struct.UserSettingForwardingAddresseDeleteCall.html), [*settings forwarding addresses get*](struct.UserSettingForwardingAddresseGetCall.html), [*settings forwarding addresses list*](struct.UserSettingForwardingAddresseListCall.html), [*settings get auto forwarding*](struct.UserSettingGetAutoForwardingCall.html), [*settings get imap*](struct.UserSettingGetImapCall.html), [*settings get pop*](struct.UserSettingGetPopCall.html), [*settings get vacation*](struct.UserSettingGetVacationCall.html), [*settings send as create*](struct.UserSettingSendACreateCall.html), [*settings send as delete*](struct.UserSettingSendADeleteCall.html), [*settings send as get*](struct.UserSettingSendAGetCall.html), [*settings send as list*](struct.UserSettingSendAListCall.html), [*settings send as patch*](struct.UserSettingSendAPatchCall.html), [*settings send as update*](struct.UserSettingSendAUpdateCall.html), [*settings send as verify*](struct.UserSettingSendAVerifyCall.html), [*settings update auto forwarding*](struct.UserSettingUpdateAutoForwardingCall.html), [*settings update imap*](struct.UserSettingUpdateImapCall.html), [*settings update pop*](struct.UserSettingUpdatePopCall.html), [*settings update vacation*](struct.UserSettingUpdateVacationCall.html), [*stop*](struct.UserStopCall.html), [*threads delete*](struct.UserThreadDeleteCall.html), [*threads get*](struct.UserThreadGetCall.html), [*threads list*](struct.UserThreadListCall.html), [*threads modify*](struct.UserThreadModifyCall.html), [*threads trash*](struct.UserThreadTrashCall.html), [*threads untrash*](struct.UserThreadUntrashCall.html) and [*watch*](struct.UserWatchCall.html) //! //! //! Upload supported by ... @@ -20,8 +20,8 @@ //! * [*messages import users*](struct.UserMessageImportCall.html) //! * [*drafts create users*](struct.UserDraftCreateCall.html) //! * [*drafts send users*](struct.UserDraftSendCall.html) -//! * [*drafts update users*](struct.UserDraftUpdateCall.html) //! * [*messages send users*](struct.UserMessageSendCall.html) +//! * [*drafts update users*](struct.UserDraftUpdateCall.html) //! * [*messages insert users*](struct.UserMessageInsertCall.html) //! //! @@ -118,8 +118,8 @@ //! // Values shown here are possibly random and not representative ! //! let result = hub.users().messages_import(req, "userId") //! .process_for_calendar(true) -//! .never_mark_spam(false) -//! .internal_date_source("At") +//! .never_mark_spam(true) +//! .internal_date_source("diam") //! .deleted(false) //! .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); //! diff --git a/gen/gmail1/src/lib.rs.in b/gen/gmail1/src/lib.rs.in index 8f5a9bc3a3..d52ebe265a 100644 --- a/gen/gmail1/src/lib.rs.in +++ b/gen/gmail1/src/lib.rs.in @@ -36,8 +36,8 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { - /// Insert mail into your mailbox - Insert, + /// Manage your basic mail settings + SettingBasic, /// View and manage your mail Gmai, @@ -45,29 +45,37 @@ pub enum Scope { /// Send email on your behalf Send, - /// View and modify but not delete your email - Modify, - /// Manage drafts and send emails Compose, + /// Manage your sensitive mail settings, including who can manage your mail + SettingSharing, + /// Manage mailbox labels Label, /// View your emails messages and settings Readonly, + + /// Insert mail into your mailbox + Insert, + + /// View and modify but not delete your email + Modify, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { - Scope::Insert => "https://www.googleapis.com/auth/gmail.insert", + Scope::SettingBasic => "https://www.googleapis.com/auth/gmail.settings.basic", Scope::Gmai => "https://mail.google.com/", Scope::Send => "https://www.googleapis.com/auth/gmail.send", - Scope::Modify => "https://www.googleapis.com/auth/gmail.modify", Scope::Compose => "https://www.googleapis.com/auth/gmail.compose", + Scope::SettingSharing => "https://www.googleapis.com/auth/gmail.settings.sharing", Scope::Label => "https://www.googleapis.com/auth/gmail.labels", Scope::Readonly => "https://www.googleapis.com/auth/gmail.readonly", + Scope::Insert => "https://www.googleapis.com/auth/gmail.insert", + Scope::Modify => "https://www.googleapis.com/auth/gmail.modify", } } } @@ -185,200 +193,25 @@ impl<'a, C, A> Gmail // ############ // 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 MessagePartHeader { - /// The name of the header before the : separator. For example, To. - pub name: Option, - /// The value of the header after the : separator. For example, someuser@example.com. - pub value: Option, -} - -impl Part for MessagePartHeader {} - - -/// There is no detailed description. +/// Push notification watch response. /// /// # 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*). /// -/// * [history list users](struct.UserHistoryListCall.html) (response) +/// * [watch users](struct.UserWatchCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListHistoryResponse { - /// Page token to retrieve the next page of results in the list. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, +pub struct WatchResponse { + /// When Gmail will stop sending notifications for mailbox updates (epoch millis). Call watch again before this time to renew the watch. + pub expiration: Option, /// The ID of the mailbox's current history record. #[serde(rename="historyId")] pub history_id: Option, - /// List of history records. Any messages contained in the response will typically only have id and threadId fields populated. - pub history: Option>, } -impl ResponseResult for ListHistoryResponse {} - - -/// A collection of messages representing a conversation. -/// -/// # 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*). -/// -/// * [threads get users](struct.UserThreadGetCall.html) (response) -/// * [threads untrash users](struct.UserThreadUntrashCall.html) (response) -/// * [threads trash users](struct.UserThreadTrashCall.html) (response) -/// * [threads modify users](struct.UserThreadModifyCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Thread { - /// A short part of the message text. - pub snippet: Option, - /// The list of messages in the thread. - pub messages: Option>, - /// The unique ID of the thread. - pub id: Option, - /// The ID of the last history record that modified this thread. - #[serde(rename="historyId")] - pub history_id: Option, -} - -impl ResponseResult for Thread {} - - -/// 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 HistoryMessageAdded { - /// no description provided - pub message: Option, -} - -impl Part for HistoryMessageAdded {} - - -/// Labels are used to categorize messages and threads within the user's mailbox. -/// -/// # 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*). -/// -/// * [labels patch users](struct.UserLabelPatchCall.html) (request|response) -/// * [labels get users](struct.UserLabelGetCall.html) (response) -/// * [labels update users](struct.UserLabelUpdateCall.html) (request|response) -/// * [labels create users](struct.UserLabelCreateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Label { - /// The display name of the label. - pub name: Option, - /// The total number of messages with the label. - #[serde(rename="messagesTotal")] - pub messages_total: Option, - /// The visibility of the label in the message list in the Gmail web interface. - #[serde(rename="messageListVisibility")] - pub message_list_visibility: Option, - /// The total number of threads with the label. - #[serde(rename="threadsTotal")] - pub threads_total: Option, - /// The visibility of the label in the label list in the Gmail web interface. - #[serde(rename="labelListVisibility")] - pub label_list_visibility: Option, - /// The number of unread threads with the label. - #[serde(rename="threadsUnread")] - pub threads_unread: Option, - /// The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads. - #[serde(rename="type")] - pub type_: Option, - /// The immutable ID of the label. - pub id: Option, - /// The number of unread messages with the label. - #[serde(rename="messagesUnread")] - pub messages_unread: Option, -} - -impl RequestValue for Label {} -impl ResponseResult for Label {} - - -/// A draft email in the user's mailbox. -/// -/// # 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*). -/// -/// * [drafts get users](struct.UserDraftGetCall.html) (response) -/// * [drafts send users](struct.UserDraftSendCall.html) (request) -/// * [drafts create users](struct.UserDraftCreateCall.html) (request|response) -/// * [drafts update users](struct.UserDraftUpdateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Draft { - /// The message content of the draft. - pub message: Option, - /// The immutable ID of the draft. - pub id: Option, -} - -impl RequestValue for Draft {} -impl ResponseResult for Draft {} - - -/// A single MIME message part. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MessagePart { - /// The message part body for this part, which may be empty for container MIME message parts. - pub body: Option, - /// The MIME type of the message part. - #[serde(rename="mimeType")] - pub mime_type: Option, - /// The child MIME message parts of this part. This only applies to container MIME message parts, for example multipart/*. For non- container MIME message part types, such as text/plain, this field is empty. For more information, see RFC 1521. - pub parts: Option>, - /// The immutable ID of the message part. - #[serde(rename="partId")] - pub part_id: Option, - /// List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To, From, and Subject. - pub headers: Option>, - /// The filename of the attachment. Only present if this message part represents an attachment. - pub filename: Option, -} - -impl Part for MessagePart {} - - -/// 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*). -/// -/// * [messages modify users](struct.UserMessageModifyCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ModifyMessageRequest { - /// A list of IDs of labels to add to this message. - #[serde(rename="addLabelIds")] - pub add_label_ids: Option>, - /// A list IDs of labels to remove from this message. - #[serde(rename="removeLabelIds")] - pub remove_label_ids: Option>, -} - -impl RequestValue for ModifyMessageRequest {} +impl ResponseResult for WatchResponse {} /// There is no detailed description. @@ -405,17 +238,68 @@ pub struct ListDraftsResponse { impl ResponseResult for ListDraftsResponse {} +/// 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*). +/// +/// * [history list users](struct.UserHistoryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListHistoryResponse { + /// Page token to retrieve the next page of results in the list. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The ID of the mailbox's current history record. + #[serde(rename="historyId")] + pub history_id: Option, + /// List of history records. Any messages contained in the response will typically only have id and threadId fields populated. + pub history: Option>, +} + +impl ResponseResult for ListHistoryResponse {} + + +/// A draft email in the user's mailbox. +/// +/// # 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*). +/// +/// * [drafts get users](struct.UserDraftGetCall.html) (response) +/// * [drafts send users](struct.UserDraftSendCall.html) (request) +/// * [drafts create users](struct.UserDraftCreateCall.html) (request|response) +/// * [drafts update users](struct.UserDraftUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Draft { + /// The message content of the draft. + pub message: Option, + /// The immutable ID of the draft. + pub id: Option, +} + +impl RequestValue for Draft {} +impl ResponseResult for Draft {} + + /// 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 HistoryMessageDeleted { +pub struct HistoryLabelRemoved { + /// Label IDs removed from the message. + #[serde(rename="labelIds")] + pub label_ids: Option>, /// no description provided pub message: Option, } -impl Part for HistoryMessageDeleted {} +impl Part for HistoryLabelRemoved {} /// The body of a single MIME message part. @@ -469,6 +353,28 @@ pub struct Profile { impl ResponseResult for Profile {} +/// Configuration for communication with an SMTP service. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SmtpMsa { + /// The username that will be used for authentication with the SMTP service. This is a write-only field that can be specified in requests to create or update SendAs settings; it is never populated in responses. + pub username: Option, + /// The hostname of the SMTP service. Required. + pub host: Option, + /// The password that will be used for authentication with the SMTP service. This is a write-only field that can be specified in requests to create or update SendAs settings; it is never populated in responses. + pub password: Option, + /// The protocol that will be used to secure communication with the SMTP service. Required. + #[serde(rename="securityMode")] + pub security_mode: Option, + /// The port of the SMTP service. Required. + pub port: Option, +} + +impl Part for SmtpMsa {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -485,6 +391,473 @@ pub struct HistoryLabelAdded { impl Part for HistoryLabelAdded {} +/// Settings associated with a send-as alias, which can be either the primary login address associated with the account or a custom "from" address. Send-as aliases correspond to the "Send Mail As" feature in the web interface. See for more details. +/// +/// # 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*). +/// +/// * [settings send as create users](struct.UserSettingSendACreateCall.html) (request|response) +/// * [settings send as update users](struct.UserSettingSendAUpdateCall.html) (request|response) +/// * [settings send as patch users](struct.UserSettingSendAPatchCall.html) (request|response) +/// * [settings send as get users](struct.UserSettingSendAGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SendAs { + /// An optional SMTP service that will be used as an outbound relay for mail sent using this alias. If this is empty, outbound mail will be sent directly from Gmail's servers to the destination SMTP service. This setting only applies to custom "from" aliases. + #[serde(rename="smtpMsa")] + pub smtp_msa: Option, + /// A name that appears in the "From:" header for mail sent using this alias. For custom "from" addresses, when this is empty, Gmail will populate the "From:" header with the name that is used for the primary address associated with the account. + #[serde(rename="displayName")] + pub display_name: Option, + /// An optional email address that is included in a "Reply-To:" header for mail sent using this alias. If this is empty, Gmail will not generate a "Reply-To:" header. + #[serde(rename="replyToAddress")] + pub reply_to_address: Option, + /// An optional HTML signature that is included in messages composed with this alias in the Gmail web UI. + pub signature: Option, + /// Whether Gmail should treat this address as an alias for the user's primary email address. See for more details. This setting only applies to custom "from" aliases. + #[serde(rename="treatAsAlias")] + pub treat_as_alias: Option, + /// The email address that appears in the "From:" header for mail sent using this alias. This is read-only for all operations except create. + #[serde(rename="sendAsEmail")] + pub send_as_email: Option, + /// Whether this address is the primary address used to login to the account. Every Gmail account has exactly one primary address, and it cannot be deleted from the collection of send-as aliases. This field is read-only. + #[serde(rename="isPrimary")] + pub is_primary: Option, + /// Indicates whether this address has been verified for use as a send-as alias. Read-only. This setting only applies to custom "from" aliases. + #[serde(rename="verificationStatus")] + pub verification_status: Option, + /// Whether this address is selected as the default "From:" address in situations such as composing a new message or sending a vacation auto-reply. Every Gmail account has exactly one default send-as address, so the only legal value that clients may write to this field is true. Changing this from false to true for an address will result in this field becoming false for the other previous default address. + #[serde(rename="isDefault")] + pub is_default: Option, +} + +impl RequestValue for SendAs {} +impl ResponseResult for SendAs {} + + +/// 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*). +/// +/// * [threads modify users](struct.UserThreadModifyCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ModifyThreadRequest { + /// A list of IDs of labels to add to this thread. + #[serde(rename="addLabelIds")] + pub add_label_ids: Option>, + /// A list of IDs of labels to remove from this thread. + #[serde(rename="removeLabelIds")] + pub remove_label_ids: Option>, +} + +impl RequestValue for ModifyThreadRequest {} + + +/// 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*). +/// +/// * [messages batch delete users](struct.UserMessageBatchDeleteCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct BatchDeleteMessagesRequest { + /// The IDs of the messages to delete. + pub ids: Option>, +} + +impl RequestValue for BatchDeleteMessagesRequest {} + + +/// Settings for a forwarding address. +/// +/// # 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*). +/// +/// * [settings forwarding addresses create users](struct.UserSettingForwardingAddresseCreateCall.html) (request|response) +/// * [settings forwarding addresses get users](struct.UserSettingForwardingAddresseGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ForwardingAddress { + /// An email address to which messages can be forwarded. + #[serde(rename="forwardingEmail")] + pub forwarding_email: Option, + /// Indicates whether this address has been verified and is usable for forwarding. Read-only. + #[serde(rename="verificationStatus")] + pub verification_status: Option, +} + +impl RequestValue for ForwardingAddress {} +impl ResponseResult for ForwardingAddress {} + + +/// 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 MessagePartHeader { + /// The name of the header before the : separator. For example, To. + pub name: Option, + /// The value of the header after the : separator. For example, someuser@example.com. + pub value: Option, +} + +impl Part for MessagePartHeader {} + + +/// Response for the ListForwardingAddresses method. +/// +/// # 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*). +/// +/// * [settings forwarding addresses list users](struct.UserSettingForwardingAddresseListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListForwardingAddressesResponse { + /// List of addresses that may be used for forwarding. + #[serde(rename="forwardingAddresses")] + pub forwarding_addresses: Option>, +} + +impl ResponseResult for ListForwardingAddressesResponse {} + + +/// A collection of messages representing a conversation. +/// +/// # 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*). +/// +/// * [threads get users](struct.UserThreadGetCall.html) (response) +/// * [threads untrash users](struct.UserThreadUntrashCall.html) (response) +/// * [threads trash users](struct.UserThreadTrashCall.html) (response) +/// * [threads modify users](struct.UserThreadModifyCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Thread { + /// A short part of the message text. + pub snippet: Option, + /// The list of messages in the thread. + pub messages: Option>, + /// The unique ID of the thread. + pub id: Option, + /// The ID of the last history record that modified this thread. + #[serde(rename="historyId")] + pub history_id: Option, +} + +impl ResponseResult for Thread {} + + +/// 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 HistoryMessageAdded { + /// no description provided + pub message: Option, +} + +impl Part for HistoryMessageAdded {} + + +/// Response for the ListFilters method. +/// +/// # 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*). +/// +/// * [settings filters list users](struct.UserSettingFilterListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListFiltersResponse { + /// List of a user's filters. + pub filter: Option>, +} + +impl ResponseResult for ListFiltersResponse {} + + +/// Resource definition for Gmail filters. Filters apply to specific messages instead of an entire email thread. +/// +/// # 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*). +/// +/// * [settings filters get users](struct.UserSettingFilterGetCall.html) (response) +/// * [settings filters create users](struct.UserSettingFilterCreateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Filter { + /// Action that the filter performs. + pub action: Option, + /// The server assigned ID of the filter. + pub id: Option, + /// Matching criteria for the filter. + pub criteria: Option, +} + +impl RequestValue for Filter {} +impl ResponseResult for Filter {} + + +/// POP settings for an account. +/// +/// # 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*). +/// +/// * [settings get pop users](struct.UserSettingGetPopCall.html) (response) +/// * [settings update pop users](struct.UserSettingUpdatePopCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PopSettings { + /// The range of messages which are accessible via POP. + #[serde(rename="accessWindow")] + pub access_window: Option, + /// The action that will be executed on a message after it has been fetched via POP. + pub disposition: Option, +} + +impl RequestValue for PopSettings {} +impl ResponseResult for PopSettings {} + + +/// 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*). +/// +/// * [messages modify users](struct.UserMessageModifyCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ModifyMessageRequest { + /// A list of IDs of labels to add to this message. + #[serde(rename="addLabelIds")] + pub add_label_ids: Option>, + /// A list IDs of labels to remove from this message. + #[serde(rename="removeLabelIds")] + pub remove_label_ids: Option>, +} + +impl RequestValue for ModifyMessageRequest {} + + +/// Labels are used to categorize messages and threads within the user's mailbox. +/// +/// # 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*). +/// +/// * [labels patch users](struct.UserLabelPatchCall.html) (request|response) +/// * [labels get users](struct.UserLabelGetCall.html) (response) +/// * [labels update users](struct.UserLabelUpdateCall.html) (request|response) +/// * [labels create users](struct.UserLabelCreateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Label { + /// The display name of the label. + pub name: Option, + /// The total number of messages with the label. + #[serde(rename="messagesTotal")] + pub messages_total: Option, + /// The visibility of the label in the message list in the Gmail web interface. + #[serde(rename="messageListVisibility")] + pub message_list_visibility: Option, + /// The total number of threads with the label. + #[serde(rename="threadsTotal")] + pub threads_total: Option, + /// The visibility of the label in the label list in the Gmail web interface. + #[serde(rename="labelListVisibility")] + pub label_list_visibility: Option, + /// The number of unread threads with the label. + #[serde(rename="threadsUnread")] + pub threads_unread: Option, + /// The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads. + #[serde(rename="type")] + pub type_: Option, + /// The immutable ID of the label. + pub id: Option, + /// The number of unread messages with the label. + #[serde(rename="messagesUnread")] + pub messages_unread: Option, +} + +impl RequestValue for Label {} +impl ResponseResult for Label {} + + +/// Response for the ListSendAs method. +/// +/// # 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*). +/// +/// * [settings send as list users](struct.UserSettingSendAListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListSendAsResponse { + /// List of send-as aliases. + #[serde(rename="sendAs")] + pub send_as: Option>, +} + +impl ResponseResult for ListSendAsResponse {} + + +/// 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 HistoryMessageDeleted { + /// no description provided + pub message: Option, +} + +impl Part for HistoryMessageDeleted {} + + +/// A record of a change to the user's mailbox. Each history change may affect multiple messages in multiple ways. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct History { + /// Labels removed from messages in this history record. + #[serde(rename="labelsRemoved")] + pub labels_removed: Option>, + /// Messages deleted (not Trashed) from the mailbox in this history record. + #[serde(rename="messagesDeleted")] + pub messages_deleted: Option>, + /// Labels added to messages in this history record. + #[serde(rename="labelsAdded")] + pub labels_added: Option>, + /// List of messages changed in this history record. The fields for specific change types, such as messagesAdded may duplicate messages in this field. We recommend using the specific change-type fields instead of this. + pub messages: Option>, + /// The mailbox sequence ID. + pub id: Option, + /// Messages added to the mailbox in this history record. + #[serde(rename="messagesAdded")] + pub messages_added: Option>, +} + +impl Part for History {} + + +/// Auto-forwarding settings for an account. +/// +/// # 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*). +/// +/// * [settings get auto forwarding users](struct.UserSettingGetAutoForwardingCall.html) (response) +/// * [settings update auto forwarding users](struct.UserSettingUpdateAutoForwardingCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AutoForwarding { + /// Email address to which all incoming messages are forwarded. This email address must be a verified member of the forwarding addresses. + #[serde(rename="emailAddress")] + pub email_address: Option, + /// Whether all incoming mail is automatically forwarded to another address. + pub enabled: Option, + /// The state that a message should be left in after it has been forwarded. + pub disposition: Option, +} + +impl RequestValue for AutoForwarding {} +impl ResponseResult for AutoForwarding {} + + +/// 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*). +/// +/// * [messages list users](struct.UserMessageListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListMessagesResponse { + /// Token to retrieve the next page of results in the list. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// Estimated total number of results. + #[serde(rename="resultSizeEstimate")] + pub result_size_estimate: Option, + /// List of messages. + pub messages: Option>, +} + +impl ResponseResult for ListMessagesResponse {} + + +/// Vacation auto-reply settings for an account. These settings correspond to the "Vacation responder" feature in the web interface. See for more details. +/// +/// # 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*). +/// +/// * [settings update vacation users](struct.UserSettingUpdateVacationCall.html) (request|response) +/// * [settings get vacation users](struct.UserSettingGetVacationCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VacationSettings { + /// Optional text to prepend to the subject line in vacation responses. In order to enable auto-replies, either the response subject or the response body must be nonempty. + #[serde(rename="responseSubject")] + pub response_subject: Option, + /// Response body in plain text format. + #[serde(rename="responseBodyPlainText")] + pub response_body_plain_text: Option, + /// Flag that determines whether responses are sent to recipients who are not in the user's list of contacts. + #[serde(rename="restrictToContacts")] + pub restrict_to_contacts: Option, + /// Flag that controls whether Gmail automatically replies to messages. + #[serde(rename="enableAutoReply")] + pub enable_auto_reply: Option, + /// An optional start time for sending auto-replies (epoch ms). When this is specified, Gmail will automatically reply only to messages that it receives after the start time. If both startTime and endTime are specified, startTime must precede endTime. + #[serde(rename="startTime")] + pub start_time: Option, + /// An optional end time for sending auto-replies (epoch ms). When this is specified, Gmail will automatically reply only to messages that it receives before the end time. If both startTime and endTime are specified, startTime must precede endTime. + #[serde(rename="endTime")] + pub end_time: Option, + /// Response body in HTML format. Gmail will sanitize the HTML before storing it. + #[serde(rename="responseBodyHtml")] + pub response_body_html: Option, + /// Flag that determines whether responses are sent to recipients who are outside of the user's domain. This feature is only available for Google Apps users. + #[serde(rename="restrictToDomain")] + pub restrict_to_domain: Option, +} + +impl RequestValue for VacationSettings {} +impl ResponseResult for VacationSettings {} + + /// There is no detailed description. /// /// # Activities @@ -527,28 +900,6 @@ pub struct ListThreadsResponse { impl ResponseResult for ListThreadsResponse {} -/// 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*). -/// -/// * [threads modify users](struct.UserThreadModifyCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ModifyThreadRequest { - /// A list of IDs of labels to add to this thread. - #[serde(rename="addLabelIds")] - pub add_label_ids: Option>, - /// A list of IDs of labels to remove from this thread. - #[serde(rename="removeLabelIds")] - pub remove_label_ids: Option>, -} - -impl RequestValue for ModifyThreadRequest {} - - /// Set up or update a new push notification watch on this user's mailbox. /// /// # Activities @@ -576,64 +927,6 @@ pub struct WatchRequest { impl RequestValue for WatchRequest {} -/// 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*). -/// -/// * [messages list users](struct.UserMessageListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListMessagesResponse { - /// Token to retrieve the next page of results in the list. - #[serde(rename="nextPageToken")] - pub next_page_token: Option, - /// Estimated total number of results. - #[serde(rename="resultSizeEstimate")] - pub result_size_estimate: Option, - /// List of messages. - pub messages: Option>, -} - -impl ResponseResult for ListMessagesResponse {} - - -/// 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*). -/// -/// * [messages batch delete users](struct.UserMessageBatchDeleteCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct BatchDeleteMessagesRequest { - /// The IDs of the messages to delete. - pub ids: Option>, -} - -impl RequestValue for BatchDeleteMessagesRequest {} - - -/// 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 HistoryLabelRemoved { - /// Label IDs removed from the message. - #[serde(rename="labelIds")] - pub label_ids: Option>, - /// no description provided - pub message: Option, -} - -impl Part for HistoryLabelRemoved {} - - /// An email message. /// /// # Activities @@ -684,52 +977,110 @@ impl RequestValue for Message {} impl ResponseResult for Message {} -/// A record of a change to the user's mailbox. Each history change may affect multiple messages in multiple ways. +/// Message matching criteria. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct History { - /// Labels removed from messages in this history record. - #[serde(rename="labelsRemoved")] - pub labels_removed: Option>, - /// Messages deleted (not Trashed) from the mailbox in this history record. - #[serde(rename="messagesDeleted")] - pub messages_deleted: Option>, - /// Labels added to messages in this history record. - #[serde(rename="labelsAdded")] - pub labels_added: Option>, - /// List of messages changed in this history record. The fields for specific change types, such as messagesAdded may duplicate messages in this field. We recommend using the specific change-type fields instead of this. - pub messages: Option>, - /// The mailbox sequence ID. - pub id: Option, - /// Messages added to the mailbox in this history record. - #[serde(rename="messagesAdded")] - pub messages_added: Option>, +pub struct FilterCriteria { + /// The size of the entire RFC822 message in bytes, including all headers and attachments. + pub size: Option, + /// The sender's display name or email address. + pub from: Option, + /// Whether the message has any attachment. + #[serde(rename="hasAttachment")] + pub has_attachment: Option, + /// How the message size in bytes should be in relation to the size field. + #[serde(rename="sizeComparison")] + pub size_comparison: Option, + /// The recipient's display name or email address. Includes recipients in the "to", "cc", and "bcc" header fields. You can use simply the local part of the email address. For example, "example" and "example@" both match "example@gmail.com". This field is case-insensitive. + pub to: Option, + /// Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". + pub query: Option, + /// Whether the response should exclude chats. + #[serde(rename="excludeChats")] + pub exclude_chats: Option, + /// Only return messages not matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". + #[serde(rename="negatedQuery")] + pub negated_query: Option, + /// Case-insensitive phrase found in the message's subject. Trailing and leading whitespace are be trimmed and adjacent spaces are collapsed. + pub subject: Option, } -impl Part for History {} +impl Part for FilterCriteria {} -/// Push notification watch response. +/// A set of actions to perform on a message. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FilterAction { + /// Email address that the message should be forwarded to. + pub forward: Option, + /// List of labels to add to the message. + #[serde(rename="addLabelIds")] + pub add_label_ids: Option>, + /// List of labels to remove from the message. + #[serde(rename="removeLabelIds")] + pub remove_label_ids: Option>, +} + +impl Part for FilterAction {} + + +/// IMAP settings for an account. /// /// # 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*). /// -/// * [watch users](struct.UserWatchCall.html) (response) +/// * [settings update imap users](struct.UserSettingUpdateImapCall.html) (request|response) +/// * [settings get imap users](struct.UserSettingGetImapCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct WatchResponse { - /// When Gmail will stop sending notifications for mailbox updates (epoch millis). Call watch again before this time to renew the watch. - pub expiration: Option, - /// The ID of the mailbox's current history record. - #[serde(rename="historyId")] - pub history_id: Option, +pub struct ImapSettings { + /// If this value is true, Gmail will immediately expunge a message when it is marked as deleted in IMAP. Otherwise, Gmail will wait for an update from the client before expunging messages marked as deleted. + #[serde(rename="autoExpunge")] + pub auto_expunge: Option, + /// The action that will be executed on a message when it is marked as deleted and expunged from the last visible IMAP folder. + #[serde(rename="expungeBehavior")] + pub expunge_behavior: Option, + /// Whether IMAP is enabled for the account. + pub enabled: Option, + /// An optional limit on the number of messages that an IMAP folder may contain. Legal values are 0, 1000, 2000, 5000 or 10000. A value of zero is interpreted to mean that there is no limit. + #[serde(rename="maxFolderSize")] + pub max_folder_size: Option, } -impl ResponseResult for WatchResponse {} +impl RequestValue for ImapSettings {} +impl ResponseResult for ImapSettings {} + + +/// A single MIME message part. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MessagePart { + /// The message part body for this part, which may be empty for container MIME message parts. + pub body: Option, + /// The MIME type of the message part. + #[serde(rename="mimeType")] + pub mime_type: Option, + /// The child MIME message parts of this part. This only applies to container MIME message parts, for example multipart/*. For non- container MIME message part types, such as text/plain, this field is empty. For more information, see RFC 1521. + pub parts: Option>, + /// The immutable ID of the message part. + #[serde(rename="partId")] + pub part_id: Option, + /// List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To, From, and Subject. + pub headers: Option>, + /// The filename of the attachment. Only present if this message part represents an attachment. + pub filename: Option, +} + +impl Part for MessagePart {} @@ -760,7 +1111,7 @@ impl ResponseResult for WatchResponse {} /// ::default(), None); /// let mut hub = Gmail::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `drafts_create(...)`, `drafts_delete(...)`, `drafts_get(...)`, `drafts_list(...)`, `drafts_send(...)`, `drafts_update(...)`, `get_profile(...)`, `history_list(...)`, `labels_create(...)`, `labels_delete(...)`, `labels_get(...)`, `labels_list(...)`, `labels_patch(...)`, `labels_update(...)`, `messages_attachments_get(...)`, `messages_batch_delete(...)`, `messages_delete(...)`, `messages_get(...)`, `messages_import(...)`, `messages_insert(...)`, `messages_list(...)`, `messages_modify(...)`, `messages_send(...)`, `messages_trash(...)`, `messages_untrash(...)`, `stop(...)`, `threads_delete(...)`, `threads_get(...)`, `threads_list(...)`, `threads_modify(...)`, `threads_trash(...)`, `threads_untrash(...)` and `watch(...)` +/// // like `drafts_create(...)`, `drafts_delete(...)`, `drafts_get(...)`, `drafts_list(...)`, `drafts_send(...)`, `drafts_update(...)`, `get_profile(...)`, `history_list(...)`, `labels_create(...)`, `labels_delete(...)`, `labels_get(...)`, `labels_list(...)`, `labels_patch(...)`, `labels_update(...)`, `messages_attachments_get(...)`, `messages_batch_delete(...)`, `messages_delete(...)`, `messages_get(...)`, `messages_import(...)`, `messages_insert(...)`, `messages_list(...)`, `messages_modify(...)`, `messages_send(...)`, `messages_trash(...)`, `messages_untrash(...)`, `settings_filters_create(...)`, `settings_filters_delete(...)`, `settings_filters_get(...)`, `settings_filters_list(...)`, `settings_forwarding_addresses_create(...)`, `settings_forwarding_addresses_delete(...)`, `settings_forwarding_addresses_get(...)`, `settings_forwarding_addresses_list(...)`, `settings_get_auto_forwarding(...)`, `settings_get_imap(...)`, `settings_get_pop(...)`, `settings_get_vacation(...)`, `settings_send_as_create(...)`, `settings_send_as_delete(...)`, `settings_send_as_get(...)`, `settings_send_as_list(...)`, `settings_send_as_patch(...)`, `settings_send_as_update(...)`, `settings_send_as_verify(...)`, `settings_update_auto_forwarding(...)`, `settings_update_imap(...)`, `settings_update_pop(...)`, `settings_update_vacation(...)`, `stop(...)`, `threads_delete(...)`, `threads_get(...)`, `threads_list(...)`, `threads_modify(...)`, `threads_trash(...)`, `threads_untrash(...)` and `watch(...)` /// // to build up your call. /// let rb = hub.users(); /// # } @@ -777,13 +1128,68 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Stop receiving push notifications for the given user mailbox. + /// Updates vacation responder settings. /// /// # Arguments /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_update_vacation(&self, request: VacationSettings, user_id: &str) -> UserSettingUpdateVacationCall<'a, C, A> { + UserSettingUpdateVacationCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a new label. + /// + /// # Arguments + /// + /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn stop(&self, user_id: &str) -> UserStopCall<'a, C, A> { - UserStopCall { + pub fn labels_create(&self, request: Label, user_id: &str) -> UserLabelCreateCall<'a, C, A> { + UserLabelCreateCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_send_as_list(&self, user_id: &str) -> UserSettingSendAListCall<'a, C, A> { + UserSettingSendAListCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets IMAP settings. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_get_imap(&self, user_id: &str) -> UserSettingGetImapCall<'a, C, A> { + UserSettingGetImapCall { hub: self.hub, _user_id: user_id.to_string(), _delegate: Default::default(), @@ -815,6 +1221,42 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Lists the message filters of a Gmail user. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_filters_list(&self, user_id: &str) -> UserSettingFilterListCall<'a, C, A> { + UserSettingFilterListCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the specified forwarding address. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `forwardingEmail` - The forwarding address to be retrieved. + pub fn settings_forwarding_addresses_get(&self, user_id: &str, forwarding_email: &str) -> UserSettingForwardingAddresseGetCall<'a, C, A> { + UserSettingForwardingAddresseGetCall { + hub: self.hub, + _user_id: user_id.to_string(), + _forwarding_email: forwarding_email.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId). @@ -857,17 +1299,17 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Creates a new label. + /// Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection. /// /// # Arguments /// - /// * `request` - No description provided. - /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn labels_create(&self, request: Label, user_id: &str) -> UserLabelCreateCall<'a, C, A> { - UserLabelCreateCall { + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `sendAsEmail` - The send-as alias to be retrieved. + pub fn settings_send_as_get(&self, user_id: &str, send_as_email: &str) -> UserSettingSendAGetCall<'a, C, A> { + UserSettingSendAGetCall { hub: self.hub, - _request: request, _user_id: user_id.to_string(), + _send_as_email: send_as_email.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -914,17 +1356,15 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Moves the specified message to the trash. + /// Lists all labels in the user's mailbox. /// /// # Arguments /// /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the message to Trash. - pub fn messages_trash(&self, user_id: &str, id: &str) -> UserMessageTrashCall<'a, C, A> { - UserMessageTrashCall { + pub fn labels_list(&self, user_id: &str) -> UserLabelListCall<'a, C, A> { + UserLabelListCall { hub: self.hub, _user_id: user_id.to_string(), - _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -969,6 +1409,59 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets POP settings. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_get_pop(&self, user_id: &str) -> UserSettingGetPopCall<'a, C, A> { + UserSettingGetPopCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates POP settings. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_update_pop(&self, request: PopSettings, user_id: &str) -> UserSettingUpdatePopCall<'a, C, A> { + UserSettingUpdatePopCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets vacation responder settings. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_get_vacation(&self, user_id: &str) -> UserSettingGetVacationCall<'a, C, A> { + UserSettingGetVacationCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all. @@ -1007,6 +1500,26 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets the specified draft. + /// + /// # Arguments + /// + /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. + /// * `id` - The ID of the draft to retrieve. + pub fn drafts_get(&self, user_id: &str, id: &str) -> UserDraftGetCall<'a, C, A> { + UserDraftGetCall { + hub: self.hub, + _user_id: user_id.to_string(), + _id: id.to_string(), + _format: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Replaces a draft's content. @@ -1028,26 +1541,6 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Gets the specified draft. - /// - /// # Arguments - /// - /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the draft to retrieve. - pub fn drafts_get(&self, user_id: &str, id: &str) -> UserDraftGetCall<'a, C, A> { - UserDraftGetCall { - hub: self.hub, - _user_id: user_id.to_string(), - _id: id.to_string(), - _format: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Updates the specified label. @@ -1071,17 +1564,37 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Modifies the labels on the specified message. + /// Lists the threads in the user's mailbox. /// /// # Arguments /// - /// * `request` - No description provided. /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the message to modify. - pub fn messages_modify(&self, request: ModifyMessageRequest, user_id: &str, id: &str) -> UserMessageModifyCall<'a, C, A> { - UserMessageModifyCall { + pub fn threads_list(&self, user_id: &str) -> UserThreadListCall<'a, C, A> { + UserThreadListCall { + hub: self.hub, + _user_id: user_id.to_string(), + _q: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _label_ids: Default::default(), + _include_spam_trash: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets a filter. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `id` - The ID of the filter to be fetched. + pub fn settings_filters_get(&self, user_id: &str, id: &str) -> UserSettingFilterGetCall<'a, C, A> { + UserSettingFilterGetCall { hub: self.hub, - _request: request, _user_id: user_id.to_string(), _id: id.to_string(), _delegate: Default::default(), @@ -1132,20 +1645,76 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists the threads in the user's mailbox. + /// Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_send_as_create(&self, request: SendAs, user_id: &str) -> UserSettingSendACreateCall<'a, C, A> { + UserSettingSendACreateCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_update_auto_forwarding(&self, request: AutoForwarding, user_id: &str) -> UserSettingUpdateAutoForwardingCall<'a, C, A> { + UserSettingUpdateAutoForwardingCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Removes the specified thread from the trash. /// /// # Arguments /// /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn threads_list(&self, user_id: &str) -> UserThreadListCall<'a, C, A> { - UserThreadListCall { + /// * `id` - The ID of the thread to remove from Trash. + pub fn threads_untrash(&self, user_id: &str, id: &str) -> UserThreadUntrashCall<'a, C, A> { + UserThreadUntrashCall { hub: self.hub, _user_id: user_id.to_string(), - _q: Default::default(), - _page_token: Default::default(), - _max_results: Default::default(), - _label_ids: Default::default(), - _include_spam_trash: Default::default(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `sendAsEmail` - The send-as alias to be updated. + pub fn settings_send_as_patch(&self, request: SendAs, user_id: &str, send_as_email: &str) -> UserSettingSendAPatchCall<'a, C, A> { + UserSettingSendAPatchCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _send_as_email: send_as_email.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1192,6 +1761,23 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Lists the forwarding addresses for the specified account. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_forwarding_addresses_list(&self, user_id: &str) -> UserSettingForwardingAddresseListCall<'a, C, A> { + UserSettingForwardingAddresseListCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Gets the specified message attachment. @@ -1215,17 +1801,40 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Moves the specified thread to the trash. + /// Modifies the labels on the specified message. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. + /// * `id` - The ID of the message to modify. + pub fn messages_modify(&self, request: ModifyMessageRequest, user_id: &str, id: &str) -> UserMessageModifyCall<'a, C, A> { + UserMessageModifyCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets the specified message. /// /// # Arguments /// /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the thread to Trash. - pub fn threads_trash(&self, user_id: &str, id: &str) -> UserThreadTrashCall<'a, C, A> { - UserThreadTrashCall { + /// * `id` - The ID of the message to retrieve. + pub fn messages_get(&self, user_id: &str, id: &str) -> UserMessageGetCall<'a, C, A> { + UserMessageGetCall { hub: self.hub, _user_id: user_id.to_string(), _id: id.to_string(), + _metadata_headers: Default::default(), + _format: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1251,6 +1860,25 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Deletes a filter. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `id` - The ID of the filter to be deleted. + pub fn settings_filters_delete(&self, user_id: &str, id: &str) -> UserSettingFilterDeleteCall<'a, C, A> { + UserSettingFilterDeleteCall { + hub: self.hub, + _user_id: user_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists the drafts in the user's mailbox. @@ -1262,6 +1890,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { UserDraftListCall { hub: self.hub, _user_id: user_id.to_string(), + _q: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _include_spam_trash: Default::default(), @@ -1271,6 +1900,25 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Updates IMAP settings. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_update_imap(&self, request: ImapSettings, user_id: &str) -> UserSettingUpdateImapCall<'a, C, A> { + UserSettingUpdateImapCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Sends the specified message to the recipients in the To, Cc, and Bcc headers. @@ -1292,19 +1940,53 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets the specified message. + /// Moves the specified thread to the trash. /// /// # Arguments /// /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the message to retrieve. - pub fn messages_get(&self, user_id: &str, id: &str) -> UserMessageGetCall<'a, C, A> { - UserMessageGetCall { + /// * `id` - The ID of the thread to Trash. + pub fn threads_trash(&self, user_id: &str, id: &str) -> UserThreadTrashCall<'a, C, A> { + UserThreadTrashCall { hub: self.hub, _user_id: user_id.to_string(), _id: id.to_string(), - _metadata_headers: Default::default(), - _format: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Stop receiving push notifications for the given user mailbox. + /// + /// # Arguments + /// + /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. + pub fn stop(&self, user_id: &str) -> UserStopCall<'a, C, A> { + UserStopCall { + hub: self.hub, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_forwarding_addresses_create(&self, request: ForwardingAddress, user_id: &str) -> UserSettingForwardingAddresseCreateCall<'a, C, A> { + UserSettingForwardingAddresseCreateCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1335,14 +2017,54 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Removes the specified thread from the trash. + /// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `sendAsEmail` - The send-as alias to be updated. + pub fn settings_send_as_update(&self, request: SendAs, user_id: &str, send_as_email: &str) -> UserSettingSendAUpdateCall<'a, C, A> { + UserSettingSendAUpdateCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _send_as_email: send_as_email.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a filter. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_filters_create(&self, request: Filter, user_id: &str) -> UserSettingFilterCreateCall<'a, C, A> { + UserSettingFilterCreateCall { + hub: self.hub, + _request: request, + _user_id: user_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Moves the specified message to the trash. /// /// # Arguments /// /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - /// * `id` - The ID of the thread to remove from Trash. - pub fn threads_untrash(&self, user_id: &str, id: &str) -> UserThreadUntrashCall<'a, C, A> { - UserThreadUntrashCall { + /// * `id` - The ID of the message to Trash. + pub fn messages_trash(&self, user_id: &str, id: &str) -> UserMessageTrashCall<'a, C, A> { + UserMessageTrashCall { hub: self.hub, _user_id: user_id.to_string(), _id: id.to_string(), @@ -1390,6 +2112,25 @@ impl<'a, C, A> UserMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Sends a verification email to the specified send-as alias address. The verification status must be pending. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `sendAsEmail` - The send-as alias to be verified. + pub fn settings_send_as_verify(&self, user_id: &str, send_as_email: &str) -> UserSettingSendAVerifyCall<'a, C, A> { + UserSettingSendAVerifyCall { + hub: self.hub, + _user_id: user_id.to_string(), + _send_as_email: send_as_email.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Directly inserts a message into only this user's mailbox similar to IMAP APPEND, bypassing most scanning and classification. Does not send a message. @@ -1413,13 +2154,13 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all labels in the user's mailbox. + /// Gets the auto-forwarding setting for the specified account. /// /// # Arguments /// - /// * `userId` - The user's email address. The special value me can be used to indicate the authenticated user. - pub fn labels_list(&self, user_id: &str) -> UserLabelListCall<'a, C, A> { - UserLabelListCall { + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + pub fn settings_get_auto_forwarding(&self, user_id: &str) -> UserSettingGetAutoForwardingCall<'a, C, A> { + UserSettingGetAutoForwardingCall { hub: self.hub, _user_id: user_id.to_string(), _delegate: Default::default(), @@ -1427,6 +2168,44 @@ impl<'a, C, A> UserMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Deletes the specified send-as alias. Revokes any verification that may have been required for using it. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `sendAsEmail` - The send-as alias to be deleted. + pub fn settings_send_as_delete(&self, user_id: &str, send_as_email: &str) -> UserSettingSendADeleteCall<'a, C, A> { + UserSettingSendADeleteCall { + hub: self.hub, + _user_id: user_id.to_string(), + _send_as_email: send_as_email.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 forwarding address and revokes any verification that may have been required. + /// + /// # Arguments + /// + /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user. + /// * `forwardingEmail` - The forwarding address to be deleted. + pub fn settings_forwarding_addresses_delete(&self, user_id: &str, forwarding_email: &str) -> UserSettingForwardingAddresseDeleteCall<'a, C, A> { + UserSettingForwardingAddresseDeleteCall { + hub: self.hub, + _user_id: user_id.to_string(), + _forwarding_email: forwarding_email.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -1437,9 +2216,541 @@ impl<'a, C, A> UserMethods<'a, C, A> { // CallBuilders ### // ################# -/// Stop receiving push notifications for the given user mailbox. +/// Updates vacation responder settings. /// -/// A builder for the *stop* method supported by a *user* resource. +/// A builder for the *settings.updateVacation* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::VacationSettings; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = VacationSettings::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.users().settings_update_vacation(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingUpdateVacationCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: VacationSettings, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingUpdateVacationCall<'a, C, A> {} + +impl<'a, C, A> UserSettingUpdateVacationCall<'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, VacationSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.updateVacation", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/vacation".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: VacationSettings) -> UserSettingUpdateVacationCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingUpdateVacationCall<'a, C, A> { + self._user_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) -> UserSettingUpdateVacationCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingUpdateVacationCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingUpdateVacationCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a new label. +/// +/// A builder for the *labels.create* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::Label; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = Label::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.users().labels_create(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserLabelCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: Label, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserLabelCreateCall<'a, C, A> {} + +impl<'a, C, A> UserLabelCreateCall<'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, Label)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.labels.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/labels".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: Label) -> UserLabelCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// The user's email address. The special value me can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserLabelCreateCall<'a, C, A> { + self._user_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) -> UserLabelCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserLabelCreateCall<'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::Gmai`. + /// + /// 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) -> UserLabelCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases. +/// +/// A builder for the *settings.sendAs.list* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -1463,11 +2774,11 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().stop("userId") +/// let result = hub.users().settings_send_as_list("userId") /// .doit(); /// # } /// ``` -pub struct UserStopCall<'a, C, A> +pub struct UserSettingSendAListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, @@ -1477,13 +2788,13 @@ pub struct UserStopCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserStopCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserSettingSendAListCall<'a, C, A> {} -impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserSettingSendAListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListSendAsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -1491,11 +2802,11 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.stop", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.settings.sendAs.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); - for &field in ["userId"].iter() { + for &field in ["alt", "userId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1505,10 +2816,11 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut params.push((&name, value.clone())); } + params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/stop".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/settings/sendAs".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{userId}", "userId")].iter() { @@ -1556,7 +2868,7 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -1589,7 +2901,17 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut Ok(serr) => Err(Error::BadRequest(serr)) } } - let result_value = res; + 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) @@ -1599,13 +2921,13 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut } - /// The user's email address. The special value me can be used to indicate the authenticated user. + /// User's email address. The special value "me" can be used to indicate the authenticated user. /// /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserStopCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserSettingSendAListCall<'a, C, A> { self._user_id = new_value.to_string(); self } @@ -1615,7 +2937,7 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserStopCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserSettingSendAListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -1636,7 +2958,7 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut /// * *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) -> UserStopCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserSettingSendAListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -1645,7 +2967,7 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut /// 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::Gmai`. + /// `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. @@ -1653,7 +2975,242 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut /// 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) -> UserStopCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserSettingSendAListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets IMAP settings. +/// +/// A builder for the *settings.getImap* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_get_imap("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingGetImapCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingGetImapCall<'a, C, A> {} + +impl<'a, C, A> UserSettingGetImapCall<'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, ImapSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.getImap", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/imap".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingGetImapCall<'a, C, A> { + self._user_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) -> UserSettingGetImapCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingGetImapCall<'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) -> UserSettingGetImapCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -1696,8 +3253,8 @@ impl<'a, C, A> UserStopCall<'a, C, A> where C: BorrowMut, A: oaut /// // Values shown here are possibly random and not representative ! /// let result = hub.users().messages_import(req, "userId") /// .process_for_calendar(true) -/// .never_mark_spam(true) -/// .internal_date_source("nonumy") +/// .never_mark_spam(false) +/// .internal_date_source("sadipscing") /// .deleted(true) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } @@ -2089,6 +3646,488 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut } +/// Lists the message filters of a Gmail user. +/// +/// A builder for the *settings.filters.list* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_filters_list("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingFilterListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingFilterListCall<'a, C, A> {} + +impl<'a, C, A> UserSettingFilterListCall<'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, ListFiltersResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.filters.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/filters".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingFilterListCall<'a, C, A> { + self._user_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) -> UserSettingFilterListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingFilterListCall<'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) -> UserSettingFilterListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the specified forwarding address. +/// +/// A builder for the *settings.forwardingAddresses.get* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_forwarding_addresses_get("userId", "forwardingEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingForwardingAddresseGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _forwarding_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingForwardingAddresseGetCall<'a, C, A> {} + +impl<'a, C, A> UserSettingForwardingAddresseGetCall<'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, ForwardingAddress)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.forwardingAddresses.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("forwardingEmail", self._forwarding_email.to_string())); + for &field in ["alt", "userId", "forwardingEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{forwardingEmail}", "forwardingEmail")].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 ["forwardingEmail", "userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingForwardingAddresseGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The forwarding address to be retrieved. + /// + /// Sets the *forwarding email* path property to 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_email(mut self, new_value: &str) -> UserSettingForwardingAddresseGetCall<'a, C, A> { + self._forwarding_email = 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) -> UserSettingForwardingAddresseGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingForwardingAddresseGetCall<'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) -> UserSettingForwardingAddresseGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId). /// /// A builder for the *history.list* method supported by a *user* resource. @@ -2116,10 +4155,10 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().history_list("userId") -/// .start_history_id("sadipscing") -/// .page_token("aliquyam") -/// .max_results(35) -/// .label_id("no") +/// .start_history_id("et") +/// .page_token("et") +/// .max_results(60) +/// .label_id("ipsum") /// .doit(); /// # } /// ``` @@ -2752,9 +4791,9 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut, } -/// Creates a new label. +/// Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection. /// -/// A builder for the *labels.create* method supported by a *user* resource. +/// A builder for the *settings.sendAs.get* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -2765,7 +4804,6 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_gmail1 as gmail1; -/// use gmail1::Label; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -2776,36 +4814,31 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Gmail::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 = Label::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.users().labels_create(req, "userId") +/// let result = hub.users().settings_send_as_get("userId", "sendAsEmail") /// .doit(); /// # } /// ``` -pub struct UserLabelCreateCall<'a, C, A> +pub struct UserSettingSendAGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, - _request: Label, _user_id: String, + _send_as_email: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserLabelCreateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserSettingSendAGetCall<'a, C, A> {} -impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserSettingSendAGetCall<'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, Label)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, SendAs)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -2813,11 +4846,12 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.labels.create", - http_method: hyper::method::Method::Post }); + dlg.begin(MethodInfo { id: "gmail.users.settings.sendAs.get", + http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); - for &field in ["alt", "userId"].iter() { + params.push(("sendAsEmail", self._send_as_email.to_string())); + for &field in ["alt", "userId", "sendAsEmail"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2829,12 +4863,12 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/labels".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{userId}", "userId")].iter() { + for &(find_this, param_name) in [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -2845,8 +4879,8 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, 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 ["userId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["sendAsEmail", "userId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -2861,17 +4895,6 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, 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 { @@ -2888,15 +4911,11 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, } }; 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) + 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); + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -2947,32 +4966,33 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, } - /// - /// 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: Label) -> UserLabelCreateCall<'a, C, A> { - self._request = new_value; - self - } - /// The user's email address. The special value me can be used to indicate the authenticated user. + /// User's email address. The special value "me" can be used to indicate the authenticated user. /// /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserLabelCreateCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserSettingSendAGetCall<'a, C, A> { self._user_id = new_value.to_string(); self } + /// The send-as alias to be retrieved. + /// + /// Sets the *send as email* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAGetCall<'a, C, A> { + self._send_as_email = 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) -> UserLabelCreateCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserSettingSendAGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -2993,7 +5013,7 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, /// * *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) -> UserLabelCreateCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserSettingSendAGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -3002,7 +5022,7 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, /// 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::Gmai`. + /// `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. @@ -3010,7 +5030,7 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut, /// 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) -> UserLabelCreateCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserSettingSendAGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -3501,9 +5521,9 @@ impl<'a, C, A> UserLabelGetCall<'a, C, A> where C: BorrowMut, A: } -/// Moves the specified message to the trash. +/// Lists all labels in the user's mailbox. /// -/// A builder for the *messages.trash* method supported by a *user* resource. +/// A builder for the *labels.list* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -3527,28 +5547,27 @@ impl<'a, C, A> UserLabelGetCall<'a, C, A> where C: BorrowMut, A: /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_trash("userId", "id") +/// let result = hub.users().labels_list("userId") /// .doit(); /// # } /// ``` -pub struct UserMessageTrashCall<'a, C, A> +pub struct UserLabelListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, _user_id: String, - _id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserMessageTrashCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserLabelListCall<'a, C, A> {} -impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserLabelListCall<'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, Message)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListLabelsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3556,12 +5575,11 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.messages.trash", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.labels.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "userId", "id"].iter() { + for &field in ["alt", "userId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3573,12 +5591,12 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}/trash".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/labels".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() { + for &(find_this, param_name) in [("{userId}", "userId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -3589,8 +5607,8 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, 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 ["id", "userId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["userId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -3623,7 +5641,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -3682,27 +5700,17 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserLabelListCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// The ID of the message to Trash. - /// - /// Sets the *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 id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C, A> { - self._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) -> UserMessageTrashCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserLabelListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -3723,7 +5731,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, /// * *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) -> UserMessageTrashCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserLabelListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -3732,7 +5740,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, /// 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::Gmai`. + /// `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. @@ -3740,7 +5748,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut, /// 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) -> UserMessageTrashCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserLabelListCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -4375,6 +6383,742 @@ impl<'a, C, A> UserMessageUntrashCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Gmail::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.users().settings_get_pop("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingGetPopCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingGetPopCall<'a, C, A> {} + +impl<'a, C, A> UserSettingGetPopCall<'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, PopSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.getPop", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/pop".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingGetPopCall<'a, C, A> { + self._user_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) -> UserSettingGetPopCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingGetPopCall<'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) -> UserSettingGetPopCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates POP settings. +/// +/// A builder for the *settings.updatePop* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::PopSettings; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = PopSettings::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.users().settings_update_pop(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingUpdatePopCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: PopSettings, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingUpdatePopCall<'a, C, A> {} + +impl<'a, C, A> UserSettingUpdatePopCall<'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, PopSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.updatePop", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/pop".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: PopSettings) -> UserSettingUpdatePopCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingUpdatePopCall<'a, C, A> { + self._user_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) -> UserSettingUpdatePopCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingUpdatePopCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingUpdatePopCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets vacation responder settings. +/// +/// A builder for the *settings.getVacation* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_get_vacation("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingGetVacationCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingGetVacationCall<'a, C, A> {} + +impl<'a, C, A> UserSettingGetVacationCall<'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, VacationSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.getVacation", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/vacation".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingGetVacationCall<'a, C, A> { + self._user_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) -> UserSettingGetVacationCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingGetVacationCall<'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) -> UserSettingGetVacationCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all. /// /// A builder for the *messages.batchDelete* method supported by a *user* resource. @@ -4866,6 +7610,265 @@ impl<'a, C, A> UserMessageDeleteCall<'a, C, A> where C: BorrowMut } +/// Gets the specified draft. +/// +/// A builder for the *drafts.get* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().drafts_get("userId", "id") +/// .format("accusam") +/// .doit(); +/// # } +/// ``` +pub struct UserDraftGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _id: String, + _format: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserDraftGetCall<'a, C, A> {} + +impl<'a, C, A> UserDraftGetCall<'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, Draft)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.drafts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("id", self._id.to_string())); + if let Some(value) = self._format { + params.push(("format", value.to_string())); + } + for &field in ["alt", "userId", "id", "format"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/drafts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].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 ["id", "userId"].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) + } + } + } + } + + + /// The user's email address. The special value me can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the draft to retrieve. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The format to return the draft in. + /// + /// Sets the *format* query property to the given value. + pub fn format(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { + self._format = 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) -> UserDraftGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserDraftGetCall<'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) -> UserDraftGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Replaces a draft's content. /// /// A builder for the *drafts.update* method supported by a *user* resource. @@ -5258,265 +8261,6 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut, } -/// Gets the specified draft. -/// -/// A builder for the *drafts.get* method supported by a *user* resource. -/// It is not used directly, but through a `UserMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_gmail1 as gmail1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use gmail1::Gmail; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Gmail::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.users().drafts_get("userId", "id") -/// .format("amet") -/// .doit(); -/// # } -/// ``` -pub struct UserDraftGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Gmail, - _user_id: String, - _id: String, - _format: Option, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for UserDraftGetCall<'a, C, A> {} - -impl<'a, C, A> UserDraftGetCall<'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, Draft)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "gmail.users.drafts.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("userId", self._user_id.to_string())); - params.push(("id", self._id.to_string())); - if let Some(value) = self._format { - params.push(("format", value.to_string())); - } - for &field in ["alt", "userId", "id", "format"].iter() { - if self._additional_params.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/gmail/v1/users/{userId}/drafts/{id}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].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 ["id", "userId"].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) - } - } - } - } - - - /// The user's email address. The special value me can be used to indicate the authenticated user. - /// - /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { - self._user_id = new_value.to_string(); - self - } - /// The ID of the draft to retrieve. - /// - /// Sets the *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 id(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The format to return the draft in. - /// - /// Sets the *format* query property to the given value. - pub fn format(mut self, new_value: &str) -> UserDraftGetCall<'a, C, A> { - self._format = 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) -> UserDraftGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not 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) -> UserDraftGetCall<'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) -> UserDraftGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates the specified label. /// /// A builder for the *labels.update* method supported by a *user* resource. @@ -5795,9 +8539,9 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut, } -/// Modifies the labels on the specified message. +/// Lists the threads in the user's mailbox. /// -/// A builder for the *messages.modify* method supported by a *user* resource. +/// A builder for the *threads.list* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -5808,7 +8552,6 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_gmail1 as gmail1; -/// use gmail1::ModifyMessageRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -5819,37 +8562,40 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = Gmail::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 = ModifyMessageRequest::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.users().messages_modify(req, "userId", "id") +/// let result = hub.users().threads_list("userId") +/// .q("eirmod") +/// .page_token("sanctus") +/// .max_results(79) +/// .add_label_ids("amet") +/// .include_spam_trash(true) /// .doit(); /// # } /// ``` -pub struct UserMessageModifyCall<'a, C, A> +pub struct UserThreadListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, - _request: ModifyMessageRequest, _user_id: String, - _id: String, + _q: Option, + _page_token: Option, + _max_results: Option, + _label_ids: Vec, + _include_spam_trash: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserMessageModifyCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserThreadListCall<'a, C, A> {} -impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserThreadListCall<'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, Message)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, ListThreadsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -5857,12 +8603,28 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.messages.modify", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.threads.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "userId", "id"].iter() { + if let Some(value) = self._q { + params.push(("q", value.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 self._label_ids.len() > 0 { + for f in self._label_ids.iter() { + params.push(("labelIds", f.to_string())); + } + } + if let Some(value) = self._include_spam_trash { + params.push(("includeSpamTrash", value.to_string())); + } + for &field in ["alt", "userId", "q", "pageToken", "maxResults", "labelIds", "includeSpamTrash"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5874,12 +8636,12 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}/modify".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() { + for &(find_this, param_name) in [("{userId}", "userId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -5890,8 +8652,8 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut 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 ["id", "userId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["userId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -5906,17 +8668,6 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut 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 { @@ -5933,15 +8684,11 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut } }; 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) + 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); + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -5992,33 +8739,50 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut } - /// - /// 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: ModifyMessageRequest) -> UserMessageModifyCall<'a, C, A> { - self._request = new_value; - self - } /// The user's email address. The special value me can be used to indicate the authenticated user. /// /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// The ID of the message to modify. + /// Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". /// - /// Sets the *id* path property to the given value. + /// Sets the *q* query property to the given value. + pub fn q(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { + self._q = Some(new_value.to_string()); + self + } + /// Page token to retrieve a specific page of results in the list. /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C, A> { - self._id = new_value.to_string(); + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of threads to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> UserThreadListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Only return threads with labels that match all of the specified label IDs. + /// + /// Append the given value to the *label ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_label_ids(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { + self._label_ids.push(new_value.to_string()); + self + } + /// Include threads from SPAM and TRASH in the results. + /// + /// Sets the *include spam trash* query property to the given value. + pub fn include_spam_trash(mut self, new_value: bool) -> UserThreadListCall<'a, C, A> { + self._include_spam_trash = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6027,7 +8791,7 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserMessageModifyCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserThreadListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -6048,7 +8812,7 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut /// * *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) -> UserMessageModifyCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserThreadListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -6057,7 +8821,7 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut /// 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::Gmai`. + /// `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. @@ -6065,7 +8829,254 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut /// 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) -> UserMessageModifyCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserThreadListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets a filter. +/// +/// A builder for the *settings.filters.get* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_filters_get("userId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingFilterGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingFilterGetCall<'a, C, A> {} + +impl<'a, C, A> UserSettingFilterGetCall<'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, Filter)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.filters.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "userId", "id"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/filters/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].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 ["id", "userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingFilterGetCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the filter to be fetched. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserSettingFilterGetCall<'a, C, A> { + self._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) -> UserSettingFilterGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingFilterGetCall<'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) -> UserSettingFilterGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -6587,9 +9598,541 @@ impl<'a, C, A> UserDraftDeleteCall<'a, C, A> where C: BorrowMut, } -/// Lists the threads in the user's mailbox. +/// Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. /// -/// A builder for the *threads.list* method supported by a *user* resource. +/// A builder for the *settings.sendAs.create* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::SendAs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = SendAs::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.users().settings_send_as_create(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingSendACreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: SendAs, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingSendACreateCall<'a, C, A> {} + +impl<'a, C, A> UserSettingSendACreateCall<'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, SendAs)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.sendAs.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/sendAs".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: SendAs) -> UserSettingSendACreateCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingSendACreateCall<'a, C, A> { + self._user_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) -> UserSettingSendACreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingSendACreateCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingSendACreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled. +/// +/// A builder for the *settings.updateAutoForwarding* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::AutoForwarding; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = AutoForwarding::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.users().settings_update_auto_forwarding(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingUpdateAutoForwardingCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: AutoForwarding, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingUpdateAutoForwardingCall<'a, C, A> {} + +impl<'a, C, A> UserSettingUpdateAutoForwardingCall<'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, AutoForwarding)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.updateAutoForwarding", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/autoForwarding".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: AutoForwarding) -> UserSettingUpdateAutoForwardingCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingUpdateAutoForwardingCall<'a, C, A> { + self._user_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) -> UserSettingUpdateAutoForwardingCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingUpdateAutoForwardingCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingUpdateAutoForwardingCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Removes the specified thread from the trash. +/// +/// A builder for the *threads.untrash* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -6613,37 +10156,28 @@ impl<'a, C, A> UserDraftDeleteCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().threads_list("userId") -/// .q("et") -/// .page_token("duo") -/// .max_results(80) -/// .add_label_ids("eirmod") -/// .include_spam_trash(false) +/// let result = hub.users().threads_untrash("userId", "id") /// .doit(); /// # } /// ``` -pub struct UserThreadListCall<'a, C, A> +pub struct UserThreadUntrashCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, _user_id: String, - _q: Option, - _page_token: Option, - _max_results: Option, - _label_ids: Vec, - _include_spam_trash: Option, + _id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserThreadListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserThreadUntrashCall<'a, C, A> {} -impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserThreadUntrashCall<'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, ListThreadsResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Thread)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -6651,28 +10185,12 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.threads.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.threads.untrash", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); - if let Some(value) = self._q { - params.push(("q", value.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 self._label_ids.len() > 0 { - for f in self._label_ids.iter() { - params.push(("labelIds", f.to_string())); - } - } - if let Some(value) = self._include_spam_trash { - params.push(("includeSpamTrash", value.to_string())); - } - for &field in ["alt", "userId", "q", "pageToken", "maxResults", "labelIds", "includeSpamTrash"].iter() { + params.push(("id", self._id.to_string())); + for &field in ["alt", "userId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6684,12 +10202,12 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads/{id}/untrash".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{userId}", "userId")].iter() { + for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -6700,8 +10218,8 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A 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 ["userId"].iter() { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["id", "userId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } @@ -6734,7 +10252,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -6793,44 +10311,18 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". + /// The ID of the thread to remove from Trash. /// - /// Sets the *q* query property to the given value. - pub fn q(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { - self._q = Some(new_value.to_string()); - self - } - /// Page token to retrieve a specific page of results in the list. + /// Sets the *id* path property to the given value. /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of threads to return. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> UserThreadListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Only return threads with labels that match all of the specified label IDs. - /// - /// Append the given value to the *label ids* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_label_ids(mut self, new_value: &str) -> UserThreadListCall<'a, C, A> { - self._label_ids.push(new_value.to_string()); - self - } - /// Include threads from SPAM and TRASH in the results. - /// - /// Sets the *include spam trash* query property to the given value. - pub fn include_spam_trash(mut self, new_value: bool) -> UserThreadListCall<'a, C, A> { - self._include_spam_trash = Some(new_value); + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C, A> { + self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -6839,7 +10331,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserThreadListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserThreadUntrashCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -6860,7 +10352,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A /// * *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) -> UserThreadListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserThreadUntrashCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -6869,7 +10361,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A /// 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`. + /// `Scope::Gmai`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -6877,7 +10369,285 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut, A /// 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) -> UserThreadListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserThreadUntrashCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. This method supports patch semantics. +/// +/// A builder for the *settings.sendAs.patch* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::SendAs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = SendAs::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.users().settings_send_as_patch(req, "userId", "sendAsEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingSendAPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: SendAs, + _user_id: String, + _send_as_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingSendAPatchCall<'a, C, A> {} + +impl<'a, C, A> UserSettingSendAPatchCall<'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, SendAs)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.sendAs.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("sendAsEmail", self._send_as_email.to_string())); + for &field in ["alt", "userId", "sendAsEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].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 ["sendAsEmail", "userId"].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: SendAs) -> UserSettingSendAPatchCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingSendAPatchCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The send-as alias to be updated. + /// + /// Sets the *send as email* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAPatchCall<'a, C, A> { + self._send_as_email = 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) -> UserSettingSendAPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingSendAPatchCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingSendAPatchCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -7399,6 +11169,241 @@ impl<'a, C, A> UserThreadDeleteCall<'a, C, A> where C: BorrowMut, } +/// Lists the forwarding addresses for the specified account. +/// +/// A builder for the *settings.forwardingAddresses.list* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_forwarding_addresses_list("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingForwardingAddresseListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingForwardingAddresseListCall<'a, C, A> {} + +impl<'a, C, A> UserSettingForwardingAddresseListCall<'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, ListForwardingAddressesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.forwardingAddresses.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/forwardingAddresses".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingForwardingAddresseListCall<'a, C, A> { + self._user_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) -> UserSettingForwardingAddresseListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingForwardingAddresseListCall<'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) -> UserSettingForwardingAddresseListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Gets the specified message attachment. /// /// A builder for the *messages.attachments.get* method supported by a *user* resource. @@ -7658,9 +11663,287 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Gmail::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 = ModifyMessageRequest::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.users().messages_modify(req, "userId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserMessageModifyCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: ModifyMessageRequest, + _user_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserMessageModifyCall<'a, C, A> {} + +impl<'a, C, A> UserMessageModifyCall<'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, Message)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.messages.modify", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "userId", "id"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/messages/{id}/modify".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].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 ["id", "userId"].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: ModifyMessageRequest) -> UserMessageModifyCall<'a, C, A> { + self._request = new_value; + self + } + /// The user's email address. The special value me can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the message to modify. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C, A> { + self._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) -> UserMessageModifyCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserMessageModifyCall<'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::Gmai`. + /// + /// 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) -> UserMessageModifyCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets the specified message. +/// +/// A builder for the *messages.get* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -7684,28 +11967,32 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut +pub struct UserMessageGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, _user_id: String, _id: String, + _metadata_headers: Vec, + _format: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserThreadTrashCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserMessageGetCall<'a, C, A> {} -impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserMessageGetCall<'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, Thread)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Message)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -7713,12 +12000,20 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.threads.trash", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.messages.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); params.push(("id", self._id.to_string())); - for &field in ["alt", "userId", "id"].iter() { + if self._metadata_headers.len() > 0 { + for f in self._metadata_headers.iter() { + params.push(("metadataHeaders", f.to_string())); + } + } + if let Some(value) = self._format { + params.push(("format", value.to_string())); + } + for &field in ["alt", "userId", "id", "metadataHeaders", "format"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7730,9 +12025,9 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads/{id}/trash".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() { @@ -7780,7 +12075,7 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -7839,27 +12134,42 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// The ID of the thread to Trash. + /// The ID of the message to retrieve. /// /// Sets the *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 id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C, A> { + pub fn id(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { self._id = new_value.to_string(); self } + /// When given and format is METADATA, only include headers specified. + /// + /// Append the given value to the *metadata headers* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_metadata_headers(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { + self._metadata_headers.push(new_value.to_string()); + self + } + /// The format to return the message in. + /// + /// Sets the *format* query property to the given value. + pub fn format(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { + self._format = 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) -> UserThreadTrashCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserMessageGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -7880,7 +12190,7 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, /// * *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) -> UserThreadTrashCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserMessageGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -7889,7 +12199,7 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, /// 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::Gmai`. + /// `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. @@ -7897,7 +12207,7 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut, /// 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) -> UserThreadTrashCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserMessageGetCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -8171,6 +12481,242 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau } +/// Deletes a filter. +/// +/// A builder for the *settings.filters.delete* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_filters_delete("userId", "id") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingFilterDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingFilterDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserSettingFilterDeleteCall<'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: "gmail.users.settings.filters.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["userId", "id"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/filters/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].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 ["id", "userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingFilterDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The ID of the filter to be deleted. + /// + /// Sets the *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 id(mut self, new_value: &str) -> UserSettingFilterDeleteCall<'a, C, A> { + self._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) -> UserSettingFilterDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingFilterDeleteCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingFilterDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists the drafts in the user's mailbox. /// /// A builder for the *drafts.list* method supported by a *user* resource. @@ -8198,8 +12744,9 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().drafts_list("userId") -/// .page_token("consetetur") -/// .max_results(49) +/// .q("consetetur") +/// .page_token("takimata") +/// .max_results(61) /// .include_spam_trash(true) /// .doit(); /// # } @@ -8209,6 +12756,7 @@ pub struct UserDraftListCall<'a, C, A> hub: &'a Gmail, _user_id: String, + _q: Option, _page_token: Option, _max_results: Option, _include_spam_trash: Option, @@ -8233,8 +12781,11 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "gmail.users.drafts.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); + if let Some(value) = self._q { + params.push(("q", value.to_string())); + } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -8244,7 +12795,7 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._include_spam_trash { params.push(("includeSpamTrash", value.to_string())); } - for &field in ["alt", "userId", "pageToken", "maxResults", "includeSpamTrash"].iter() { + for &field in ["alt", "userId", "q", "pageToken", "maxResults", "includeSpamTrash"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8369,6 +12920,13 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut, A: self._user_id = new_value.to_string(); self } + /// Only return draft messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". + /// + /// Sets the *q* query property to the given value. + pub fn q(mut self, new_value: &str) -> UserDraftListCall<'a, C, A> { + self._q = Some(new_value.to_string()); + self + } /// Page token to retrieve a specific page of results in the list. /// /// Sets the *page token* query property to the given value. @@ -8442,6 +13000,272 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut, A: } +/// Updates IMAP settings. +/// +/// A builder for the *settings.updateImap* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::ImapSettings; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = ImapSettings::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.users().settings_update_imap(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingUpdateImapCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: ImapSettings, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingUpdateImapCall<'a, C, A> {} + +impl<'a, C, A> UserSettingUpdateImapCall<'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, ImapSettings)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.updateImap", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/imap".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: ImapSettings) -> UserSettingUpdateImapCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingUpdateImapCall<'a, C, A> { + self._user_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) -> UserSettingUpdateImapCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingUpdateImapCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingUpdateImapCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Sends the specified message to the recipients in the To, Cc, and Bcc headers. /// /// A builder for the *messages.send* method supported by a *user* resource. @@ -8822,9 +13646,9 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut, } -/// Gets the specified message. +/// Moves the specified thread to the trash. /// -/// A builder for the *messages.get* method supported by a *user* resource. +/// A builder for the *threads.trash* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -8848,32 +13672,28 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().messages_get("userId", "id") -/// .add_metadata_headers("sit") -/// .format("vero") +/// let result = hub.users().threads_trash("userId", "id") /// .doit(); /// # } /// ``` -pub struct UserMessageGetCall<'a, C, A> +pub struct UserThreadTrashCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, _user_id: String, _id: String, - _metadata_headers: Vec, - _format: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserMessageGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserThreadTrashCall<'a, C, A> {} -impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserThreadTrashCall<'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, Message)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Thread)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -8881,20 +13701,12 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.messages.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "gmail.users.threads.trash", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); params.push(("id", self._id.to_string())); - if self._metadata_headers.len() > 0 { - for f in self._metadata_headers.iter() { - params.push(("metadataHeaders", f.to_string())); - } - } - if let Some(value) = self._format { - params.push(("format", value.to_string())); - } - for &field in ["alt", "userId", "id", "metadataHeaders", "format"].iter() { + for &field in ["alt", "userId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8906,9 +13718,9 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads/{id}/trash".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() { @@ -8956,7 +13768,7 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A 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) + let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url) .header(UserAgent(self.hub._user_agent.clone())) .header(auth_header.clone()); @@ -9015,42 +13827,27 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// The ID of the message to retrieve. + /// The ID of the thread to Trash. /// /// Sets the *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 id(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { + pub fn id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C, A> { self._id = new_value.to_string(); self } - /// When given and format is METADATA, only include headers specified. - /// - /// Append the given value to the *metadata headers* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_metadata_headers(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { - self._metadata_headers.push(new_value.to_string()); - self - } - /// The format to return the message in. - /// - /// Sets the *format* query property to the given value. - pub fn format(mut self, new_value: &str) -> UserMessageGetCall<'a, C, A> { - self._format = 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) -> UserMessageGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserThreadTrashCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9071,7 +13868,7 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A /// * *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) -> UserMessageGetCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserThreadTrashCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -9080,7 +13877,7 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A /// 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`. + /// `Scope::Gmai`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -9088,7 +13885,497 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A /// 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) -> UserMessageGetCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserThreadTrashCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Stop receiving push notifications for the given user mailbox. +/// +/// A builder for the *stop* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().stop("userId") +/// .doit(); +/// # } +/// ``` +pub struct UserStopCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserStopCall<'a, C, A> {} + +impl<'a, C, A> UserStopCall<'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: "gmail.users.stop", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/stop".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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 = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The user's email address. The special value me can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserStopCall<'a, C, A> { + self._user_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) -> UserStopCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserStopCall<'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::Gmai`. + /// + /// 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) -> UserStopCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to pending; otherwise, the resource will be created with verification status set to accepted. +/// +/// A builder for the *settings.forwardingAddresses.create* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::ForwardingAddress; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = ForwardingAddress::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.users().settings_forwarding_addresses_create(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingForwardingAddresseCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: ForwardingAddress, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingForwardingAddresseCreateCall<'a, C, A> {} + +impl<'a, C, A> UserSettingForwardingAddresseCreateCall<'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, ForwardingAddress)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.forwardingAddresses.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/forwardingAddresses".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: ForwardingAddress) -> UserSettingForwardingAddresseCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingForwardingAddresseCreateCall<'a, C, A> { + self._user_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) -> UserSettingForwardingAddresseCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingForwardingAddresseCreateCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingForwardingAddresseCreateCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -9124,9 +14411,9 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut, A /// // Values shown here are possibly random and not representative ! /// let result = hub.users().messages_list("userId") /// .q("rebum.") -/// .page_token("consetetur") -/// .max_results(57) -/// .add_label_ids("vero") +/// .page_token("dolore") +/// .max_results(60) +/// .add_label_ids("sed") /// .include_spam_trash(false) /// .doit(); /// # } @@ -9394,9 +14681,553 @@ impl<'a, C, A> UserMessageListCall<'a, C, A> where C: BorrowMut, } -/// Removes the specified thread from the trash. +/// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. /// -/// A builder for the *threads.untrash* method supported by a *user* resource. +/// A builder for the *settings.sendAs.update* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::SendAs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = SendAs::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.users().settings_send_as_update(req, "userId", "sendAsEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingSendAUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: SendAs, + _user_id: String, + _send_as_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingSendAUpdateCall<'a, C, A> {} + +impl<'a, C, A> UserSettingSendAUpdateCall<'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, SendAs)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.sendAs.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("sendAsEmail", self._send_as_email.to_string())); + for &field in ["alt", "userId", "sendAsEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].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 ["sendAsEmail", "userId"].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: SendAs) -> UserSettingSendAUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingSendAUpdateCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The send-as alias to be updated. + /// + /// Sets the *send as email* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAUpdateCall<'a, C, A> { + self._send_as_email = 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) -> UserSettingSendAUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingSendAUpdateCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingSendAUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a filter. +/// +/// A builder for the *settings.filters.create* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// use gmail1::Filter; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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 = Filter::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.users().settings_filters_create(req, "userId") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingFilterCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _request: Filter, + _user_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingFilterCreateCall<'a, C, A> {} + +impl<'a, C, A> UserSettingFilterCreateCall<'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, Filter)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "gmail.users.settings.filters.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + for &field in ["alt", "userId"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/filters".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingBasic.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId")].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 ["userId"].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: Filter) -> UserSettingFilterCreateCall<'a, C, A> { + self._request = new_value; + self + } + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingFilterCreateCall<'a, C, A> { + self._user_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) -> UserSettingFilterCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingFilterCreateCall<'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::SettingBasic`. + /// + /// 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) -> UserSettingFilterCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Moves the specified message to the trash. +/// +/// A builder for the *messages.trash* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -9420,11 +15251,11 @@ impl<'a, C, A> UserMessageListCall<'a, C, A> where C: BorrowMut, /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().threads_untrash("userId", "id") +/// let result = hub.users().messages_trash("userId", "id") /// .doit(); /// # } /// ``` -pub struct UserThreadUntrashCall<'a, C, A> +pub struct UserMessageTrashCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, @@ -9435,13 +15266,13 @@ pub struct UserThreadUntrashCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserThreadUntrashCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserMessageTrashCall<'a, C, A> {} -impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserMessageTrashCall<'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, Thread)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, Message)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -9449,7 +15280,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.threads.untrash", + dlg.begin(MethodInfo { id: "gmail.users.messages.trash", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); @@ -9466,7 +15297,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/threads/{id}/untrash".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/messages/{id}/trash".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Gmai.as_ref().to_string(), ()); } @@ -9575,17 +15406,17 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn user_id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C, A> { self._user_id = new_value.to_string(); self } - /// The ID of the thread to remove from Trash. + /// The ID of the message to Trash. /// /// Sets the *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 id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C, A> { + pub fn id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C, A> { self._id = new_value.to_string(); self } @@ -9595,7 +15426,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserThreadUntrashCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserMessageTrashCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -9616,7 +15447,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut /// * *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) -> UserThreadUntrashCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserMessageTrashCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -9633,7 +15464,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut /// 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) -> UserThreadUntrashCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserMessageTrashCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -9903,8 +15734,8 @@ impl<'a, C, A> UserGetProfileCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().threads_get("userId", "id") -/// .add_metadata_headers("Lorem") -/// .format("et") +/// .add_metadata_headers("eos") +/// .format("tempor") /// .doit(); /// # } /// ``` @@ -10150,6 +15981,242 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut, A: } +/// Sends a verification email to the specified send-as alias address. The verification status must be pending. +/// +/// A builder for the *settings.sendAs.verify* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_send_as_verify("userId", "sendAsEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingSendAVerifyCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _send_as_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingSendAVerifyCall<'a, C, A> {} + +impl<'a, C, A> UserSettingSendAVerifyCall<'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: "gmail.users.settings.sendAs.verify", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("sendAsEmail", self._send_as_email.to_string())); + for &field in ["userId", "sendAsEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].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 ["sendAsEmail", "userId"].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 = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingSendAVerifyCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The send-as alias to be verified. + /// + /// Sets the *send as email* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAVerifyCall<'a, C, A> { + self._send_as_email = 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) -> UserSettingSendAVerifyCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingSendAVerifyCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingSendAVerifyCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Directly inserts a message into only this user's mailbox similar to IMAP APPEND, bypassing most scanning and classification. Does not send a message. /// /// A builder for the *messages.insert* method supported by a *user* resource. @@ -10184,7 +16251,7 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().messages_insert(req, "userId") -/// .internal_date_source("consetetur") +/// .internal_date_source("aliquyam") /// .deleted(false) /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } @@ -10554,9 +16621,9 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut } -/// Lists all labels in the user's mailbox. +/// Gets the auto-forwarding setting for the specified account. /// -/// A builder for the *labels.list* method supported by a *user* resource. +/// A builder for the *settings.getAutoForwarding* method supported by a *user* resource. /// It is not used directly, but through a `UserMethods` instance. /// /// # Example @@ -10580,11 +16647,11 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.users().labels_list("userId") +/// let result = hub.users().settings_get_auto_forwarding("userId") /// .doit(); /// # } /// ``` -pub struct UserLabelListCall<'a, C, A> +pub struct UserSettingGetAutoForwardingCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Gmail, @@ -10594,13 +16661,13 @@ pub struct UserLabelListCall<'a, C, A> _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for UserLabelListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for UserSettingGetAutoForwardingCall<'a, C, A> {} -impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> UserSettingGetAutoForwardingCall<'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, ListLabelsResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, AutoForwarding)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -10608,7 +16675,7 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "gmail.users.labels.list", + dlg.begin(MethodInfo { id: "gmail.users.settings.getAutoForwarding", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("userId", self._user_id.to_string())); @@ -10624,7 +16691,7 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/labels".to_string(); + let mut url = "https://www.googleapis.com/gmail/v1/users/{userId}/settings/autoForwarding".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); } @@ -10727,13 +16794,13 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: } - /// The user's email address. The special value me can be used to indicate the authenticated user. + /// User's email address. The special value "me" can be used to indicate the authenticated user. /// /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserLabelListCall<'a, C, A> { + pub fn user_id(mut self, new_value: &str) -> UserSettingGetAutoForwardingCall<'a, C, A> { self._user_id = new_value.to_string(); self } @@ -10743,7 +16810,7 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserLabelListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserSettingGetAutoForwardingCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -10764,7 +16831,7 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: /// * *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) -> UserLabelListCall<'a, C, A> + pub fn param(mut self, name: T, value: T) -> UserSettingGetAutoForwardingCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -10781,7 +16848,479 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut, A: /// 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) -> UserLabelListCall<'a, C, A> + pub fn add_scope(mut self, scope: T) -> UserSettingGetAutoForwardingCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes the specified send-as alias. Revokes any verification that may have been required for using it. +/// +/// A builder for the *settings.sendAs.delete* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_send_as_delete("userId", "sendAsEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingSendADeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _send_as_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingSendADeleteCall<'a, C, A> {} + +impl<'a, C, A> UserSettingSendADeleteCall<'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: "gmail.users.settings.sendAs.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("sendAsEmail", self._send_as_email.to_string())); + for &field in ["userId", "sendAsEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].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 ["sendAsEmail", "userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingSendADeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The send-as alias to be deleted. + /// + /// Sets the *send as email* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendADeleteCall<'a, C, A> { + self._send_as_email = 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) -> UserSettingSendADeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingSendADeleteCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingSendADeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes the specified forwarding address and revokes any verification that may have been required. +/// +/// A builder for the *settings.forwardingAddresses.delete* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_gmail1 as gmail1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use gmail1::Gmail; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Gmail::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.users().settings_forwarding_addresses_delete("userId", "forwardingEmail") +/// .doit(); +/// # } +/// ``` +pub struct UserSettingForwardingAddresseDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Gmail, + _user_id: String, + _forwarding_email: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for UserSettingForwardingAddresseDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserSettingForwardingAddresseDeleteCall<'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: "gmail.users.settings.forwardingAddresses.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("forwardingEmail", self._forwarding_email.to_string())); + for &field in ["userId", "forwardingEmail"].iter() { + if self._additional_params.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/gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::SettingSharing.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{forwardingEmail}", "forwardingEmail")].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 ["forwardingEmail", "userId"].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) + } + } + } + } + + + /// User's email address. The special value "me" can be used to indicate the authenticated user. + /// + /// Sets the *user 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 user_id(mut self, new_value: &str) -> UserSettingForwardingAddresseDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The forwarding address to be deleted. + /// + /// Sets the *forwarding email* path property to 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_email(mut self, new_value: &str) -> UserSettingForwardingAddresseDeleteCall<'a, C, A> { + self._forwarding_email = 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) -> UserSettingForwardingAddresseDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> UserSettingForwardingAddresseDeleteCall<'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::SettingSharing`. + /// + /// 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) -> UserSettingForwardingAddresseDeleteCall<'a, C, A> where T: AsRef { self._scopes.insert(scope.as_ref().to_string(), ()); self diff --git a/gen/groupsmigration1-cli/Cargo.toml b/gen/groupsmigration1-cli/Cargo.toml index ab8d389c90..0ec45aa336 100644 --- a/gen/groupsmigration1-cli/Cargo.toml +++ b/gen/groupsmigration1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "groupsmigration1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-groupsmigration1/nightly" with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-groupsmigration1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-groupsmigration1] diff --git a/gen/groupsmigration1/Cargo.toml b/gen/groupsmigration1/Cargo.toml index 3e64462b7a..8ce3f79a46 100644 --- a/gen/groupsmigration1/Cargo.toml +++ b/gen/groupsmigration1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/groupssettings1-cli/Cargo.toml b/gen/groupssettings1-cli/Cargo.toml index c040cd5a44..6845b53453 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+20160323" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "groupssettings1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-groupssettings1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-groupssettings1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-groupssettings1] diff --git a/gen/groupssettings1-cli/README.md b/gen/groupssettings1-cli/README.md index 5d7d777c61..daf124e7b3 100644 --- a/gen/groupssettings1-cli/README.md +++ b/gen/groupssettings1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *groupssettings* API at revision *20160323*. The CLI is at version *0.3.6*. +This documentation was generated from the *groupssettings* API at revision *20160525*. The CLI is at version *0.3.6*. ```bash groupssettings1 [options] diff --git a/gen/groupssettings1-cli/mkdocs.yml b/gen/groupssettings1-cli/mkdocs.yml index ab0b25dd33..a6000a3f2a 100644 --- a/gen/groupssettings1-cli/mkdocs.yml +++ b/gen/groupssettings1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: groupssettings v0.3.6+20160323 +site_name: groupssettings v0.3.6+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 d364dab78b..4703c651e9 100644 --- a/gen/groupssettings1-cli/src/main.rs +++ b/gen/groupssettings1-cli/src/main.rs @@ -124,6 +124,7 @@ impl<'n> Engine<'n> { "who-can-post-message" => Some(("whoCanPostMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "primary-language" => Some(("primaryLanguage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-view-membership" => Some(("whoCanViewMembership", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "include-custom-footer" => Some(("includeCustomFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-message-deny-notification-text" => Some(("defaultMessageDenyNotificationText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "include-in-global-address-list" => Some(("includeInGlobalAddressList", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "archive-only" => Some(("archiveOnly", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -131,11 +132,11 @@ impl<'n> Engine<'n> { "members-can-post-as-the-group" => Some(("membersCanPostAsTheGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "allow-web-posting" => Some(("allowWebPosting", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "message-moderation-level" => Some(("messageModerationLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "send-message-deny-notification" => Some(("sendMessageDenyNotification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reply-to" => Some(("replyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "custom-reply-to" => Some(("customReplyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "send-message-deny-notification" => Some(("sendMessageDenyNotification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "message-moderation-level" => Some(("messageModerationLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-contact-owner" => Some(("whoCanContactOwner", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "message-display-font" => Some(("messageDisplayFont", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-leave-group" => Some(("whoCanLeaveGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -148,9 +149,10 @@ impl<'n> Engine<'n> { "who-can-view-group" => Some(("whoCanViewGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "show-in-group-directory" => Some(("showInGroupDirectory", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "max-message-bytes" => Some(("maxMessageBytes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "custom-footer-text" => Some(("customFooterText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "allow-google-communication" => Some(("allowGoogleCommunication", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-external-members", "allow-google-communication", "allow-web-posting", "archive-only", "custom-reply-to", "default-message-deny-notification-text", "description", "email", "include-in-global-address-list", "is-archived", "kind", "max-message-bytes", "members-can-post-as-the-group", "message-display-font", "message-moderation-level", "name", "primary-language", "reply-to", "send-message-deny-notification", "show-in-group-directory", "spam-moderation-level", "who-can-add", "who-can-contact-owner", "who-can-invite", "who-can-join", "who-can-leave-group", "who-can-post-message", "who-can-view-group", "who-can-view-membership"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-external-members", "allow-google-communication", "allow-web-posting", "archive-only", "custom-footer-text", "custom-reply-to", "default-message-deny-notification-text", "description", "email", "include-custom-footer", "include-in-global-address-list", "is-archived", "kind", "max-message-bytes", "members-can-post-as-the-group", "message-display-font", "message-moderation-level", "name", "primary-language", "reply-to", "send-message-deny-notification", "show-in-group-directory", "spam-moderation-level", "who-can-add", "who-can-contact-owner", "who-can-invite", "who-can-join", "who-can-leave-group", "who-can-post-message", "who-can-view-group", "who-can-view-membership"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -237,6 +239,7 @@ impl<'n> Engine<'n> { "who-can-post-message" => Some(("whoCanPostMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "primary-language" => Some(("primaryLanguage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-view-membership" => Some(("whoCanViewMembership", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "include-custom-footer" => Some(("includeCustomFooter", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "default-message-deny-notification-text" => Some(("defaultMessageDenyNotificationText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "include-in-global-address-list" => Some(("includeInGlobalAddressList", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "archive-only" => Some(("archiveOnly", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -244,11 +247,11 @@ impl<'n> Engine<'n> { "members-can-post-as-the-group" => Some(("membersCanPostAsTheGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "allow-web-posting" => Some(("allowWebPosting", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "message-moderation-level" => Some(("messageModerationLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "send-message-deny-notification" => Some(("sendMessageDenyNotification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reply-to" => Some(("replyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "custom-reply-to" => Some(("customReplyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "send-message-deny-notification" => Some(("sendMessageDenyNotification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "message-moderation-level" => Some(("messageModerationLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-contact-owner" => Some(("whoCanContactOwner", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "message-display-font" => Some(("messageDisplayFont", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "who-can-leave-group" => Some(("whoCanLeaveGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -261,9 +264,10 @@ impl<'n> Engine<'n> { "who-can-view-group" => Some(("whoCanViewGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "show-in-group-directory" => Some(("showInGroupDirectory", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "max-message-bytes" => Some(("maxMessageBytes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "custom-footer-text" => Some(("customFooterText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "allow-google-communication" => Some(("allowGoogleCommunication", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-external-members", "allow-google-communication", "allow-web-posting", "archive-only", "custom-reply-to", "default-message-deny-notification-text", "description", "email", "include-in-global-address-list", "is-archived", "kind", "max-message-bytes", "members-can-post-as-the-group", "message-display-font", "message-moderation-level", "name", "primary-language", "reply-to", "send-message-deny-notification", "show-in-group-directory", "spam-moderation-level", "who-can-add", "who-can-contact-owner", "who-can-invite", "who-can-join", "who-can-leave-group", "who-can-post-message", "who-can-view-group", "who-can-view-membership"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-external-members", "allow-google-communication", "allow-web-posting", "archive-only", "custom-footer-text", "custom-reply-to", "default-message-deny-notification-text", "description", "email", "include-custom-footer", "include-in-global-address-list", "is-archived", "kind", "max-message-bytes", "members-can-post-as-the-group", "message-display-font", "message-moderation-level", "name", "primary-language", "reply-to", "send-message-deny-notification", "show-in-group-directory", "spam-moderation-level", "who-can-add", "who-can-contact-owner", "who-can-invite", "who-can-join", "who-can-leave-group", "who-can-post-message", "who-can-view-group", "who-can-view-membership"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -512,7 +516,7 @@ fn main() { let mut app = App::new("groupssettings1") .author("Sebastian Thiel ") - .version("0.3.6+20160323") + .version("0.3.6+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/groupssettings1/Cargo.toml b/gen/groupssettings1/Cargo.toml index 5ec8cefbbd..2a098266cb 100644 --- a/gen/groupssettings1/Cargo.toml +++ b/gen/groupssettings1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-groupssettings1" -version = "0.1.14+20160323" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/groupssettings1/README.md b/gen/groupssettings1/README.md index 4c870c5b00..ede2284fe1 100644 --- a/gen/groupssettings1/README.md +++ b/gen/groupssettings1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-groupssettings1` library allows access to all features of the *Google groupssettings* service. -This documentation was generated from *groupssettings* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *groupssettings* crate version *0.1.14+20160525*, where *20160525* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *groupssettings* *v1* API can be found at the [official documentation site](https://developers.google.com/google-apps/groups-settings/get_started). diff --git a/gen/groupssettings1/src/lib.rs b/gen/groupssettings1/src/lib.rs index bd7a419539..d873feef14 100644 --- a/gen/groupssettings1/src/lib.rs +++ b/gen/groupssettings1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *groupssettings* crate version *0.1.14+20160323*, where *20160323* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *groupssettings* crate version *0.1.14+20160525*, where *20160525* is the exact revision of the *groupssettings:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *groupssettings* *v1* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/groups-settings/get_started). diff --git a/gen/groupssettings1/src/lib.rs.in b/gen/groupssettings1/src/lib.rs.in index 63a2b539e3..a4a7dfab34 100644 --- a/gen/groupssettings1/src/lib.rs.in +++ b/gen/groupssettings1/src/lib.rs.in @@ -169,9 +169,9 @@ impl<'a, C, A> Groupssettings /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Groups { - /// Moderation level for messages. Possible values are: MODERATE_ALL_MESSAGES MODERATE_NON_MEMBERS MODERATE_NEW_MEMBERS MODERATE_NONE - #[serde(rename="messageModerationLevel")] - pub message_moderation_level: Option, + /// Should the member be notified if his message is denied by owner. + #[serde(rename="sendMessageDenyNotification")] + pub send_message_deny_notification: Option, /// Description of the group pub description: Option, /// Are external members allowed to join the group. @@ -183,9 +183,9 @@ pub struct Groups { /// Default email to which reply to any message should go. #[serde(rename="customReplyTo")] pub custom_reply_to: Option, - /// Should the member be notified if his message is denied by owner. - #[serde(rename="sendMessageDenyNotification")] - pub send_message_deny_notification: Option, + /// Moderation level for messages. Possible values are: MODERATE_ALL_MESSAGES MODERATE_NON_MEMBERS MODERATE_NEW_MEMBERS MODERATE_NONE + #[serde(rename="messageModerationLevel")] + pub message_moderation_level: Option, /// Permission to contact owner of the group via web UI. Possible values are: ANYONE_CAN_CONTACT ALL_IN_DOMAIN_CAN_CONTACT ALL_MEMBERS_CAN_CONTACT ALL_MANAGERS_CAN_CONTACT #[serde(rename="whoCanContactOwner")] pub who_can_contact_owner: Option, @@ -217,9 +217,15 @@ pub struct Groups { pub kind: Option, /// Name of the Group pub name: Option, + /// Whether to include custom footer. + #[serde(rename="includeCustomFooter")] + pub include_custom_footer: Option, /// Moderation level for messages detected as spam. Possible values are: ALLOW MODERATE SILENTLY_MODERATE REJECT #[serde(rename="spamModerationLevel")] pub spam_moderation_level: Option, + /// Custom footer text. + #[serde(rename="customFooterText")] + pub custom_footer_text: Option, /// Default message deny notification message #[serde(rename="defaultMessageDenyNotificationText")] pub default_message_deny_notification_text: Option, diff --git a/gen/iam1-cli/Cargo.toml b/gen/iam1-cli/Cargo.toml index cb2d9381cc..6c10f3a6b4 100644 --- a/gen/iam1-cli/Cargo.toml +++ b/gen/iam1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "iam1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-iam1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-iam1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-iam1] diff --git a/gen/iam1/Cargo.toml b/gen/iam1/Cargo.toml index 9516cb569e..dad600aeb2 100644 --- a/gen/iam1/Cargo.toml +++ b/gen/iam1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/identitytoolkit3-cli/Cargo.toml b/gen/identitytoolkit3-cli/Cargo.toml index 7cc75d42ea..c54c98c24b 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+20160324" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "identitytoolkit3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-identitytoolkit3/nightly" with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-identitytoolkit3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-identitytoolkit3] diff --git a/gen/identitytoolkit3-cli/README.md b/gen/identitytoolkit3-cli/README.md index a754639b39..9072ea0b06 100644 --- a/gen/identitytoolkit3-cli/README.md +++ b/gen/identitytoolkit3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *Identity Toolkit* API at revision *20160324*. 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 *0.3.6*. ```bash identitytoolkit3 [options] diff --git a/gen/identitytoolkit3-cli/mkdocs.yml b/gen/identitytoolkit3-cli/mkdocs.yml index 015f6ecdea..a24a750cea 100644 --- a/gen/identitytoolkit3-cli/mkdocs.yml +++ b/gen/identitytoolkit3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Identity Toolkit v0.3.6+20160324 +site_name: Identity Toolkit v0.3.6+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 f6b9e6eba8..027facfa81 100644 --- a/gen/identitytoolkit3-cli/src/main.rs +++ b/gen/identitytoolkit3-cli/src/main.rs @@ -68,18 +68,21 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { - "openid-realm" => Some(("openidRealm", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "oauth-scope" => Some(("oauthScope", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "client-id" => Some(("clientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "ota-app" => Some(("otaApp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "hosted-domain" => Some(("hostedDomain", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "oauth-consumer-key" => Some(("oauthConsumerKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "openid-realm" => Some(("openidRealm", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "auth-flow-type" => Some(("authFlowType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "client-id" => Some(("clientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "oauth-scope" => Some(("oauthScope", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ota-app" => Some(("otaApp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "session-id" => Some(("sessionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "provider-id" => Some(("providerId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "context" => Some(("context", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "app-id" => Some(("appId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "continue-uri" => Some(("continueUri", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "identifier" => Some(("identifier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["app-id", "client-id", "context", "continue-uri", "identifier", "oauth-consumer-key", "oauth-scope", "openid-realm", "ota-app", "provider-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["app-id", "auth-flow-type", "client-id", "context", "continue-uri", "hosted-domain", "identifier", "oauth-consumer-key", "oauth-scope", "openid-realm", "ota-app", "provider-id", "session-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -740,6 +743,7 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "delete-provider" => Some(("deleteProvider", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "provider" => Some(("provider", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "delegated-project-number" => Some(("delegatedProjectNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "oob-code" => Some(("oobCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -748,19 +752,20 @@ impl<'n> Engine<'n> { "photo-url" => Some(("photoUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "instance-id" => Some(("instanceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id-token" => Some(("idToken", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "delete-attribute" => Some(("deleteAttribute", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "last-login-at" => Some(("lastLoginAt", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "upgrade-to-federated-login" => Some(("upgradeToFederatedLogin", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "disable-user" => Some(("disableUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "delete-provider" => Some(("deleteProvider", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "delete-attribute" => Some(("deleteAttribute", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "captcha-challenge" => Some(("captchaChallenge", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "captcha-response" => Some(("captchaResponse", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email-verified" => Some(("emailVerified", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "return-secure-token" => Some(("returnSecureToken", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "password" => Some(("password", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "created-at" => Some(("createdAt", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["captcha-challenge", "captcha-response", "delegated-project-number", "delete-attribute", "delete-provider", "disable-user", "display-name", "email", "email-verified", "id-token", "instance-id", "local-id", "oob-code", "password", "photo-url", "provider", "return-secure-token", "upgrade-to-federated-login", "valid-since"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["captcha-challenge", "captcha-response", "created-at", "delegated-project-number", "delete-attribute", "delete-provider", "disable-user", "display-name", "email", "email-verified", "id-token", "instance-id", "last-login-at", "local-id", "oob-code", "password", "photo-url", "provider", "return-secure-token", "upgrade-to-federated-login", "valid-since"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -849,6 +854,7 @@ impl<'n> Engine<'n> { "verify-email-template.reply-to" => Some(("verifyEmailTemplate.replyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "verify-email-template.subject" => Some(("verifyEmailTemplate.subject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "enable-anonymous-user" => Some(("enableAnonymousUser", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "authorized-domains" => Some(("authorizedDomains", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "reset-password-template.body" => Some(("resetPasswordTemplate.body", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reset-password-template.from-display-name" => Some(("resetPasswordTemplate.fromDisplayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "reset-password-template.from" => Some(("resetPasswordTemplate.from", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -870,7 +876,7 @@ impl<'n> Engine<'n> { "change-email-template.reply-to" => Some(("changeEmailTemplate.replyTo", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "change-email-template.subject" => Some(("changeEmailTemplate.subject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-password-user", "api-key", "body", "change-email-template", "delegated-project-number", "enable-anonymous-user", "format", "from", "from-display-name", "legacy-reset-password-template", "reply-to", "reset-password-template", "subject", "use-email-sending", "verify-email-template"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["allow-password-user", "api-key", "authorized-domains", "body", "change-email-template", "delegated-project-number", "enable-anonymous-user", "format", "from", "from-display-name", "legacy-reset-password-template", "reply-to", "reset-password-template", "subject", "use-email-sending", "verify-email-template"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1033,16 +1039,15 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { - "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "captcha-challenge" => Some(("captchaChallenge", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "instance-id" => Some(("instanceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "id-token" => Some(("idToken", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "captcha-response" => Some(("captchaResponse", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "return-secure-token" => Some(("returnSecureToken", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "id-token" => Some(("idToken", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "captcha-challenge" => Some(("captchaChallenge", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "password" => Some(("password", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["captcha-challenge", "captcha-response", "display-name", "email", "id-token", "instance-id", "password", "return-secure-token"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["captcha-challenge", "captcha-response", "display-name", "email", "id-token", "instance-id", "password"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1218,8 +1223,9 @@ impl<'n> Engine<'n> { "request-uri" => Some(("requestUri", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "return-secure-token" => Some(("returnSecureToken", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "return-refresh-token" => Some(("returnRefreshToken", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "return-idp-credential" => Some(("returnIdpCredential", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["delegated-project-number", "id-token", "instance-id", "pending-id-token", "post-body", "request-uri", "return-refresh-token", "return-secure-token", "session-id"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["delegated-project-number", "id-token", "instance-id", "pending-id-token", "post-body", "request-uri", "return-idp-credential", "return-refresh-token", "return-secure-token", "session-id"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1302,8 +1308,9 @@ impl<'n> Engine<'n> { "instance-id" => Some(("instanceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "return-secure-token" => Some(("returnSecureToken", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "token" => Some(("token", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "delegated-project-number" => Some(("delegatedProjectNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-id", "return-secure-token", "token"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["delegated-project-number", "instance-id", "return-secure-token", "token"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1959,7 +1966,7 @@ fn main() { let mut app = App::new("identitytoolkit3") .author("Sebastian Thiel ") - .version("0.3.6+20160324") + .version("0.3.6+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/identitytoolkit3/Cargo.toml b/gen/identitytoolkit3/Cargo.toml index ec14155cb6..da84d3ab5a 100644 --- a/gen/identitytoolkit3/Cargo.toml +++ b/gen/identitytoolkit3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-identitytoolkit3" -version = "0.1.14+20160324" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/identitytoolkit3/README.md b/gen/identitytoolkit3/README.md index a42db95f0a..79d9a24658 100644 --- a/gen/identitytoolkit3/README.md +++ b/gen/identitytoolkit3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-identitytoolkit3` library allows access to all features of the *Google Identity Toolkit* service. -This documentation was generated from *Identity Toolkit* crate version *0.1.14+20160324*, where *20160324* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Identity Toolkit* crate version *0.1.14+20160812*, where *20160812* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *Identity Toolkit* *v3* API can be found at the [official documentation site](https://developers.google.com/identity-toolkit/v3/). diff --git a/gen/identitytoolkit3/src/lib.rs b/gen/identitytoolkit3/src/lib.rs index bd32068209..595dc3bfe8 100644 --- a/gen/identitytoolkit3/src/lib.rs +++ b/gen/identitytoolkit3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *Identity Toolkit* crate version *0.1.14+20160324*, where *20160324* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Identity Toolkit* crate version *0.1.14+20160812*, where *20160812* is the exact revision of the *identitytoolkit:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *Identity Toolkit* *v3* API can be found at the //! [official documentation site](https://developers.google.com/identity-toolkit/v3/). diff --git a/gen/identitytoolkit3/src/lib.rs.in b/gen/identitytoolkit3/src/lib.rs.in index 2295dcf970..f1c3387319 100644 --- a/gen/identitytoolkit3/src/lib.rs.in +++ b/gen/identitytoolkit3/src/lib.rs.in @@ -503,8 +503,17 @@ impl ResponseResult for IdentitytoolkitRelyingpartySignOutUserResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct IdentitytoolkitRelyingpartyCreateAuthUriRequest { + /// The hosted domain to restrict sign-in to accounts at that domain for Google Apps hosted accounts. + #[serde(rename="hostedDomain")] + pub hosted_domain: Option, + /// The session_id passed by client. + #[serde(rename="sessionId")] + pub session_id: Option, /// The email or federated ID of the user. pub identifier: Option, + /// Explicitly specify the auth flow type. Currently only support "CODE_FLOW" type. The field is only used for Google provider. + #[serde(rename="authFlowType")] + pub auth_flow_type: Option, /// Additional oauth scopes, beyond the basid user profile, that the user would be prompted to grant #[serde(rename="oauthScope")] pub oauth_scope: Option, @@ -547,24 +556,21 @@ impl RequestValue for IdentitytoolkitRelyingpartyCreateAuthUriRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct IdentitytoolkitRelyingpartySignupNewUserRequest { + /// Response to the captcha. + #[serde(rename="captchaResponse")] + pub captcha_response: Option, /// The name of the user. #[serde(rename="displayName")] pub display_name: Option, + /// The captcha challenge. + #[serde(rename="captchaChallenge")] + pub captcha_challenge: Option, /// Instance id token of the app. #[serde(rename="instanceId")] pub instance_id: Option, /// The GITKit token of the authenticated user. #[serde(rename="idToken")] pub id_token: Option, - /// The captcha challenge. - #[serde(rename="captchaChallenge")] - pub captcha_challenge: Option, - /// Response to the captcha. - #[serde(rename="captchaResponse")] - pub captcha_response: Option, - /// Whether return sts id token and refresh token instead of gitkit token. - #[serde(rename="returnSecureToken")] - pub return_secure_token: Option, /// The new password of the user. pub password: Option, /// The email of the user. @@ -620,6 +626,9 @@ impl RequestValue for IdentitytoolkitRelyingpartyDownloadAccountRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SetAccountInfoResponseProviderUserInfo { + /// User's identifier at IDP. + #[serde(rename="federatedId")] + pub federated_id: Option, /// The IdP ID. For whitelisted IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. #[serde(rename="providerId")] pub provider_id: Option, @@ -654,6 +663,9 @@ pub struct IdentitytoolkitRelyingpartyVerifyCustomTokenRequest { pub return_secure_token: Option, /// The custom token to verify pub token: Option, + /// GCP project number of the requesting delegated app. Currently only intended for Firebase V1 migration. + #[serde(rename="delegatedProjectNumber")] + pub delegated_project_number: Option, } impl RequestValue for IdentitytoolkitRelyingpartyVerifyCustomTokenRequest {} @@ -698,21 +710,27 @@ pub struct SetAccountInfoResponse { /// The name of the user. #[serde(rename="displayName")] pub display_name: Option, - /// The new email the user attempts to change to. - #[serde(rename="newEmail")] - pub new_email: Option, + /// The local ID of the user. + #[serde(rename="localId")] + pub local_id: Option, /// The photo url of the user. #[serde(rename="photoUrl")] pub photo_url: Option, /// The Gitkit id token to login the newly sign up user. #[serde(rename="idToken")] pub id_token: Option, - /// The user's profiles at the associated IdPs. - #[serde(rename="providerUserInfo")] - pub provider_user_info: Option>, + /// The user's hashed password. + #[serde(rename="passwordHash")] + pub password_hash: Option, + /// The new email the user attempts to change to. + #[serde(rename="newEmail")] + pub new_email: Option, /// If idToken is STS id token, then this field will be refresh token. #[serde(rename="refreshToken")] pub refresh_token: Option, + /// The user's profiles at the associated IdPs. + #[serde(rename="providerUserInfo")] + pub provider_user_info: Option>, /// The email of the user. pub email: Option, } @@ -758,6 +776,9 @@ pub struct IdentitytoolkitRelyingpartyVerifyAssertionRequest { /// Whether to return refresh tokens. #[serde(rename="returnRefreshToken")] pub return_refresh_token: Option, + /// Whether return 200 and IDP credential rather than throw exception when federated id is already linked. + #[serde(rename="returnIdpCredential")] + pub return_idp_credential: Option, } impl RequestValue for IdentitytoolkitRelyingpartyVerifyAssertionRequest {} @@ -856,6 +877,9 @@ pub struct IdentitytoolkitRelyingpartySetAccountInfoRequest { /// Instance id token of the app. #[serde(rename="instanceId")] pub instance_id: Option, + /// Last login timestamp. + #[serde(rename="lastLoginAt")] + pub last_login_at: Option, /// Whether to disable the user. #[serde(rename="disableUser")] pub disable_user: Option, @@ -867,6 +891,9 @@ pub struct IdentitytoolkitRelyingpartySetAccountInfoRequest { /// The name of the user. #[serde(rename="displayName")] pub display_name: Option, + /// The timestamp when the account is created. + #[serde(rename="createdAt")] + pub created_at: Option, /// The attributes users request to delete. #[serde(rename="deleteAttribute")] pub delete_attribute: Option>, @@ -956,20 +983,26 @@ pub struct UserInfoProviderUserInfo { /// User's identifier at IDP. #[serde(rename="federatedId")] pub federated_id: Option, - /// The IdP ID. For white listed IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. - #[serde(rename="providerId")] - pub provider_id: Option, /// The user's display name at the IDP. #[serde(rename="displayName")] pub display_name: Option, /// The user's photo url at the IDP. #[serde(rename="photoUrl")] pub photo_url: Option, + /// Raw IDP-returned user info. + #[serde(rename="rawUserInfo")] + pub raw_user_info: Option, + /// The IdP ID. For white listed IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. + #[serde(rename="providerId")] + pub provider_id: Option, /// User's raw identifier directly returned from IDP. #[serde(rename="rawId")] pub raw_id: Option, /// User's email at IDP. pub email: Option, + /// User's screen name at Twitter. + #[serde(rename="screenName")] + pub screen_name: Option, } impl NestedType for UserInfoProviderUserInfo {} @@ -999,6 +1032,9 @@ pub struct IdentitytoolkitRelyingpartySetProjectConfigRequest { /// Whether to enable anonymous user. #[serde(rename="enableAnonymousUser")] pub enable_anonymous_user: Option, + /// Authorized domains for widget redirect. + #[serde(rename="authorizedDomains")] + pub authorized_domains: Option>, /// Change email template. #[serde(rename="changeEmailTemplate")] pub change_email_template: Option, @@ -1045,6 +1081,9 @@ pub struct VerifyAssertionResponse { /// It's the identifier param in the createAuthUri request if the identifier is an email. It can be used to check whether the user input email is different from the asserted email. #[serde(rename="inputEmail")] pub input_email: Option, + /// Raw IDP-returned user info. + #[serde(rename="rawUserInfo")] + pub raw_user_info: Option, /// The custom scheme used by mobile app. #[serde(rename="appScheme")] pub app_scheme: Option, @@ -1068,28 +1107,37 @@ pub struct VerifyAssertionResponse { pub nick_name: Option, /// The email returned by the IdP. NOTE: The federated login user may not own the email. pub email: Option, + /// The screen_name of a Twitter user. + #[serde(rename="screenName")] + pub screen_name: Option, + /// URL for OTA app installation. + #[serde(rename="appInstallationUrl")] + pub app_installation_url: Option, + /// Client error code. + #[serde(rename="errorMessage")] + pub error_message: Option, /// The OAuth1 access token secret. #[serde(rename="oauthTokenSecret")] pub oauth_token_secret: Option, - /// The language preference of the user. - pub language: Option, /// Whether the assertion is from a non-trusted IDP and need account linking confirmation. #[serde(rename="needConfirmation")] pub need_confirmation: Option, - /// The display name of the user. - #[serde(rename="displayName")] - pub display_name: Option, + /// The OIDC id token. + #[serde(rename="oauthIdToken")] + pub oauth_id_token: Option, /// The full name of the user. #[serde(rename="fullName")] pub full_name: Option, + /// The display name of the user. + #[serde(rename="displayName")] + pub display_name: Option, /// The fixed string "identitytoolkit#VerifyAssertionResponse". pub kind: Option, /// If idToken is STS id token, then this field will be refresh token. #[serde(rename="refreshToken")] pub refresh_token: Option, - /// URL for OTA app installation. - #[serde(rename="appInstallationUrl")] - pub app_installation_url: Option, + /// The language preference of the user. + pub language: Option, /// The OAuth2 access token. #[serde(rename="oauthAccessToken")] pub oauth_access_token: Option, @@ -1146,13 +1194,16 @@ pub struct IdpConfig { pub experiment_percent: Option, /// OAuth2 client secret. pub secret: Option, + /// OAuth2 provider. + pub provider: Option, + /// Whitelisted client IDs for audience check. + #[serde(rename="whitelistedAudiences")] + pub whitelisted_audiences: Option>, /// Whether this IDP is enabled. pub enabled: Option, /// OAuth2 client ID. #[serde(rename="clientId")] pub client_id: Option, - /// OAuth2 provider. - pub provider: Option, } impl Part for IdpConfig {} @@ -1235,6 +1286,9 @@ impl RequestValue for IdentitytoolkitRelyingpartyUploadAccountRequest {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserInfo { + /// last login timestamp. + #[serde(rename="lastLoginAt")] + pub last_login_at: Option, /// The name of the user. #[serde(rename="displayName")] pub display_name: Option, @@ -1267,6 +1321,12 @@ pub struct UserInfo { pub salt: Option, /// The email of the user. pub email: Option, + /// User creation timestamp. + #[serde(rename="createdAt")] + pub created_at: Option, + /// User's screen name at Twitter. + #[serde(rename="screenName")] + pub screen_name: Option, } impl Part for UserInfo {} diff --git a/gen/kgsearch1-cli/Cargo.toml b/gen/kgsearch1-cli/Cargo.toml index 24f7ee42ba..9bcf6a1832 100644 --- a/gen/kgsearch1-cli/Cargo.toml +++ b/gen/kgsearch1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "kgsearch1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-kgsearch1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-kgsearch1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-kgsearch1] diff --git a/gen/kgsearch1/Cargo.toml b/gen/kgsearch1/Cargo.toml index 4e312d5989..acfbefe669 100644 --- a/gen/kgsearch1/Cargo.toml +++ b/gen/kgsearch1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/licensing1-cli/Cargo.toml b/gen/licensing1-cli/Cargo.toml index bd52b28a8b..05d88ace6c 100644 --- a/gen/licensing1-cli/Cargo.toml +++ b/gen/licensing1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "licensing1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-licensing1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-licensing1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-licensing1] diff --git a/gen/licensing1/Cargo.toml b/gen/licensing1/Cargo.toml index 4714b34441..d5fb1596a4 100644 --- a/gen/licensing1/Cargo.toml +++ b/gen/licensing1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/logging2_beta1-cli/Cargo.toml b/gen/logging2_beta1-cli/Cargo.toml index 7890510d92..bbde679383 100644 --- a/gen/logging2_beta1-cli/Cargo.toml +++ b/gen/logging2_beta1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "logging2-beta1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-logging2_beta1] diff --git a/gen/logging2_beta1/Cargo.toml b/gen/logging2_beta1/Cargo.toml index 1c27487531..e151af0b46 100644 --- a/gen/logging2_beta1/Cargo.toml +++ b/gen/logging2_beta1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/manager1_beta2-cli/Cargo.toml b/gen/manager1_beta2-cli/Cargo.toml index ce6a95bd8e..8b48e4135d 100644 --- a/gen/manager1_beta2-cli/Cargo.toml +++ b/gen/manager1_beta2-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "manager1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-manager1_beta2] diff --git a/gen/manager1_beta2/Cargo.toml b/gen/manager1_beta2/Cargo.toml index c2102d0df2..16aa3452a8 100644 --- a/gen/manager1_beta2/Cargo.toml +++ b/gen/manager1_beta2/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/mirror1-cli/Cargo.toml b/gen/mirror1-cli/Cargo.toml index 176970fd38..574e441fee 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+20151206" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "mirror1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-mirror1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-mirror1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-mirror1] diff --git a/gen/mirror1-cli/README.md b/gen/mirror1-cli/README.md index 51352583e9..4bdd175fb0 100644 --- a/gen/mirror1-cli/README.md +++ b/gen/mirror1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *mirror* API at revision *20151206*. The CLI is at version *0.3.6*. +This documentation was generated from the *mirror* API at revision *20160616*. The CLI is at version *0.3.6*. ```bash mirror1 [options] diff --git a/gen/mirror1-cli/mkdocs.yml b/gen/mirror1-cli/mkdocs.yml index 08deabf602..d9043b4ee2 100644 --- a/gen/mirror1-cli/mkdocs.yml +++ b/gen/mirror1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: mirror v0.3.6+20151206 +site_name: mirror v0.3.6+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 82d4fd79e5..3bb634e665 100644 --- a/gen/mirror1-cli/src/main.rs +++ b/gen/mirror1-cli/src/main.rs @@ -2563,8 +2563,8 @@ fn main() { let mut app = App::new("mirror1") .author("Sebastian Thiel ") - .version("0.3.6+20151206") - .about("API for interacting with Glass users via the timeline.") + .version("0.3.6+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") .long("scope") diff --git a/gen/mirror1/Cargo.toml b/gen/mirror1/Cargo.toml index 3d0e8d957a..7d6bad106c 100644 --- a/gen/mirror1/Cargo.toml +++ b/gen/mirror1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-mirror1" -version = "0.1.14+20151206" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/mirror1/README.md b/gen/mirror1/README.md index 29dbdcc995..44ab98add3 100644 --- a/gen/mirror1/README.md +++ b/gen/mirror1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-mirror1` library allows access to all features of the *Google mirror* service. -This documentation was generated from *mirror* crate version *0.1.14+20151206*, where *20151206* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *mirror* crate version *0.1.14+20160616*, where *20160616* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *mirror* *v1* API can be found at the [official documentation site](https://developers.google.com/glass). diff --git a/gen/mirror1/src/lib.rs b/gen/mirror1/src/lib.rs index 2c987b770e..a612017ea4 100644 --- a/gen/mirror1/src/lib.rs +++ b/gen/mirror1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *mirror* crate version *0.1.14+20151206*, where *20151206* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *mirror* crate version *0.1.14+20160616*, where *20160616* is the exact revision of the *mirror:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *mirror* *v1* API can be found at the //! [official documentation site](https://developers.google.com/glass). diff --git a/gen/monitoring3-cli/Cargo.toml b/gen/monitoring3-cli/Cargo.toml index 4df601c147..7eb25819ca 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+20160321" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "monitoring3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-monitoring3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-monitoring3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-monitoring3] diff --git a/gen/monitoring3-cli/README.md b/gen/monitoring3-cli/README.md index d85b6c97ea..d8c5775d32 100644 --- a/gen/monitoring3-cli/README.md +++ b/gen/monitoring3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *monitoring* API at revision *20160321*. The CLI is at version *0.3.6*. +This documentation was generated from the *monitoring* API at revision *20160425*. The CLI is at version *0.3.6*. ```bash monitoring3 [options] diff --git a/gen/monitoring3-cli/mkdocs.yml b/gen/monitoring3-cli/mkdocs.yml index 89388ee54d..d95b383f3f 100644 --- a/gen/monitoring3-cli/mkdocs.yml +++ b/gen/monitoring3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: monitoring v0.3.6+20160321 +site_name: monitoring v0.3.6+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 b68424531c..4ed4ca5df3 100644 --- a/gen/monitoring3-cli/src/main.rs +++ b/gen/monitoring3-cli/src/main.rs @@ -1467,7 +1467,7 @@ fn main() { Some(false)), ]), ("metric-descriptors-get", - Some(r##"Gets a single metric descriptor."##), + Some(r##"Gets a single metric descriptor. This method does not require a Stackdriver account."##), "Details at http://byron.github.io/google-apis-rs/google_monitoring3_cli/projects_metric-descriptors-get", vec![ (Some(r##"name"##), @@ -1489,7 +1489,7 @@ fn main() { Some(false)), ]), ("metric-descriptors-list", - Some(r##"Lists metric descriptors that match a filter."##), + Some(r##"Lists metric descriptors that match a filter. This method does not require a Stackdriver account."##), "Details at http://byron.github.io/google-apis-rs/google_monitoring3_cli/projects_metric-descriptors-list", vec![ (Some(r##"name"##), @@ -1511,7 +1511,7 @@ fn main() { Some(false)), ]), ("monitored-resource-descriptors-get", - Some(r##"Gets a single monitored resource descriptor."##), + Some(r##"Gets a single monitored resource descriptor. This method does not require a Stackdriver account."##), "Details at http://byron.github.io/google-apis-rs/google_monitoring3_cli/projects_monitored-resource-descriptors-get", vec![ (Some(r##"name"##), @@ -1533,7 +1533,7 @@ fn main() { Some(false)), ]), ("monitored-resource-descriptors-list", - Some(r##"Lists monitored resource descriptors that match a filter."##), + Some(r##"Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account."##), "Details at http://byron.github.io/google-apis-rs/google_monitoring3_cli/projects_monitored-resource-descriptors-list", vec![ (Some(r##"name"##), @@ -1583,7 +1583,7 @@ fn main() { Some(false)), ]), ("time-series-list", - Some(r##"Lists time series that match a filter."##), + Some(r##"Lists time series that match a filter. This method does not require a Stackdriver account."##), "Details at http://byron.github.io/google-apis-rs/google_monitoring3_cli/projects_time-series-list", vec![ (Some(r##"name"##), @@ -1610,8 +1610,8 @@ fn main() { let mut app = App::new("monitoring3") .author("Sebastian Thiel ") - .version("0.3.6+20160321") - .about("The Google Monitoring API lets you manage your monitoring data and configurations.") + .version("0.3.6+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") .long("scope") diff --git a/gen/monitoring3/Cargo.toml b/gen/monitoring3/Cargo.toml index 410d79fcd7..c40e992719 100644 --- a/gen/monitoring3/Cargo.toml +++ b/gen/monitoring3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-monitoring3" -version = "0.1.14+20160321" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/monitoring3/README.md b/gen/monitoring3/README.md index 2573815e6c..62c1a85159 100644 --- a/gen/monitoring3/README.md +++ b/gen/monitoring3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-monitoring3` library allows access to all features of the *Google monitoring* service. -This documentation was generated from *monitoring* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *monitoring:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *monitoring* crate version *0.1.14+20160425*, where *20160425* is the exact revision of the *monitoring:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *monitoring* *v3* API can be found at the [official documentation site](https://cloud.google.com/monitoring/api/). diff --git a/gen/monitoring3/src/lib.rs b/gen/monitoring3/src/lib.rs index f7dc9904b7..184dd39b7b 100644 --- a/gen/monitoring3/src/lib.rs +++ b/gen/monitoring3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *monitoring* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *monitoring:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *monitoring* crate version *0.1.14+20160425*, where *20160425* is the exact revision of the *monitoring:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *monitoring* *v3* API can be found at the //! [official documentation site](https://cloud.google.com/monitoring/api/). diff --git a/gen/monitoring3/src/lib.rs.in b/gen/monitoring3/src/lib.rs.in index d9198d6da0..a554fc4c58 100644 --- a/gen/monitoring3/src/lib.rs.in +++ b/gen/monitoring3/src/lib.rs.in @@ -174,10 +174,10 @@ impl<'a, C, A> Monitoring /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TimeInterval { - /// (required) The end of the interval. The interval includes this time. + /// Required. The end of the interval. The interval includes this time. #[serde(rename="endTime")] pub end_time: Option, - /// (optional) If omitted, the interval is a point in time, `endTime`. If `startTime` is present, it must be earlier than (less than) `endTime`. The interval begins after `startTime`—it does not include `startTime`. + /// If this value is omitted, the interval is a point in time, `endTime`. If `startTime` is present, it must be earlier than (less than) `endTime`. The interval begins after `startTime`—it does not include `startTime`. #[serde(rename="startTime")] pub start_time: Option, } @@ -776,7 +776,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets a single metric descriptor. + /// Gets a single metric descriptor. This method does not require a Stackdriver account. /// /// # Arguments /// @@ -888,7 +888,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists monitored resource descriptors that match a filter. + /// Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. /// /// # Arguments /// @@ -968,7 +968,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists metric descriptors that match a filter. + /// Lists metric descriptors that match a filter. This method does not require a Stackdriver account. /// /// # Arguments /// @@ -988,7 +988,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets a single monitored resource descriptor. + /// Gets a single monitored resource descriptor. This method does not require a Stackdriver account. /// /// # Arguments /// @@ -1042,7 +1042,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists time series that match a filter. + /// Lists time series that match a filter. This method does not require a Stackdriver account. /// /// # Arguments /// @@ -1077,7 +1077,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { // CallBuilders ### // ################# -/// Gets a single metric descriptor. +/// Gets a single metric descriptor. This method does not require a Stackdriver account. /// /// A builder for the *metricDescriptors.get* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -2602,14 +2602,14 @@ impl<'a, C, A> ProjectGroupMemberListCall<'a, C, A> where C: BorrowMut ProjectGroupMemberListCall<'a, C, A> { self._interval_start_time = Some(new_value.to_string()); self } - /// (required) The end of the interval. The interval includes this time. + /// Required. The end of the interval. The interval includes this time. /// /// Sets the *interval.end time* query property to the given value. pub fn interval_end_time(mut self, new_value: &str) -> ProjectGroupMemberListCall<'a, C, A> { @@ -2681,7 +2681,7 @@ impl<'a, C, A> ProjectGroupMemberListCall<'a, C, A> where C: BorrowMut ProjectGroupListCall<'a, C, A> where C: BorrowMut, } -/// Lists metric descriptors that match a filter. +/// Lists metric descriptors that match a filter. This method does not require a Stackdriver account. /// /// A builder for the *metricDescriptors.list* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -4100,7 +4100,7 @@ impl<'a, C, A> ProjectMetricDescriptorListCall<'a, C, A> where C: BorrowMut ProjectGroupDeleteCall<'a, C, A> where C: BorrowMut ProjectTimeSeryListCall<'a, C, A> where C: BorrowMut ProjectTimeSeryListCall<'a, C, A> { self._interval_start_time = Some(new_value.to_string()); self } - /// (required) The end of the interval. The interval includes this time. + /// Required. The end of the interval. The interval includes this time. /// /// Sets the *interval.end time* query property to the given value. pub fn interval_end_time(mut self, new_value: &str) -> ProjectTimeSeryListCall<'a, C, A> { diff --git a/gen/pagespeedonline2-cli/Cargo.toml b/gen/pagespeedonline2-cli/Cargo.toml index dc8b1d62df..65c5aee364 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+20160306" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "pagespeedonline2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-pagespeedonline2/nightly" with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-pagespeedonline2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pagespeedonline2] diff --git a/gen/pagespeedonline2-cli/README.md b/gen/pagespeedonline2-cli/README.md index 77a55817c6..17d45a3905 100644 --- a/gen/pagespeedonline2-cli/README.md +++ b/gen/pagespeedonline2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *pagespeedonline* API at revision *20160306*. The CLI is at version *0.3.6*. +This documentation was generated from the *pagespeedonline* API at revision *20160811*. The CLI is at version *0.3.6*. ```bash pagespeedonline2 [options] diff --git a/gen/pagespeedonline2-cli/mkdocs.yml b/gen/pagespeedonline2-cli/mkdocs.yml index 7d97c35a78..bf544ebe99 100644 --- a/gen/pagespeedonline2-cli/mkdocs.yml +++ b/gen/pagespeedonline2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: pagespeedonline v0.3.6+20160306 +site_name: pagespeedonline v0.3.6+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 e06106a43c..5cad0c244e 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+20160306") + .version("0.3.6+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/pagespeedonline2/Cargo.toml b/gen/pagespeedonline2/Cargo.toml index c80b0df53f..1ebc9a3c4c 100644 --- a/gen/pagespeedonline2/Cargo.toml +++ b/gen/pagespeedonline2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-pagespeedonline2" -version = "0.1.14+20160306" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/pagespeedonline2/README.md b/gen/pagespeedonline2/README.md index de7ad0af29..c1e0641a88 100644 --- a/gen/pagespeedonline2/README.md +++ b/gen/pagespeedonline2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-pagespeedonline2` library allows access to all features of the *Google pagespeedonline* service. -This documentation was generated from *pagespeedonline* crate version *0.1.14+20160306*, where *20160306* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *pagespeedonline* crate version *0.1.14+20160811*, where *20160811* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *pagespeedonline* *v2* API can be found at the [official documentation site](https://developers.google.com/speed/docs/insights/v2/getting-started). diff --git a/gen/pagespeedonline2/src/lib.rs b/gen/pagespeedonline2/src/lib.rs index 0992074d26..acd18cbb50 100644 --- a/gen/pagespeedonline2/src/lib.rs +++ b/gen/pagespeedonline2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *pagespeedonline* crate version *0.1.14+20160306*, where *20160306* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *pagespeedonline* crate version *0.1.14+20160811*, where *20160811* is the exact revision of the *pagespeedonline:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *pagespeedonline* *v2* API can be found at the //! [official documentation site](https://developers.google.com/speed/docs/insights/v2/getting-started). diff --git a/gen/partners2-cli/Cargo.toml b/gen/partners2-cli/Cargo.toml index 755ef9b7b0..05488078a4 100644 --- a/gen/partners2-cli/Cargo.toml +++ b/gen/partners2-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "partners2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-partners2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-partners2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-partners2] diff --git a/gen/partners2/Cargo.toml b/gen/partners2/Cargo.toml index baf2ad4c80..2d81c4238a 100644 --- a/gen/partners2/Cargo.toml +++ b/gen/partners2/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/people1-cli/Cargo.toml b/gen/people1-cli/Cargo.toml index 4574bfbd6f..6af990d8ef 100644 --- a/gen/people1-cli/Cargo.toml +++ b/gen/people1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "people1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-people1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-people1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-people1] diff --git a/gen/people1/Cargo.toml b/gen/people1/Cargo.toml index 2f4f69d5c6..aae1ed7d74 100644 --- a/gen/people1/Cargo.toml +++ b/gen/people1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/playmoviespartner1-cli/Cargo.toml b/gen/playmoviespartner1-cli/Cargo.toml index dfe64dfa96..edd1a0708e 100644 --- a/gen/playmoviespartner1-cli/Cargo.toml +++ b/gen/playmoviespartner1-cli/Cargo.toml @@ -4,9 +4,9 @@ [package] name = "google-playmoviespartner1-cli" -version = "0.3.6+20150812" +version = "0.3.6+20160518" authors = ["Sebastian Thiel "] -description = "A complete library to interact with playmoviespartner (protocol v1)" +description = "A complete library to interact with Play Movies (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/playmoviespartner1-cli" homepage = "https://developers.google.com/playmoviespartner/" documentation = "http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli" @@ -19,10 +19,10 @@ name = "playmoviespartner1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-playmoviespartner1/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-playmoviespartner1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-playmoviespartner1] diff --git a/gen/playmoviespartner1-cli/README.md b/gen/playmoviespartner1-cli/README.md index 13caff5234..29e2a1947b 100644 --- a/gen/playmoviespartner1-cli/README.md +++ b/gen/playmoviespartner1-cli/README.md @@ -3,14 +3,14 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/cli/README.md.mako' DO NOT EDIT ! --> -The `playmoviespartner1` command-line interface *(CLI)* allows to use most features of the *Google playmoviespartner* service from the comfort of your terminal. +The `playmoviespartner1` command-line interface *(CLI)* allows to use most features of the *Google Play Movies* 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 *playmoviespartner* API can be found at the +Everything else about the *Play Movies* API can be found at the [official documentation site](https://developers.google.com/playmoviespartner/). # Downloads @@ -24,12 +24,15 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *playmoviespartner* API at revision *20150812*. 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 *0.3.6*. ```bash playmoviespartner1 [options] accounts + avails-get [-p ]... [-o ] avails-list [-p ]... [-o ] + components-list [-p ]... [-o ] + components-type-get [-p ]... [-o ] experience-locales-get [-p ]... [-o ] experience-locales-list [-p ]... [-o ] orders-get [-p ]... [-o ] diff --git a/gen/playmoviespartner1-cli/mkdocs.yml b/gen/playmoviespartner1-cli/mkdocs.yml index 55cab32259..0deafa9b8a 100644 --- a/gen/playmoviespartner1-cli/mkdocs.yml +++ b/gen/playmoviespartner1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: playmoviespartner v0.3.6+20150812 +site_name: Play Movies v0.3.6+20160518 site_url: http://byron.github.io/google-apis-rs/google-playmoviespartner1-cli site_description: Write integrating applications with bcore @@ -9,7 +9,10 @@ site_dir: build_html pages: - ['index.md', 'Home'] +- ['accounts_avails-get.md', 'Accounts', 'Avails Get'] - ['accounts_avails-list.md', 'Accounts', 'Avails List'] +- ['accounts_components-list.md', 'Accounts', 'Components List'] +- ['accounts_components-type-get.md', 'Accounts', 'Components Type Get'] - ['accounts_experience-locales-get.md', 'Accounts', 'Experience Locales Get'] - ['accounts_experience-locales-list.md', 'Accounts', 'Experience Locales List'] - ['accounts_orders-get.md', 'Accounts', 'Orders Get'] diff --git a/gen/playmoviespartner1-cli/src/main.rs b/gen/playmoviespartner1-cli/src/main.rs index 5968debf30..fe100832b0 100644 --- a/gen/playmoviespartner1-cli/src/main.rs +++ b/gen/playmoviespartner1-cli/src/main.rs @@ -38,13 +38,65 @@ enum DoitError { struct Engine<'n> { opt: ArgMatches<'n>, - hub: api::Playmoviespartner>, + hub: api::PlayMovies>, gp: Vec<&'static str>, gpm: Vec<(&'static str, &'static str)>, } impl<'n> Engine<'n> { + fn _accounts_avails_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().avails_get(opt.value_of("account-id").unwrap_or(""), opt.value_of("avail-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 _accounts_avails_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.accounts().avails_list(opt.value_of("account-id").unwrap_or("")); @@ -72,6 +124,9 @@ impl<'n> Engine<'n> { "page-size" => { call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); }, + "alt-ids" => { + call = call.add_alt_ids(value.unwrap_or("")); + }, "alt-id" => { call = call.alt_id(value.unwrap_or("")); }, @@ -88,7 +143,154 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["pph-names", "alt-id", "video-ids", "page-size", "page-token", "title", "studio-names", "territories"].iter().map(|v|*v)); + v.extend(["pph-names", "alt-id", "video-ids", "page-size", "page-token", "title", "studio-names", "territories", "alt-ids"].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 _accounts_components_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().components_list(opt.value_of("account-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 { + "title-level-eidr" => { + call = call.title_level_eidr(value.unwrap_or("")); + }, + "studio-names" => { + call = call.add_studio_names(value.unwrap_or("")); + }, + "status" => { + call = call.add_status(value.unwrap_or("")); + }, + "presentation-id" => { + call = call.presentation_id(value.unwrap_or("")); + }, + "pph-names" => { + call = call.add_pph_names(value.unwrap_or("")); + }, + "playable-sequence-id" => { + call = call.playable_sequence_id(value.unwrap_or("")); + }, + "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")); + }, + "inventory-id" => { + call = call.inventory_id(value.unwrap_or("")); + }, + "filename" => { + call = call.filename(value.unwrap_or("")); + }, + "el-id" => { + call = call.el_id(value.unwrap_or("")); + }, + "edit-level-eidr" => { + call = call.edit_level_eidr(value.unwrap_or("")); + }, + "custom-id" => { + call = call.custom_id(value.unwrap_or("")); + }, + "alt-cut-id" => { + call = call.alt_cut_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(["status", "presentation-id", "title-level-eidr", "page-size", "alt-cut-id", "studio-names", "filename", "page-token", "pph-names", "edit-level-eidr", "inventory-id", "el-id", "custom-id", "playable-sequence-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 _accounts_components_type_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.accounts().components_type_get(opt.value_of("account-id").unwrap_or(""), opt.value_of("component-id").unwrap_or(""), opt.value_of("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 } )); } } @@ -312,6 +514,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "video-ids" => { + call = call.add_video_ids(value.unwrap_or("")); + }, "studio-names" => { call = call.add_studio_names(value.unwrap_or("")); }, @@ -346,7 +551,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["status", "pph-names", "name", "page-size", "studio-names", "page-token", "custom-id"].iter().map(|v|*v)); + v.extend(["status", "pph-names", "video-ids", "page-size", "studio-names", "page-token", "custom-id", "name"].iter().map(|v|*v)); v } )); } } @@ -447,6 +652,9 @@ impl<'n> Engine<'n> { "studio-names" => { call = call.add_studio_names(value.unwrap_or("")); }, + "season-ids" => { + call = call.add_season_ids(value.unwrap_or("")); + }, "pph-names" => { call = call.add_pph_names(value.unwrap_or("")); }, @@ -459,6 +667,9 @@ impl<'n> Engine<'n> { "name" => { call = call.name(value.unwrap_or("")); }, + "mids" => { + call = call.add_mids(value.unwrap_or("")); + }, "countries" => { call = call.add_countries(value.unwrap_or("")); }, @@ -475,7 +686,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["pph-names", "video-ids", "page-size", "countries", "studio-names", "video-id", "page-token", "name"].iter().map(|v|*v)); + v.extend(["pph-names", "season-ids", "video-ids", "page-size", "countries", "studio-names", "video-id", "page-token", "mids", "name"].iter().map(|v|*v)); v } )); } } @@ -516,9 +727,18 @@ impl<'n> Engine<'n> { match self.opt.subcommand() { ("accounts", Some(opt)) => { match opt.subcommand() { + ("avails-get", Some(opt)) => { + call_result = self._accounts_avails_get(opt, dry_run, &mut err); + }, ("avails-list", Some(opt)) => { call_result = self._accounts_avails_list(opt, dry_run, &mut err); }, + ("components-list", Some(opt)) => { + call_result = self._accounts_components_list(opt, dry_run, &mut err); + }, + ("components-type-get", Some(opt)) => { + call_result = self._accounts_components_type_get(opt, dry_run, &mut err); + }, ("experience-locales-get", Some(opt)) => { call_result = self._accounts_experience_locales_get(opt, dry_run, &mut err); }, @@ -597,7 +817,7 @@ impl<'n> Engine<'n> { }; let engine = Engine { opt: opt, - hub: api::Playmoviespartner::new(client, auth), + hub: api::PlayMovies::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"), @@ -629,7 +849,35 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("accounts", "methods: 'avails-list', 'experience-locales-get', 'experience-locales-list', 'orders-get', 'orders-list', 'store-infos-country-get' and 'store-infos-list'", vec![ + ("accounts", "methods: 'avails-get', 'avails-list', 'components-list', 'components-type-get', 'experience-locales-get', 'experience-locales-list', 'orders-get', 'orders-list', 'store-infos-country-get' and 'store-infos-list'", vec![ + ("avails-get", + Some(r##"Get an Avail given its avail group id and avail id."##), + "Details at http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli/accounts_avails-get", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"REQUIRED. See _General rules_ for more information about this field."##), + Some(true), + Some(false)), + + (Some(r##"avail-id"##), + None, + Some(r##"REQUIRED. Avail ID."##), + 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)), + ]), ("avails-list", Some(r##"List Avails owned or managed by the partner. See _Authentication and Authorization rules_ and _List methods rules_ for more information about this method."##), "Details at http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli/accounts_avails-list", @@ -646,6 +894,62 @@ fn main() { 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)), + ]), + ("components-list", + Some(r##"List Components owned or managed by the partner. See _Authentication and Authorization rules_ and _List methods rules_ for more information about this method."##), + "Details at http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli/accounts_components-list", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"REQUIRED. See _General rules_ for more information about this field."##), + 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)), + ]), + ("components-type-get", + Some(r##"Get a Component given its id."##), + "Details at http://byron.github.io/google-apis-rs/google_playmoviespartner1_cli/accounts_components-type-get", + vec![ + (Some(r##"account-id"##), + None, + Some(r##"REQUIRED. See _General rules_ for more information about this field."##), + Some(true), + Some(false)), + + (Some(r##"component-id"##), + None, + Some(r##"REQUIRED. Component ID."##), + Some(true), + Some(false)), + + (Some(r##"type"##), + None, + Some(r##"REQUIRED. Component Type."##), + 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"##), @@ -814,8 +1118,8 @@ fn main() { let mut app = App::new("playmoviespartner1") .author("Sebastian Thiel ") - .version("0.3.6+20150812") - .about("Lets Google Play Movies Partners get the delivery status of their titles.") + .version("0.3.6+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") .long("scope") diff --git a/gen/playmoviespartner1/Cargo.toml b/gen/playmoviespartner1/Cargo.toml index 6b84514bb4..66c1b7d7c5 100644 --- a/gen/playmoviespartner1/Cargo.toml +++ b/gen/playmoviespartner1/Cargo.toml @@ -4,9 +4,9 @@ [package] name = "google-playmoviespartner1" -version = "0.1.14+20150812" +version = "0.1.14+20160518" authors = ["Sebastian Thiel "] -description = "A complete library to interact with playmoviespartner (protocol v1)" +description = "A complete library to interact with Play Movies (protocol v1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/playmoviespartner1" homepage = "https://developers.google.com/playmoviespartner/" documentation = "http://byron.github.io/google-apis-rs/google_playmoviespartner1" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/playmoviespartner1/README.md b/gen/playmoviespartner1/README.md index 984c09e539..a9d16e04ea 100644 --- a/gen/playmoviespartner1/README.md +++ b/gen/playmoviespartner1/README.md @@ -3,18 +3,18 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/api/README.md.mako' DO NOT EDIT ! --> -The `google-playmoviespartner1` library allows access to all features of the *Google playmoviespartner* service. +The `google-playmoviespartner1` library allows access to all features of the *Google Play Movies* service. -This documentation was generated from *playmoviespartner* crate version *0.1.14+20150812*, where *20150812* is the exact revision of the *playmoviespartner:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *Play Movies* crate version *0.1.14+20160518*, where *20160518* is the exact revision of the *playmoviespartner:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. -Everything else about the *playmoviespartner* *v1* API can be found at the +Everything else about the *Play Movies* *v1* API can be found at the [official documentation site](https://developers.google.com/playmoviespartner/). # Features -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.Playmoviespartner.html) ... +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.PlayMovies.html) ... * accounts - * [*avails list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountAvailListCall.html), [*experience locales get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountExperienceLocaleGetCall.html), [*experience locales list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountExperienceLocaleListCall.html), [*orders get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountOrderGetCall.html), [*orders list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountOrderListCall.html), [*store infos country get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountStoreInfoCountryGetCall.html) and [*store infos list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountStoreInfoListCall.html) + * [*avails get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountAvailGetCall.html), [*avails list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountAvailListCall.html), [*components list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountComponentListCall.html), [*components type get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountComponentTypeGetCall.html), [*experience locales get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountExperienceLocaleGetCall.html), [*experience locales list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountExperienceLocaleListCall.html), [*orders get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountOrderGetCall.html), [*orders list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountOrderListCall.html), [*store infos country get*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountStoreInfoCountryGetCall.html) and [*store infos list*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.AccountStoreInfoListCall.html) @@ -23,7 +23,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g The API is structured into the following primary items: -* **[Hub](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.Playmoviespartner.html)** +* **[Hub](http://byron.github.io/google-apis-rs/google_playmoviespartner1/struct.PlayMovies.html)** * a central object to maintain state and allow accessing all *Activities* * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/trait.MethodsBuilder.html) which in turn allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_playmoviespartner1/trait.CallBuilder.html) @@ -47,7 +47,7 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.accounts().store_infos_country_get(...).doit() +let r = hub.accounts().avails_get(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -75,7 +75,7 @@ extern crate google_playmoviespartner1 as playmoviespartner1; use playmoviespartner1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use playmoviespartner1::Playmoviespartner; +use playmoviespartner1::PlayMovies; // Get an ApplicationSecret instance by some means. It contains the `client_id` and // `client_secret`, among other things. @@ -88,11 +88,11 @@ let secret: ApplicationSecret = Default::default(); let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, hyper::Client::new(), ::default(), None); -let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +let mut hub = PlayMovies::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.accounts().store_infos_country_get("accountId", "videoId", "country") +let result = hub.accounts().avails_get("accountId", "availId") .doit(); match result { diff --git a/gen/playmoviespartner1/src/lib.rs b/gen/playmoviespartner1/src/lib.rs index 4b814a4570..2f7f9a8e60 100644 --- a/gen/playmoviespartner1/src/lib.rs +++ b/gen/playmoviespartner1/src/lib.rs @@ -2,17 +2,17 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *playmoviespartner* crate version *0.1.14+20150812*, where *20150812* is the exact revision of the *playmoviespartner:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *Play Movies* crate version *0.1.14+20160518*, where *20160518* is the exact revision of the *playmoviespartner:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! -//! Everything else about the *playmoviespartner* *v1* API can be found at the +//! Everything else about the *Play Movies* *v1* API can be found at the //! [official documentation site](https://developers.google.com/playmoviespartner/). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/playmoviespartner1). //! # Features //! -//! Handle the following *Resources* with ease from the central [hub](struct.Playmoviespartner.html) ... +//! Handle the following *Resources* with ease from the central [hub](struct.PlayMovies.html) ... //! //! * accounts -//! * [*avails list*](struct.AccountAvailListCall.html), [*experience locales get*](struct.AccountExperienceLocaleGetCall.html), [*experience locales list*](struct.AccountExperienceLocaleListCall.html), [*orders get*](struct.AccountOrderGetCall.html), [*orders list*](struct.AccountOrderListCall.html), [*store infos country get*](struct.AccountStoreInfoCountryGetCall.html) and [*store infos list*](struct.AccountStoreInfoListCall.html) +//! * [*avails get*](struct.AccountAvailGetCall.html), [*avails list*](struct.AccountAvailListCall.html), [*components list*](struct.AccountComponentListCall.html), [*components type get*](struct.AccountComponentTypeGetCall.html), [*experience locales get*](struct.AccountExperienceLocaleGetCall.html), [*experience locales list*](struct.AccountExperienceLocaleListCall.html), [*orders get*](struct.AccountOrderGetCall.html), [*orders list*](struct.AccountOrderListCall.html), [*store infos country get*](struct.AccountStoreInfoCountryGetCall.html) and [*store infos list*](struct.AccountStoreInfoListCall.html) //! //! //! @@ -23,7 +23,7 @@ //! //! The API is structured into the following primary items: //! -//! * **[Hub](struct.Playmoviespartner.html)** +//! * **[Hub](struct.PlayMovies.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) @@ -47,7 +47,7 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.accounts().store_infos_country_get(...).doit() +//! let r = hub.accounts().avails_get(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -76,7 +76,7 @@ //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use playmoviespartner1::Playmoviespartner; +//! use playmoviespartner1::PlayMovies; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. @@ -89,11 +89,11 @@ //! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, //! hyper::Client::new(), //! ::default(), None); -//! let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +//! let mut hub = PlayMovies::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.accounts().store_infos_country_get("accountId", "videoId", "country") +//! let result = hub.accounts().avails_get("accountId", "availId") //! .doit(); //! //! match result { diff --git a/gen/playmoviespartner1/src/lib.rs.in b/gen/playmoviespartner1/src/lib.rs.in index c8bbad795b..40683bcaf3 100644 --- a/gen/playmoviespartner1/src/lib.rs.in +++ b/gen/playmoviespartner1/src/lib.rs.in @@ -60,7 +60,7 @@ impl Default for Scope { // HUB ### // ###### -/// Central instance to access all Playmoviespartner related resource activities +/// Central instance to access all PlayMovies related resource activities /// /// # Examples /// @@ -74,7 +74,7 @@ impl Default for Scope { /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use playmoviespartner1::Playmoviespartner; +/// use playmoviespartner1::PlayMovies; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. @@ -87,11 +87,11 @@ impl Default for Scope { /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// let mut hub = PlayMovies::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.accounts().store_infos_country_get("accountId", "videoId", "country") +/// let result = hub.accounts().avails_get("accountId", "availId") /// .doit(); /// /// match result { @@ -112,19 +112,19 @@ impl Default for Scope { /// } /// # } /// ``` -pub struct Playmoviespartner { +pub struct PlayMovies { client: RefCell, auth: RefCell, _user_agent: String, } -impl<'a, C, A> Hub for Playmoviespartner {} +impl<'a, C, A> Hub for PlayMovies {} -impl<'a, C, A> Playmoviespartner +impl<'a, C, A> PlayMovies where C: BorrowMut, A: oauth2::GetToken { - pub fn new(client: C, authenticator: A) -> Playmoviespartner { - Playmoviespartner { + pub fn new(client: C, authenticator: A) -> PlayMovies { + PlayMovies { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/0.1.14".to_string(), @@ -164,6 +164,9 @@ pub struct ListExperienceLocalesResponse { /// See _List methods rules_ for info about this field. #[serde(rename="nextPageToken")] pub next_page_token: Option, + /// See _List methods rules_ for more information about this field. + #[serde(rename="totalSize")] + pub total_size: Option, /// List of ExperienceLocales that match the request criteria. #[serde(rename="experienceLocales")] pub experience_locales: Option>, @@ -186,6 +189,9 @@ pub struct ListOrdersResponse { /// See _List methods rules_ for info about this field. #[serde(rename="nextPageToken")] pub next_page_token: Option, + /// See _List methods rules_ for more information about this field. + #[serde(rename="totalSize")] + pub total_size: Option, /// List of Orders that match the request criteria. pub orders: Option>, } @@ -210,14 +216,99 @@ pub struct ListStoreInfosResponse { /// See 'List methods rules' for info about this field. #[serde(rename="nextPageToken")] pub next_page_token: Option, + /// See _List methods rules_ for more information about this field. + #[serde(rename="totalSize")] + pub total_size: Option, } impl ResponseResult for ListStoreInfosResponse {} +/// A Component is an element (audio, video, subtitle, artwork, trailer, etc...) that is used in a set of ExperienceLocales. A Component is owned by a Studio and managed either by the Studio itself or by one Post-Production House. Each Component is identified by a `component_id` and its `type`. +/// +/// # 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*). +/// +/// * [components type get accounts](struct.AccountComponentTypeGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Component { + /// High-level status of the Component. + pub status: Option, + /// List of Alternative Cut IDs, sometimes available in lieu of the main Edit-level EIDR IDs. This is not an EIDR ID, but a Partner-provided ID. Example: "206346_79838". + #[serde(rename="altCutIds")] + pub alt_cut_ids: Option>, + /// Processing errors during XML file parsing. Example: 'Invalid input file' + #[serde(rename="processingErrors")] + pub processing_errors: Option>, + /// Name of the studio that owns the Component. + #[serde(rename="studioName")] + pub studio_name: Option, + /// Detailed status of the Component + #[serde(rename="statusDetail")] + pub status_detail: Option, + /// Notes explaining why a Component has been rejected. + #[serde(rename="rejectionNote")] + pub rejection_note: Option, + /// Timestamp when the Component was approved. + #[serde(rename="approvedTime")] + pub approved_time: Option, + /// List of Title-level EIDR IDs. Example: "10.5240/1489-49A2-3956-4B2D-FE16-5". + #[serde(rename="titleLevelEidrs")] + pub title_level_eidrs: Option>, + /// IDs internally generated by Google to uniquely identify the ExperienceLocales for which the Component is used. Example: 'KRZiVjY9h7t' + #[serde(rename="elIds")] + pub el_ids: Option>, + /// Default Edit name, usually in the language of the country of origin. Example: "Googlers, The". + pub name: Option, + /// Language of the component, using the "BCP 47" format. Examples: "en", "en-US", "es", "es-419". + pub language: Option, + /// Type of the playable unit for which the Component is intended. + #[serde(rename="playableUnitType")] + pub playable_unit_type: Option, + /// Detail about the type of the Component. + #[serde(rename="componentDetailType")] + pub component_detail_type: Option, + /// Timestamp when the Component was received. + #[serde(rename="receivedTime")] + pub received_time: Option, + /// List of custom IDs (defined by the partner) linked to the ExperienceLocale using this Component. Example: "R86241" + #[serde(rename="customIds")] + pub custom_ids: Option>, + /// Name of the post-production house that manages the Component. + #[serde(rename="pphName")] + pub pph_name: Option, + /// File name of the Component when delivered. + pub filename: Option, + /// Component priority, as defined by Google. The higher the value, the higher the priority. + pub priority: Option, + /// List of Edit-level EIDR IDs. Example: "10.5240/1489-49A2-3956-4B2D-FE16-6". + #[serde(rename="editLevelEidrs")] + pub edit_level_eidrs: Option>, + /// A simpler representation of the priority. + #[serde(rename="normalizedPriority")] + pub normalized_priority: Option, + /// Type of the Component. Example: AUDIO_51 + #[serde(rename="type")] + pub type_: Option, + /// ID internally generated by Google to uniquely identify the Component. Example: 'wteyrc_647xc' + #[serde(rename="componentId")] + pub component_id: Option, +} + +impl ResponseResult for Component {} + + /// An Avail describes the Availability Window of a specific Edit in a given country, which means the period Google is allowed to sell or rent the Edit. Avails are exposed in EMA format Version 1.6b (available at http://www.movielabs.com/md/avails/) Studios can see the Avails for the Titles they own. Post-production houses cannot see any Avails. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # 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*). +/// +/// * [avails get accounts](struct.AccountAvailGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Avail { @@ -242,9 +333,9 @@ pub struct Avail { /// OPTIONAL.TV Only. Title used by involved parties to refer to this episode. Only available on TV Avails. Example: "Coding at Google". #[serde(rename="episodeTitleInternalAlias")] pub episode_title_internal_alias: Option, - /// The number assigned to the episode within a season. Only available on TV Avails. Example: "3". - #[serde(rename="episodeNumber")] - pub episode_number: Option, + /// ID internally generated by Google to uniquely identify an Avail. Not part of EMA Specs. + #[serde(rename="availId")] + pub avail_id: Option, /// End of term in YYYY-MM-DD format in the timezone of the country of the Avail. "Open" if no end date is available. Example: "2019-02-17" pub end: Option, /// Other identifier referring to the Edit, as defined by partner. Example: "GOOGLER_2006" @@ -272,6 +363,9 @@ pub struct Avail { /// The number assigned to the season within a series. Only available on TV Avails. Example: "1". #[serde(rename="seasonNumber")] pub season_number: Option, + /// The number assigned to the episode within a season. Only available on TV Avails. Example: "3". + #[serde(rename="episodeNumber")] + pub episode_number: Option, /// Indicates the format profile covered by the transaction. #[serde(rename="formatProfile")] pub format_profile: Option, @@ -316,7 +410,7 @@ pub struct Avail { pub price_type: Option, } -impl Part for Avail {} +impl ResponseResult for Avail {} /// An ExperienceLocale tracks the fulfillment of a Title in a country using a specific language, when delivered using component-based delivery. For example, a Title in Switzerland might have 3 ExperienceLocales: they both share the same country ("CH"), but each has different languages ("de", "fr", and "it"). Each ExperienceLocale is uniquely identified by an `el_id`, which is generated by Google. Externally, an ExperienceLocale can also be identified by partners using its EIDR IDs, AltCutID or `custom_id` (when provided). @@ -500,6 +594,9 @@ pub struct ListAvailsResponse { /// See _List methods rules_ for info about this field. #[serde(rename="nextPageToken")] pub next_page_token: Option, + /// See _List methods rules_ for more information about this field. + #[serde(rename="totalSize")] + pub total_size: Option, /// List of Avails that match the request criteria. pub avails: Option>, } @@ -588,13 +685,37 @@ pub struct Order { impl ResponseResult for Order {} +/// Response to the 'ListComponents' method. +/// +/// # 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*). +/// +/// * [components list accounts](struct.AccountComponentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListComponentsResponse { + /// See _List methods rules_ for info about this field. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// See _List methods rules_ for more information about this field. + #[serde(rename="totalSize")] + pub total_size: Option, + /// List of Components that match the request criteria. + pub components: Option>, +} + +impl ResponseResult for ListComponentsResponse {} + + // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *account* resources. -/// It is not used directly, but through the `Playmoviespartner` hub. +/// It is not used directly, but through the `PlayMovies` hub. /// /// # Example /// @@ -608,15 +729,15 @@ impl ResponseResult for Order {} /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use playmoviespartner1::Playmoviespartner; +/// use playmoviespartner1::PlayMovies; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); -/// let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// let mut hub = PlayMovies::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `avails_list(...)`, `experience_locales_get(...)`, `experience_locales_list(...)`, `orders_get(...)`, `orders_list(...)`, `store_infos_country_get(...)` and `store_infos_list(...)` +/// // like `avails_get(...)`, `avails_list(...)`, `components_list(...)`, `components_type_get(...)`, `experience_locales_get(...)`, `experience_locales_list(...)`, `orders_get(...)`, `orders_list(...)`, `store_infos_country_get(...)` and `store_infos_list(...)` /// // to build up your call. /// let rb = hub.accounts(); /// # } @@ -624,7 +745,7 @@ impl ResponseResult for Order {} pub struct AccountMethods<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, } impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} @@ -642,6 +763,7 @@ impl<'a, C, A> AccountMethods<'a, C, A> { AccountOrderListCall { hub: self.hub, _account_id: account_id.to_string(), + _video_ids: Default::default(), _studio_names: Default::default(), _status: Default::default(), _pph_names: Default::default(), @@ -695,6 +817,25 @@ impl<'a, C, A> AccountMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Get an Avail given its avail group id and avail id. + /// + /// # Arguments + /// + /// * `accountId` - REQUIRED. See _General rules_ for more information about this field. + /// * `availId` - REQUIRED. Avail ID. + pub fn avails_get(&self, account_id: &str, avail_id: &str) -> AccountAvailGetCall<'a, C, A> { + AccountAvailGetCall { + hub: self.hub, + _account_id: account_id.to_string(), + _avail_id: avail_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// List Avails owned or managed by the partner. See _Authentication and Authorization rules_ and _List methods rules_ for more information about this method. @@ -713,6 +854,7 @@ impl<'a, C, A> AccountMethods<'a, C, A> { _pph_names: Default::default(), _page_token: Default::default(), _page_size: Default::default(), + _alt_ids: Default::default(), _alt_id: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -753,10 +895,12 @@ impl<'a, C, A> AccountMethods<'a, C, A> { _video_ids: Default::default(), _video_id: Default::default(), _studio_names: Default::default(), + _season_ids: Default::default(), _pph_names: Default::default(), _page_token: Default::default(), _page_size: Default::default(), _name: Default::default(), + _mids: Default::default(), _countries: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -789,6 +933,58 @@ impl<'a, C, A> AccountMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// List Components owned or managed by the partner. See _Authentication and Authorization rules_ and _List methods rules_ for more information about this method. + /// + /// # Arguments + /// + /// * `accountId` - REQUIRED. See _General rules_ for more information about this field. + pub fn components_list(&self, account_id: &str) -> AccountComponentListCall<'a, C, A> { + AccountComponentListCall { + hub: self.hub, + _account_id: account_id.to_string(), + _title_level_eidr: Default::default(), + _studio_names: Default::default(), + _status: Default::default(), + _presentation_id: Default::default(), + _pph_names: Default::default(), + _playable_sequence_id: Default::default(), + _page_token: Default::default(), + _page_size: Default::default(), + _inventory_id: Default::default(), + _filename: Default::default(), + _el_id: Default::default(), + _edit_level_eidr: Default::default(), + _custom_id: Default::default(), + _alt_cut_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Get a Component given its id. + /// + /// # Arguments + /// + /// * `accountId` - REQUIRED. See _General rules_ for more information about this field. + /// * `componentId` - REQUIRED. Component ID. + /// * `type` - REQUIRED. Component Type. + pub fn components_type_get(&self, account_id: &str, component_id: &str, type_: &str) -> AccountComponentTypeGetCall<'a, C, A> { + AccountComponentTypeGetCall { + hub: self.hub, + _account_id: account_id.to_string(), + _component_id: component_id.to_string(), + _type_: type_.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -815,32 +1011,34 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use playmoviespartner1::Playmoviespartner; +/// # use playmoviespartner1::PlayMovies; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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.accounts().orders_list("accountId") -/// .add_studio_names("accusam") -/// .add_status("takimata") -/// .add_pph_names("justo") -/// .page_token("amet.") -/// .page_size(-81) -/// .name("labore") -/// .custom_id("sea") +/// .add_video_ids("dolores") +/// .add_studio_names("kasd") +/// .add_status("accusam") +/// .add_pph_names("takimata") +/// .page_token("justo") +/// .page_size(-1) +/// .name("erat") +/// .custom_id("labore") /// .doit(); /// # } /// ``` pub struct AccountOrderListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, + _video_ids: Vec, _studio_names: Vec, _status: Vec, _pph_names: Vec, @@ -869,8 +1067,13 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "playmoviespartner.accounts.orders.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); + if self._video_ids.len() > 0 { + for f in self._video_ids.iter() { + params.push(("videoIds", f.to_string())); + } + } if self._studio_names.len() > 0 { for f in self._studio_names.iter() { params.push(("studioNames", f.to_string())); @@ -898,7 +1101,7 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._custom_id { params.push(("customId", value.to_string())); } - for &field in ["alt", "accountId", "studioNames", "status", "pphNames", "pageToken", "pageSize", "name", "customId"].iter() { + for &field in ["alt", "accountId", "videoIds", "studioNames", "status", "pphNames", "pageToken", "pageSize", "name", "customId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1023,6 +1226,14 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, self._account_id = new_value.to_string(); self } + /// Filter Orders that match any of the given `video_id`s. + /// + /// Append the given value to the *video ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_video_ids(mut self, new_value: &str) -> AccountOrderListCall<'a, C, A> { + self._video_ids.push(new_value.to_string()); + self + } /// See _List methods rules_ for info about this field. /// /// Append the given value to the *studio names* query property. @@ -1061,7 +1272,7 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, self._page_size = Some(new_value); self } - /// Filter Orders that match a title name (case-insensitive, sub-string match). + /// Filter that matches Orders with a `name`, `show`, `season` or `episode` that contains the given case-insensitive name. /// /// Sets the *name* query property to the given value. pub fn name(mut self, new_value: &str) -> AccountOrderListCall<'a, C, A> { @@ -1149,13 +1360,13 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use playmoviespartner1::Playmoviespartner; +/// # use playmoviespartner1::PlayMovies; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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 ! @@ -1166,7 +1377,7 @@ impl<'a, C, A> AccountOrderListCall<'a, C, A> where C: BorrowMut, pub struct AccountStoreInfoCountryGetCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _video_id: String, _country: String, @@ -1414,13 +1625,13 @@ impl<'a, C, A> AccountStoreInfoCountryGetCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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 ! @@ -1431,7 +1642,7 @@ impl<'a, C, A> AccountStoreInfoCountryGetCall<'a, C, A> where C: BorrowMut where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _order_id: String, _delegate: Option<&'a mut Delegate>, @@ -1651,6 +1862,259 @@ impl<'a, C, A> AccountOrderGetCall<'a, C, A> where C: BorrowMut, } +/// Get an Avail given its avail group id and avail id. +/// +/// A builder for the *avails.get* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_playmoviespartner1 as playmoviespartner1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use playmoviespartner1::PlayMovies; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = PlayMovies::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.accounts().avails_get("accountId", "availId") +/// .doit(); +/// # } +/// ``` +pub struct AccountAvailGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a PlayMovies, + _account_id: String, + _avail_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountAvailGetCall<'a, C, A> {} + +impl<'a, C, A> AccountAvailGetCall<'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, Avail)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "playmoviespartner.accounts.avails.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("availId", self._avail_id.to_string())); + for &field in ["alt", "accountId", "availId"].iter() { + if self._additional_params.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://playmoviespartner.googleapis.com/v1/accounts/{accountId}/avails/{availId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::PlaymovyPartnerReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{availId}", "availId")].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 ["availId", "accountId"].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) + } + } + } + } + + + /// REQUIRED. See _General rules_ for more information about this field. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountAvailGetCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// REQUIRED. Avail ID. + /// + /// Sets the *avail 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 avail_id(mut self, new_value: &str) -> AccountAvailGetCall<'a, C, A> { + self._avail_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) -> AccountAvailGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountAvailGetCall<'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::PlaymovyPartnerReadonly`. + /// + /// 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) -> AccountAvailGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// List Avails owned or managed by the partner. See _Authentication and Authorization rules_ and _List methods rules_ for more information about this method. /// /// A builder for the *avails.list* method supported by a *account* resource. @@ -1667,32 +2131,33 @@ impl<'a, C, A> AccountOrderGetCall<'a, C, A> where C: BorrowMut, /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use playmoviespartner1::Playmoviespartner; +/// # use playmoviespartner1::PlayMovies; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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.accounts().avails_list("accountId") -/// .add_video_ids("no") +/// .add_video_ids("justo") /// .title("justo") -/// .add_territories("justo") +/// .add_territories("et") /// .add_studio_names("et") -/// .add_pph_names("et") -/// .page_token("diam") -/// .page_size(-55) -/// .alt_id("Lorem") +/// .add_pph_names("diam") +/// .page_token("ipsum") +/// .page_size(-5) +/// .add_alt_ids("et") +/// .alt_id("duo") /// .doit(); /// # } /// ``` pub struct AccountAvailListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _video_ids: Vec, _title: Option, @@ -1701,6 +2166,7 @@ pub struct AccountAvailListCall<'a, C, A> _pph_names: Vec, _page_token: Option, _page_size: Option, + _alt_ids: Vec, _alt_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, @@ -1723,7 +2189,7 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "playmoviespartner.accounts.avails.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); if self._video_ids.len() > 0 { for f in self._video_ids.iter() { @@ -1754,10 +2220,15 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } + if self._alt_ids.len() > 0 { + for f in self._alt_ids.iter() { + params.push(("altIds", f.to_string())); + } + } if let Some(value) = self._alt_id { params.push(("altId", value.to_string())); } - for &field in ["alt", "accountId", "videoIds", "title", "territories", "studioNames", "pphNames", "pageToken", "pageSize", "altId"].iter() { + for &field in ["alt", "accountId", "videoIds", "title", "territories", "studioNames", "pphNames", "pageToken", "pageSize", "altIds", "altId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1890,7 +2361,7 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, self._video_ids.push(new_value.to_string()); self } - /// Filter Avails that match a case-insensitive substring of the default Title name. + /// Filter that matches Avails with a `title_internal_alias`, `series_title_internal_alias`, `season_title_internal_alias`, or `episode_title_internal_alias` that contains the given case-insensitive title. /// /// Sets the *title* query property to the given value. pub fn title(mut self, new_value: &str) -> AccountAvailListCall<'a, C, A> { @@ -1935,7 +2406,15 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, self._page_size = Some(new_value); self } - /// Filter Avails that match a case-insensitive, partner-specific custom id. + /// Filter Avails that match (case-insensitive) any of the given partner-specific custom ids. + /// + /// Append the given value to the *alt ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_alt_ids(mut self, new_value: &str) -> AccountAvailListCall<'a, C, A> { + self._alt_ids.push(new_value.to_string()); + self + } + /// Filter Avails that match a case-insensitive, partner-specific custom id. NOTE: this field is deprecated and will be removed on V2; `alt_ids` should be used instead. /// /// Sets the *alt id* query property to the given value. pub fn alt_id(mut self, new_value: &str) -> AccountAvailListCall<'a, C, A> { @@ -2016,13 +2495,13 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use playmoviespartner1::Playmoviespartner; +/// # use playmoviespartner1::PlayMovies; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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 ! @@ -2033,7 +2512,7 @@ impl<'a, C, A> AccountAvailListCall<'a, C, A> where C: BorrowMut, pub struct AccountExperienceLocaleGetCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _el_id: String, _delegate: Option<&'a mut Delegate>, @@ -2269,40 +2748,44 @@ impl<'a, C, A> AccountExperienceLocaleGetCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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.accounts().store_infos_list("accountId") -/// .add_video_ids("sea") -/// .video_id("Lorem") -/// .add_studio_names("eos") -/// .add_pph_names("erat") -/// .page_token("sadipscing") -/// .page_size(-48) -/// .name("eirmod") -/// .add_countries("elitr") +/// .add_video_ids("eos") +/// .video_id("erat") +/// .add_studio_names("sadipscing") +/// .add_season_ids("dolor") +/// .add_pph_names("eirmod") +/// .page_token("elitr") +/// .page_size(-97) +/// .name("no") +/// .add_mids("labore") +/// .add_countries("eirmod") /// .doit(); /// # } /// ``` pub struct AccountStoreInfoListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _video_ids: Vec, _video_id: Option, _studio_names: Vec, + _season_ids: Vec, _pph_names: Vec, _page_token: Option, _page_size: Option, _name: Option, + _mids: Vec, _countries: Vec, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, @@ -2325,7 +2808,7 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((11 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); params.push(("accountId", self._account_id.to_string())); if self._video_ids.len() > 0 { for f in self._video_ids.iter() { @@ -2340,6 +2823,11 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut 0 { + for f in self._season_ids.iter() { + params.push(("seasonIds", f.to_string())); + } + } if self._pph_names.len() > 0 { for f in self._pph_names.iter() { params.push(("pphNames", f.to_string())); @@ -2354,12 +2842,17 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut 0 { + for f in self._mids.iter() { + params.push(("mids", f.to_string())); + } + } if self._countries.len() > 0 { for f in self._countries.iter() { params.push(("countries", f.to_string())); } } - for &field in ["alt", "accountId", "videoIds", "videoId", "studioNames", "pphNames", "pageToken", "pageSize", "name", "countries"].iter() { + for &field in ["alt", "accountId", "videoIds", "videoId", "studioNames", "seasonIds", "pphNames", "pageToken", "pageSize", "name", "mids", "countries"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2507,6 +3000,14 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut AccountStoreInfoListCall<'a, C, A> { + self._season_ids.push(new_value.to_string()); + self + } /// See _List methods rules_ for info about this field. /// /// Append the given value to the *pph names* query property. @@ -2529,13 +3030,21 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut AccountStoreInfoListCall<'a, C, A> { self._name = Some(new_value.to_string()); self } + /// Filter StoreInfos that match any of the given `mid`s. + /// + /// Append the given value to the *mids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_mids(mut self, new_value: &str) -> AccountStoreInfoListCall<'a, C, A> { + self._mids.push(new_value.to_string()); + self + } /// Filter StoreInfos that match (case-insensitive) any of the given country codes, using the "ISO 3166-1 alpha-2" format (examples: "US", "us", "Us"). /// /// Append the given value to the *countries* query property. @@ -2618,33 +3127,33 @@ impl<'a, C, A> AccountStoreInfoListCall<'a, C, A> where C: BorrowMut::default(), None); -/// # let mut hub = Playmoviespartner::new(hyper::Client::new(), auth); +/// # let mut hub = PlayMovies::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.accounts().experience_locales_list("accountId") -/// .title_level_eidr("no") -/// .add_studio_names("labore") -/// .add_status("eirmod") -/// .add_pph_names("dolore") -/// .page_token("invidunt") -/// .page_size(-82) -/// .edit_level_eidr("accusam") -/// .custom_id("Lorem") -/// .alt_cut_id("sea") +/// .title_level_eidr("invidunt") +/// .add_studio_names("aliquyam") +/// .add_status("accusam") +/// .add_pph_names("Lorem") +/// .page_token("sea") +/// .page_size(-21) +/// .edit_level_eidr("duo") +/// .custom_id("et") +/// .alt_cut_id("eirmod") /// .doit(); /// # } /// ``` pub struct AccountExperienceLocaleListCall<'a, C, A> where C: 'a, A: 'a { - hub: &'a Playmoviespartner, + hub: &'a PlayMovies, _account_id: String, _title_level_eidr: Option, _studio_names: Vec, @@ -2960,3 +3469,686 @@ impl<'a, C, A> AccountExperienceLocaleListCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = PlayMovies::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.accounts().components_list("accountId") +/// .title_level_eidr("et") +/// .add_studio_names("amet") +/// .add_status("et") +/// .presentation_id("consetetur") +/// .add_pph_names("ut") +/// .playable_sequence_id("ea") +/// .page_token("sed") +/// .page_size(-3) +/// .inventory_id("dolor") +/// .filename("dolor") +/// .el_id("et") +/// .edit_level_eidr("consetetur") +/// .custom_id("amet.") +/// .alt_cut_id("voluptua.") +/// .doit(); +/// # } +/// ``` +pub struct AccountComponentListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a PlayMovies, + _account_id: String, + _title_level_eidr: Option, + _studio_names: Vec, + _status: Vec, + _presentation_id: Option, + _pph_names: Vec, + _playable_sequence_id: Option, + _page_token: Option, + _page_size: Option, + _inventory_id: Option, + _filename: Option, + _el_id: Option, + _edit_level_eidr: Option, + _custom_id: Option, + _alt_cut_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountComponentListCall<'a, C, A> {} + +impl<'a, C, A> AccountComponentListCall<'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, ListComponentsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "playmoviespartner.accounts.components.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((17 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + if let Some(value) = self._title_level_eidr { + params.push(("titleLevelEidr", value.to_string())); + } + if self._studio_names.len() > 0 { + for f in self._studio_names.iter() { + params.push(("studioNames", f.to_string())); + } + } + if self._status.len() > 0 { + for f in self._status.iter() { + params.push(("status", f.to_string())); + } + } + if let Some(value) = self._presentation_id { + params.push(("presentationId", value.to_string())); + } + if self._pph_names.len() > 0 { + for f in self._pph_names.iter() { + params.push(("pphNames", f.to_string())); + } + } + if let Some(value) = self._playable_sequence_id { + params.push(("playableSequenceId", value.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._inventory_id { + params.push(("inventoryId", value.to_string())); + } + if let Some(value) = self._filename { + params.push(("filename", value.to_string())); + } + if let Some(value) = self._el_id { + params.push(("elId", value.to_string())); + } + if let Some(value) = self._edit_level_eidr { + params.push(("editLevelEidr", value.to_string())); + } + if let Some(value) = self._custom_id { + params.push(("customId", value.to_string())); + } + if let Some(value) = self._alt_cut_id { + params.push(("altCutId", value.to_string())); + } + for &field in ["alt", "accountId", "titleLevelEidr", "studioNames", "status", "presentationId", "pphNames", "playableSequenceId", "pageToken", "pageSize", "inventoryId", "filename", "elId", "editLevelEidr", "customId", "altCutId"].iter() { + if self._additional_params.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://playmoviespartner.googleapis.com/v1/accounts/{accountId}/components".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::PlaymovyPartnerReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId")].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 ["accountId"].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) + } + } + } + } + + + /// REQUIRED. See _General rules_ for more information about this field. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// Filter Components that match a given title-level EIDR. + /// + /// Sets the *title level eidr* query property to the given value. + pub fn title_level_eidr(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._title_level_eidr = Some(new_value.to_string()); + self + } + /// See _List methods rules_ for info about this field. + /// + /// Append the given value to the *studio names* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_studio_names(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._studio_names.push(new_value.to_string()); + self + } + /// Filter Components that match one of the given status. + /// + /// Append the given value to the *status* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_status(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._status.push(new_value.to_string()); + self + } + /// PresentationID available in Common Manifest. + /// + /// Sets the *presentation id* query property to the given value. + pub fn presentation_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._presentation_id = Some(new_value.to_string()); + self + } + /// See _List methods rules_ for info about this field. + /// + /// Append the given value to the *pph names* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_pph_names(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._pph_names.push(new_value.to_string()); + self + } + /// PlayableSequenceID available in Common Manifest. + /// + /// Sets the *playable sequence id* query property to the given value. + pub fn playable_sequence_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._playable_sequence_id = Some(new_value.to_string()); + self + } + /// See _List methods rules_ for info about this field. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// See _List methods rules_ for info about this field. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> AccountComponentListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// InventoryID available in Common Manifest. + /// + /// Sets the *inventory id* query property to the given value. + pub fn inventory_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._inventory_id = Some(new_value.to_string()); + self + } + /// Filter Components that match a case-insensitive substring of the physical name of the delivered file. + /// + /// Sets the *filename* query property to the given value. + pub fn filename(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._filename = Some(new_value.to_string()); + self + } + /// Experience ID, as defined by Google. + /// + /// Sets the *el id* query property to the given value. + pub fn el_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._el_id = Some(new_value.to_string()); + self + } + /// Filter Components that match a given edit-level EIDR. + /// + /// Sets the *edit level eidr* query property to the given value. + pub fn edit_level_eidr(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._edit_level_eidr = Some(new_value.to_string()); + self + } + /// Filter Components that match a case-insensitive partner-specific custom id. + /// + /// Sets the *custom id* query property to the given value. + pub fn custom_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._custom_id = Some(new_value.to_string()); + self + } + /// Filter Components that match a case-insensitive, partner-specific Alternative Cut ID. + /// + /// Sets the *alt cut id* query property to the given value. + pub fn alt_cut_id(mut self, new_value: &str) -> AccountComponentListCall<'a, C, A> { + self._alt_cut_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) -> AccountComponentListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountComponentListCall<'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::PlaymovyPartnerReadonly`. + /// + /// 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) -> AccountComponentListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Get a Component given its id. +/// +/// A builder for the *components.type.get* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_playmoviespartner1 as playmoviespartner1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use playmoviespartner1::PlayMovies; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = PlayMovies::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.accounts().components_type_get("accountId", "componentId", "type") +/// .doit(); +/// # } +/// ``` +pub struct AccountComponentTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a PlayMovies, + _account_id: String, + _component_id: String, + _type_: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for AccountComponentTypeGetCall<'a, C, A> {} + +impl<'a, C, A> AccountComponentTypeGetCall<'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, Component)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "playmoviespartner.accounts.components.type.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("accountId", self._account_id.to_string())); + params.push(("componentId", self._component_id.to_string())); + params.push(("type", self._type_.to_string())); + for &field in ["alt", "accountId", "componentId", "type"].iter() { + if self._additional_params.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://playmoviespartner.googleapis.com/v1/accounts/{accountId}/components/{componentId}/type/{type}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::PlaymovyPartnerReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{accountId}", "accountId"), ("{componentId}", "componentId"), ("{type}", "type")].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 ["type", "componentId", "accountId"].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) + } + } + } + } + + + /// REQUIRED. See _General rules_ for more information about this field. + /// + /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountComponentTypeGetCall<'a, C, A> { + self._account_id = new_value.to_string(); + self + } + /// REQUIRED. Component ID. + /// + /// Sets the *component 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 component_id(mut self, new_value: &str) -> AccountComponentTypeGetCall<'a, C, A> { + self._component_id = new_value.to_string(); + self + } + /// REQUIRED. Component Type. + /// + /// Sets the *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 type_(mut self, new_value: &str) -> AccountComponentTypeGetCall<'a, C, A> { + self._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) -> AccountComponentTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> AccountComponentTypeGetCall<'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::PlaymovyPartnerReadonly`. + /// + /// 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) -> AccountComponentTypeGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/plus1-cli/Cargo.toml b/gen/plus1-cli/Cargo.toml index 37d7ffd25c..2e33701552 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+20160406" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "plus1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-plus1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-plus1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-plus1] diff --git a/gen/plus1-cli/README.md b/gen/plus1-cli/README.md index 1eed852f98..92145f5de5 100644 --- a/gen/plus1-cli/README.md +++ b/gen/plus1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *plus* API at revision *20160406*. The CLI is at version *0.3.6*. +This documentation was generated from the *plus* API at revision *20160907*. The CLI is at version *0.3.6*. ```bash plus1 [options] diff --git a/gen/plus1-cli/mkdocs.yml b/gen/plus1-cli/mkdocs.yml index baeb4fc3e8..d7b48bbcee 100644 --- a/gen/plus1-cli/mkdocs.yml +++ b/gen/plus1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plus v0.3.6+20160406 +site_name: plus v0.3.6+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 7824298af3..e5208183dc 100644 --- a/gen/plus1-cli/src/main.rs +++ b/gen/plus1-cli/src/main.rs @@ -937,8 +937,8 @@ fn main() { let mut app = App::new("plus1") .author("Sebastian Thiel ") - .version("0.3.6+20160406") - .about("The Google+ API enables developers to build on top of the Google+ platform.") + .version("0.3.6+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") .long("scope") diff --git a/gen/plus1/Cargo.toml b/gen/plus1/Cargo.toml index fe80aa510e..24a13dbc90 100644 --- a/gen/plus1/Cargo.toml +++ b/gen/plus1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plus1" -version = "0.1.14+20160406" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/plus1/README.md b/gen/plus1/README.md index c50a180a3f..d9134668d8 100644 --- a/gen/plus1/README.md +++ b/gen/plus1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-plus1` library allows access to all features of the *Google plus* service. -This documentation was generated from *plus* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *plus* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *plus* *v1* API can be found at the [official documentation site](https://developers.google.com/+/api/). diff --git a/gen/plus1/src/lib.rs b/gen/plus1/src/lib.rs index 71ca3b47f1..77a02f0750 100644 --- a/gen/plus1/src/lib.rs +++ b/gen/plus1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *plus* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *plus* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *plus:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *plus* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/api/). diff --git a/gen/plusdomains1-cli/Cargo.toml b/gen/plusdomains1-cli/Cargo.toml index 08c4db3237..15a87255c3 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+20160406" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "plusdomains1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-plusdomains1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-plusdomains1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-plusdomains1] diff --git a/gen/plusdomains1-cli/README.md b/gen/plusdomains1-cli/README.md index a59a677920..56fa01babf 100644 --- a/gen/plusdomains1-cli/README.md +++ b/gen/plusdomains1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *plusDomains* API at revision *20160406*. The CLI is at version *0.3.6*. +This documentation was generated from the *plusDomains* API at revision *20160907*. The CLI is at version *0.3.6*. ```bash plusdomains1 [options] diff --git a/gen/plusdomains1-cli/mkdocs.yml b/gen/plusdomains1-cli/mkdocs.yml index 80fb5eab04..aa21f7c54d 100644 --- a/gen/plusdomains1-cli/mkdocs.yml +++ b/gen/plusdomains1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plusDomains v0.3.6+20160406 +site_name: plusDomains v0.3.6+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 049945851a..351df09d46 100644 --- a/gen/plusdomains1-cli/src/main.rs +++ b/gen/plusdomains1-cli/src/main.rs @@ -2163,8 +2163,8 @@ fn main() { let mut app = App::new("plusdomains1") .author("Sebastian Thiel ") - .version("0.3.6+20160406") - .about("The Google+ API enables developers to build on top of the Google+ platform.") + .version("0.3.6+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") .long("scope") diff --git a/gen/plusdomains1/Cargo.toml b/gen/plusdomains1/Cargo.toml index 9bdc9842e8..d7abcf9cfb 100644 --- a/gen/plusdomains1/Cargo.toml +++ b/gen/plusdomains1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-plusdomains1" -version = "0.1.14+20160406" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/plusdomains1/README.md b/gen/plusdomains1/README.md index 0167f3d1d4..d15708eee9 100644 --- a/gen/plusdomains1/README.md +++ b/gen/plusdomains1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-plusdomains1` library allows access to all features of the *Google plusDomains* service. -This documentation was generated from *plusDomains* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *plusDomains* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *plusDomains* *v1* API can be found at the [official documentation site](https://developers.google.com/+/domains/). diff --git a/gen/plusdomains1/src/lib.rs b/gen/plusdomains1/src/lib.rs index 12513377f6..15a3412656 100644 --- a/gen/plusdomains1/src/lib.rs +++ b/gen/plusdomains1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *plusDomains* crate version *0.1.14+20160406*, where *20160406* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *plusDomains* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *plusDomains:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *plusDomains* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/domains/). diff --git a/gen/prediction1d6-cli/Cargo.toml b/gen/prediction1d6-cli/Cargo.toml index efb8f97937..31322859d1 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+20160304" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "prediction1d6" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-prediction1d6/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-prediction1d6/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-prediction1d6] diff --git a/gen/prediction1d6-cli/README.md b/gen/prediction1d6-cli/README.md index 234715ba9a..a0a42acad5 100644 --- a/gen/prediction1d6-cli/README.md +++ b/gen/prediction1d6-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *prediction* API at revision *20160304*. The CLI is at version *0.3.6*. +This documentation was generated from the *prediction* API at revision *20160511*. The CLI is at version *0.3.6*. ```bash prediction1d6 [options] diff --git a/gen/prediction1d6-cli/mkdocs.yml b/gen/prediction1d6-cli/mkdocs.yml index 0147fdcb18..cafd677e26 100644 --- a/gen/prediction1d6-cli/mkdocs.yml +++ b/gen/prediction1d6-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: prediction v0.3.6+20160304 +site_name: prediction v0.3.6+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 ff07b49a82..dfe78b5bac 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+20160304") + .version("0.3.6+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/prediction1d6/Cargo.toml b/gen/prediction1d6/Cargo.toml index 1f1fab3ec5..2bf51489d3 100644 --- a/gen/prediction1d6/Cargo.toml +++ b/gen/prediction1d6/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-prediction1d6" -version = "0.1.14+20160304" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/prediction1d6/README.md b/gen/prediction1d6/README.md index c7e1fd9f1d..090a6987c8 100644 --- a/gen/prediction1d6/README.md +++ b/gen/prediction1d6/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-prediction1d6` library allows access to all features of the *Google prediction* service. -This documentation was generated from *prediction* crate version *0.1.14+20160304*, where *20160304* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *prediction* crate version *0.1.14+20160511*, where *20160511* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *prediction* *v1d6* API can be found at the [official documentation site](https://developers.google.com/prediction/docs/developer-guide). diff --git a/gen/prediction1d6/src/lib.rs b/gen/prediction1d6/src/lib.rs index 1292f10ac6..f4b101b8fd 100644 --- a/gen/prediction1d6/src/lib.rs +++ b/gen/prediction1d6/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *prediction* crate version *0.1.14+20160304*, where *20160304* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *prediction* crate version *0.1.14+20160511*, where *20160511* is the exact revision of the *prediction:v1.6* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *prediction* *v1d6* API can be found at the //! [official documentation site](https://developers.google.com/prediction/docs/developer-guide). diff --git a/gen/prediction1d6/src/lib.rs.in b/gen/prediction1d6/src/lib.rs.in index dc336b784b..c996597b77 100644 --- a/gen/prediction1d6/src/lib.rs.in +++ b/gen/prediction1d6/src/lib.rs.in @@ -42,6 +42,9 @@ pub enum Scope { /// Manage your data in Google Cloud Storage DevstorageReadWrite, + /// View and manage your data across Google Cloud Platform services + CloudPlatform, + /// Manage your data and permissions in Google Cloud Storage DevstorageFullControl, @@ -54,6 +57,7 @@ impl AsRef for Scope { match *self { 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::DevstorageFullControl => "https://www.googleapis.com/auth/devstorage.full_control", Scope::Full => "https://www.googleapis.com/auth/prediction", } @@ -961,7 +965,7 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut, let mut url = "https://www.googleapis.com/prediction/v1.6/projects/{project}/trainedmodels/{id}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{project}", "project"), ("{id}", "id")].iter() { @@ -1118,7 +1122,7 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut, /// 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`. + /// `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. @@ -1215,7 +1219,7 @@ impl<'a, C, A> TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut TrainedmodelListCall<'a, C, A> where C: BorrowMut, let mut url = "https://www.googleapis.com/prediction/v1.6/projects/{project}/trainedmodels/list".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{project}", "project")].iter() { @@ -1655,7 +1659,7 @@ impl<'a, C, A> TrainedmodelListCall<'a, C, A> where C: BorrowMut, /// 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`. + /// `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. @@ -1744,7 +1748,7 @@ impl<'a, C, A> TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut TrainedmodelInsertCall<'a, C, A> where C: BorrowMut TrainedmodelInsertCall<'a, C, A> where C: BorrowMut TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut TrainedmodelPredictCall<'a, C, A> where C: BorrowMut TrainedmodelPredictCall<'a, C, A> where C: BorrowMut HostedmodelPredictCall<'a, C, A> where C: BorrowMut HostedmodelPredictCall<'a, C, A> where C: BorrowMut"] description = "A complete library to interact with proximitybeacon (protocol v1beta1)" repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/proximitybeacon1_beta1-cli" @@ -19,10 +19,10 @@ name = "proximitybeacon1-beta1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-proximitybeacon1_beta1/ni with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-proximitybeacon1_beta1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-proximitybeacon1_beta1] diff --git a/gen/proximitybeacon1_beta1-cli/README.md b/gen/proximitybeacon1_beta1-cli/README.md index e85ce35087..ba8eb2f406 100644 --- a/gen/proximitybeacon1_beta1-cli/README.md +++ b/gen/proximitybeacon1_beta1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *proximitybeacon* API at revision *20150729*. The CLI is at version *0.3.6*. +This documentation was generated from the *proximitybeacon* API at revision *20160429*. The CLI is at version *0.3.6*. ```bash proximitybeacon1-beta1 [options] @@ -43,11 +43,18 @@ proximitybeacon1-beta1 [options] list [-p ]... [-o ] register (-r )... [-p ]... [-o ] update (-r )... [-p ]... [-o ] + methods + get-eidparams [-p ]... [-o ] namespaces list [-p ]... [-o ] + update (-r )... [-p ]... [-o ] proximitybeacon1-beta1 --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. diff --git a/gen/proximitybeacon1_beta1-cli/mkdocs.yml b/gen/proximitybeacon1_beta1-cli/mkdocs.yml index 94bdbf0fea..e1e948b16f 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+20150729 +site_name: proximitybeacon v0.3.6+20160429 site_url: http://byron.github.io/google-apis-rs/google-proximitybeacon1_beta1-cli site_description: Write integrating applications with bcore @@ -22,7 +22,9 @@ pages: - ['beacons_list.md', 'Beacons', 'List'] - ['beacons_register.md', 'Beacons', 'Register'] - ['beacons_update.md', 'Beacons', 'Update'] +- ['methods_get-eidparams.md', 'Methods', 'Get Eidparams'] - ['namespaces_list.md', 'Namespaces', 'List'] +- ['namespaces_update.md', 'Namespaces', 'Update'] theme: readthedocs diff --git a/gen/proximitybeacon1_beta1-cli/src/main.rs b/gen/proximitybeacon1_beta1-cli/src/main.rs index da8397cf0d..df315b098a 100644 --- a/gen/proximitybeacon1_beta1-cli/src/main.rs +++ b/gen/proximitybeacon1_beta1-cli/src/main.rs @@ -133,6 +133,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -146,6 +149,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -156,6 +160,9 @@ impl<'n> Engine<'n> { 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)), @@ -182,6 +189,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, "namespaced-type" => { call = call.namespaced_type(value.unwrap_or("")); }, @@ -198,7 +208,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["namespaced-type"].iter().map(|v|*v)); + v.extend(["project-id", "namespaced-type"].iter().map(|v|*v)); v } )); } } @@ -209,6 +219,9 @@ impl<'n> Engine<'n> { 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)), @@ -270,6 +283,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -283,6 +299,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -293,6 +310,9 @@ impl<'n> Engine<'n> { 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)), @@ -319,6 +339,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -332,6 +355,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -342,6 +366,9 @@ impl<'n> Engine<'n> { 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)), @@ -368,6 +395,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, "namespaced-type" => { call = call.namespaced_type(value.unwrap_or("")); }, @@ -384,7 +414,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["namespaced-type"].iter().map(|v|*v)); + v.extend(["project-id", "namespaced-type"].iter().map(|v|*v)); v } )); } } @@ -395,6 +425,9 @@ impl<'n> Engine<'n> { 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)), @@ -421,6 +454,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -434,6 +470,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -444,6 +481,9 @@ impl<'n> Engine<'n> { 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)), @@ -470,6 +510,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -483,6 +526,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -493,6 +537,9 @@ impl<'n> Engine<'n> { 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)), @@ -519,6 +566,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, @@ -541,7 +591,7 @@ impl<'n> Engine<'n> { 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", "alert-filter", "page-size"].iter().map(|v|*v)); + v.extend(["project-id", "alert-filter", "page-size", "page-token"].iter().map(|v|*v)); v } )); } } @@ -552,6 +602,9 @@ impl<'n> Engine<'n> { 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)), @@ -578,6 +631,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -591,6 +647,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -601,6 +658,9 @@ impl<'n> Engine<'n> { 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)), @@ -630,6 +690,9 @@ impl<'n> Engine<'n> { "q" => { call = call.q(value.unwrap_or("")); }, + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, @@ -649,7 +712,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["q", "page-token", "page-size"].iter().map(|v|*v)); + v.extend(["q", "project-id", "page-size", "page-token"].iter().map(|v|*v)); v } )); } } @@ -660,6 +723,9 @@ impl<'n> Engine<'n> { 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)), @@ -709,13 +775,20 @@ impl<'n> Engine<'n> { "lat-lng.latitude" => Some(("latLng.latitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "lat-lng.longitude" => Some(("latLng.longitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "place-id" => Some(("placeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.rotation-period-exponent" => Some(("ephemeralIdRegistration.rotationPeriodExponent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ephemeral-id-registration.initial-clock-value" => Some(("ephemeralIdRegistration.initialClockValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.beacon-ecdh-public-key" => Some(("ephemeralIdRegistration.beaconEcdhPublicKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.initial-eid" => Some(("ephemeralIdRegistration.initialEid", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.service-ecdh-public-key" => Some(("ephemeralIdRegistration.serviceEcdhPublicKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.beacon-identity-key" => Some(("ephemeralIdRegistration.beaconIdentityKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "advertised-id.type" => Some(("advertisedId.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "advertised-id.id" => Some(("advertisedId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "beacon-name" => Some(("beaconName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "expected-stability" => Some(("expectedStability", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "properties" => Some(("properties", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "provisioning-key" => Some(("provisioningKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["advertised-id", "beacon-name", "description", "expected-stability", "id", "indoor-level", "lat-lng", "latitude", "longitude", "name", "place-id", "properties", "status", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["advertised-id", "beacon-ecdh-public-key", "beacon-identity-key", "beacon-name", "description", "ephemeral-id-registration", "expected-stability", "id", "indoor-level", "initial-clock-value", "initial-eid", "lat-lng", "latitude", "longitude", "name", "place-id", "properties", "provisioning-key", "rotation-period-exponent", "service-ecdh-public-key", "status", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -729,6 +802,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -742,6 +818,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -752,6 +829,9 @@ impl<'n> Engine<'n> { 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)), @@ -801,13 +881,20 @@ impl<'n> Engine<'n> { "lat-lng.latitude" => Some(("latLng.latitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "lat-lng.longitude" => Some(("latLng.longitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "place-id" => Some(("placeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.rotation-period-exponent" => Some(("ephemeralIdRegistration.rotationPeriodExponent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "ephemeral-id-registration.initial-clock-value" => Some(("ephemeralIdRegistration.initialClockValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.beacon-ecdh-public-key" => Some(("ephemeralIdRegistration.beaconEcdhPublicKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.initial-eid" => Some(("ephemeralIdRegistration.initialEid", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.service-ecdh-public-key" => Some(("ephemeralIdRegistration.serviceEcdhPublicKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "ephemeral-id-registration.beacon-identity-key" => Some(("ephemeralIdRegistration.beaconIdentityKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "advertised-id.type" => Some(("advertisedId.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "advertised-id.id" => Some(("advertisedId.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "beacon-name" => Some(("beaconName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "expected-stability" => Some(("expectedStability", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "properties" => Some(("properties", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })), + "provisioning-key" => Some(("provisioningKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["advertised-id", "beacon-name", "description", "expected-stability", "id", "indoor-level", "lat-lng", "latitude", "longitude", "name", "place-id", "properties", "status", "type"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["advertised-id", "beacon-ecdh-public-key", "beacon-identity-key", "beacon-name", "description", "ephemeral-id-registration", "expected-stability", "id", "indoor-level", "initial-clock-value", "initial-eid", "lat-lng", "latitude", "longitude", "name", "place-id", "properties", "provisioning-key", "rotation-period-exponent", "service-ecdh-public-key", "status", "type"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -818,6 +905,62 @@ impl<'n> Engine<'n> { } let mut request: api::Beacon = json::value::from_value(object).unwrap(); let mut call = self.hub.beacons().update(request, opt.value_of("beacon-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 { + "project-id" => { + call = call.project_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(["project-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 _methods_get_eidparams(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.methods().get_eidparams(); for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { @@ -844,6 +987,9 @@ impl<'n> Engine<'n> { 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)), @@ -870,6 +1016,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "project-id" => { + call = call.project_id(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -883,6 +1032,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); + v.extend(["project-id"].iter().map(|v|*v)); v } )); } } @@ -893,6 +1043,99 @@ impl<'n> Engine<'n> { 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 _namespaces_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()[..] { + "namespace-name" => Some(("namespaceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "serving-visibility" => Some(("servingVisibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["namespace-name", "serving-visibility"]); + 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::Namespace = json::value::from_value(object).unwrap(); + let mut call = self.hub.namespaces().update(request, opt.value_of("namespace-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 { + "project-id" => { + call = call.project_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(["project-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)), @@ -973,11 +1216,25 @@ impl<'n> Engine<'n> { } } }, + ("methods", Some(opt)) => { + match opt.subcommand() { + ("get-eidparams", Some(opt)) => { + call_result = self._methods_get_eidparams(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("methods".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, ("namespaces", Some(opt)) => { match opt.subcommand() { ("list", Some(opt)) => { call_result = self._namespaces_list(opt, dry_run, &mut err); }, + ("update", Some(opt)) => { + call_result = self._namespaces_update(opt, dry_run, &mut err); + }, _ => { err.issues.push(CLIError::MissingMethodError("namespaces".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); @@ -1072,7 +1329,7 @@ fn main() { let arg_data = [ ("beaconinfo", "methods: 'getforobserved'", vec![ ("getforobserved", - Some(r##"Given one or more beacon observations, returns any beacon information and attachments accessible to your application."##), + Some(r##"Given one or more beacon observations, returns any beacon information and attachments accessible to your application. Authorize by using the [API key](https://developers.google.com/beacons/proximity/how-tos/authorizing#APIKey) for the application."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beaconinfo_getforobserved", vec![ (Some(r##"kv"##), @@ -1097,12 +1354,12 @@ fn main() { ("beacons", "methods: 'activate', 'attachments-batch-delete', 'attachments-create', 'attachments-delete', 'attachments-list', 'deactivate', 'decommission', 'diagnostics-list', 'get', 'list', 'register' and 'update'", vec![ ("activate", - Some(r##"(Re)activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code)."##), + Some(r##"Activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_activate", vec![ (Some(r##"beacon-name"##), None, - Some(r##"The beacon to activate. Required."##), + Some(r##"Beacon that should be activated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1119,12 +1376,12 @@ fn main() { Some(false)), ]), ("attachments-batch-delete", - Some(r##"Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all."##), + Some(r##"Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_attachments-batch-delete", vec![ (Some(r##"beacon-name"##), None, - Some(r##"The beacon whose attachments are to be deleted. Required."##), + Some(r##"The beacon whose attachments should be deleted. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1143,12 +1400,12 @@ fn main() { ("attachments-create", Some(r##"Associates the given data with the specified beacon. Attachment data must contain two parts: - A namespaced type. - - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long."##), + - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_attachments-create", vec![ (Some(r##"beacon-name"##), None, - Some(r##"The beacon on which the attachment should be created. Required."##), + Some(r##"Beacon on which the attachment should be created. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1171,12 +1428,12 @@ fn main() { Some(false)), ]), ("attachments-delete", - Some(r##"Deletes the specified attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone."##), + Some(r##"Deletes the specified attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_attachments-delete", vec![ (Some(r##"attachment-name"##), None, - Some(r##"The attachment name (`attachmentName`) of the attachment to remove. For example: `beacons/3!893737abc9/attachments/c5e937-af0-494-959-ec49d12738` Required."##), + Some(r##"The attachment name (`attachmentName`) of the attachment to remove. For example: `beacons/3!893737abc9/attachments/c5e937-af0-494-959-ec49d12738`. For Eddystone-EID beacons, the beacon ID portion (`3!893737abc9`) may be the beacon's current EID, or its "stable" Eddystone-UID. Required."##), Some(true), Some(false)), @@ -1193,12 +1450,12 @@ fn main() { Some(false)), ]), ("attachments-list", - Some(r##"Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint."##), + Some(r##"Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_attachments-list", vec![ (Some(r##"beacon-name"##), None, - Some(r##"The beacon whose attachments are to be fetched. Required."##), + Some(r##"Beacon whose attachments should be fetched. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1215,12 +1472,12 @@ fn main() { Some(false)), ]), ("deactivate", - Some(r##"Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code)."##), + Some(r##"Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_deactivate", vec![ (Some(r##"beacon-name"##), None, - Some(r##"The beacon name of this beacon."##), + Some(r##"Beacon that should be deactivated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1237,12 +1494,12 @@ fn main() { Some(false)), ]), ("decommission", - Some(r##"Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again."##), + Some(r##"Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_decommission", vec![ (Some(r##"beacon-name"##), None, - Some(r##"Beacon that should be decommissioned. Required."##), + Some(r##"Beacon that should be decommissioned. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID of the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1259,7 +1516,7 @@ fn main() { Some(false)), ]), ("diagnostics-list", - Some(r##"List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`."##), + Some(r##"List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_diagnostics-list", vec![ (Some(r##"beacon-name"##), @@ -1281,12 +1538,12 @@ fn main() { Some(false)), ]), ("get", - Some(r##"Returns detailed information about the specified beacon."##), + Some(r##"Returns detailed information about the specified beacon. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. Requests may supply an Eddystone-EID beacon name in the form: `beacons/4!beaconId` where the `beaconId` is the base16 ephemeral ID broadcast by the beacon. The returned `Beacon` object will contain the beacon's stable Eddystone-UID. Clients not authorized to resolve the beacon's ephemeral Eddystone-EID broadcast will receive an error."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_get", vec![ (Some(r##"beacon-name"##), None, - Some(r##"Beacon that is requested."##), + Some(r##"Resource name of this beacon. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required."##), Some(true), Some(false)), @@ -1303,7 +1560,7 @@ fn main() { Some(false)), ]), ("list", - Some(r##"Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned."##), + Some(r##"Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_list", vec![ (Some(r##"v"##), @@ -1319,7 +1576,7 @@ fn main() { Some(false)), ]), ("register", - Some(r##"Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once."##), + Some(r##"Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_register", vec![ (Some(r##"kv"##), @@ -1341,7 +1598,7 @@ fn main() { Some(false)), ]), ("update", - Some(r##"Updates the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for (de)activation and decommissioning."##), + Some(r##"Updates the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for activation, deactivation, and decommissioning. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/beacons_update", vec![ (Some(r##"beacon-name"##), @@ -1370,9 +1627,28 @@ fn main() { ]), ]), - ("namespaces", "methods: 'list'", vec![ + ("methods", "methods: 'get-eidparams'", vec![ + ("get-eidparams", + Some(r##"Gets the Proximity Beacon API's current public key and associated parameters used to initiate the Diffie-Hellman key exchange required to register a beacon that broadcasts the Eddystone-EID format. This key changes periodically; clients may cache it and re-use the same public key to provision and register multiple beacons. However, clients should be prepared to refresh this key when they encounter an error registering an Eddystone-EID beacon."##), + "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/methods_get-eidparams", + 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)), + ]), + ]), + + ("namespaces", "methods: 'list' and 'update'", vec![ ("list", - Some(r##"Lists all attachment namespaces owned by your Google Developers Console project. Attachment data associated with a beacon must include a namespaced type, and the namespace must be owned by your project."##), + Some(r##"Lists all attachment namespaces owned by your Google Developers Console project. Attachment data associated with a beacon must include a namespaced type, and the namespace must be owned by your project. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project."##), "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/namespaces_list", vec![ (Some(r##"v"##), @@ -1381,6 +1657,34 @@ fn main() { 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 information about the specified namespace. Only the namespace visibility can be updated."##), + "Details at http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1_cli/namespaces_update", + vec![ + (Some(r##"namespace-name"##), + None, + Some(r##"Resource name of this namespace. Namespaces names have the format: namespaces/namespace."##), + 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"##), @@ -1393,9 +1697,14 @@ fn main() { let mut app = App::new("proximitybeacon1-beta1") .author("Sebastian Thiel ") - .version("0.3.6+20150729") - .about("This API provides services to register, manage, index, and search beacons.") + .version("0.3.6+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") + .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") diff --git a/gen/proximitybeacon1_beta1/Cargo.toml b/gen/proximitybeacon1_beta1/Cargo.toml index 8ed5c8ac34..6d443459f2 100644 --- a/gen/proximitybeacon1_beta1/Cargo.toml +++ b/gen/proximitybeacon1_beta1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-proximitybeacon1_beta1" -version = "0.1.14+20150729" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/proximitybeacon1_beta1/README.md b/gen/proximitybeacon1_beta1/README.md index 19128fba8a..2ebc9f8873 100644 --- a/gen/proximitybeacon1_beta1/README.md +++ b/gen/proximitybeacon1_beta1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-proximitybeacon1_beta1` library allows access to all features of the *Google proximitybeacon* service. -This documentation was generated from *proximitybeacon* crate version *0.1.14+20150729*, where *20150729* is the exact revision of the *proximitybeacon:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *proximitybeacon* crate version *0.1.14+20160429*, where *20160429* is the exact revision of the *proximitybeacon:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *proximitybeacon* *v1_beta1* API can be found at the [official documentation site](https://developers.google.com/beacons/proximity/). @@ -18,8 +18,11 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [beacons](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.Beacon.html) * [*activate*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconActivateCall.html), [*attachments batch delete*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconAttachmentBatchDeleteCall.html), [*attachments create*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconAttachmentCreateCall.html), [*attachments delete*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconAttachmentDeleteCall.html), [*attachments list*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconAttachmentListCall.html), [*deactivate*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconDeactivateCall.html), [*decommission*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconDecommissionCall.html), [*diagnostics list*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconDiagnosticListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconListCall.html), [*register*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconRegisterCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.BeaconUpdateCall.html) * [namespaces](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.Namespace.html) - * [*list*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.NamespaceListCall.html) + * [*list*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.NamespaceListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.NamespaceUpdateCall.html) +Other activities are ... + +* [get eidparams](http://byron.github.io/google-apis-rs/google_proximitybeacon1_beta1/struct.MethodGetEidparamCall.html) @@ -108,9 +111,10 @@ let mut hub = Proximitybeacon::new(hyper::Client::new(), auth); // execute the final call using `doit()`. // Values shown here are possibly random and not representative ! let result = hub.beacons().diagnostics_list("beaconName") - .page_token("sit") - .page_size(-65) - .alert_filter("sed") + .project_id("sit") + .page_token("Stet") + .page_size(-42) + .alert_filter("et") .doit(); match result { diff --git a/gen/proximitybeacon1_beta1/src/lib.rs b/gen/proximitybeacon1_beta1/src/lib.rs index f8061da77e..8f51cd30ef 100644 --- a/gen/proximitybeacon1_beta1/src/lib.rs +++ b/gen/proximitybeacon1_beta1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *proximitybeacon* crate version *0.1.14+20150729*, where *20150729* is the exact revision of the *proximitybeacon:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *proximitybeacon* crate version *0.1.14+20160429*, where *20160429* is the exact revision of the *proximitybeacon:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *proximitybeacon* *v1_beta1* API can be found at the //! [official documentation site](https://developers.google.com/beacons/proximity/). @@ -16,8 +16,11 @@ //! * [beacons](struct.Beacon.html) //! * [*activate*](struct.BeaconActivateCall.html), [*attachments batch delete*](struct.BeaconAttachmentBatchDeleteCall.html), [*attachments create*](struct.BeaconAttachmentCreateCall.html), [*attachments delete*](struct.BeaconAttachmentDeleteCall.html), [*attachments list*](struct.BeaconAttachmentListCall.html), [*deactivate*](struct.BeaconDeactivateCall.html), [*decommission*](struct.BeaconDecommissionCall.html), [*diagnostics list*](struct.BeaconDiagnosticListCall.html), [*get*](struct.BeaconGetCall.html), [*list*](struct.BeaconListCall.html), [*register*](struct.BeaconRegisterCall.html) and [*update*](struct.BeaconUpdateCall.html) //! * [namespaces](struct.Namespace.html) -//! * [*list*](struct.NamespaceListCall.html) +//! * [*list*](struct.NamespaceListCall.html) and [*update*](struct.NamespaceUpdateCall.html) //! +//! Other activities are ... +//! +//! * [get eidparams](struct.MethodGetEidparamCall.html) //! //! //! @@ -109,9 +112,10 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.beacons().diagnostics_list("beaconName") -//! .page_token("Lorem") -//! .page_size(-21) -//! .alert_filter("duo") +//! .project_id("invidunt") +//! .page_token("aliquyam") +//! .page_size(-73) +//! .alert_filter("Lorem") //! .doit(); //! //! match result { diff --git a/gen/proximitybeacon1_beta1/src/lib.rs.in b/gen/proximitybeacon1_beta1/src/lib.rs.in index e4251b9c44..44164ec598 100644 --- a/gen/proximitybeacon1_beta1/src/lib.rs.in +++ b/gen/proximitybeacon1_beta1/src/lib.rs.in @@ -31,6 +31,28 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, // 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 modify your beacons + UserlocationBeaconRegistry, +} + +impl AsRef for Scope { + fn as_ref(&self) -> &str { + match *self { + Scope::UserlocationBeaconRegistry => "https://www.googleapis.com/auth/userlocation.beacon.registry", + } + } +} + +impl Default for Scope { + fn default() -> Scope { + Scope::UserlocationBeaconRegistry + } +} @@ -70,9 +92,10 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().diagnostics_list("beaconName") -/// .page_token("dolores") -/// .page_size(-63) -/// .alert_filter("accusam") +/// .project_id("kasd") +/// .page_token("accusam") +/// .page_size(-8) +/// .alert_filter("justo") /// .doit(); /// /// match result { @@ -118,6 +141,9 @@ impl<'a, C, A> Proximitybeacon pub fn beacons(&'a self) -> BeaconMethods<'a, C, A> { BeaconMethods { hub: &self } } + pub fn methods(&'a self) -> MethodMethods<'a, C, A> { + MethodMethods { hub: &self } + } pub fn namespaces(&'a self) -> NamespaceMethods<'a, C, A> { NamespaceMethods { hub: &self } } @@ -168,12 +194,12 @@ impl ResponseResult for BeaconAttachment {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Observation { - /// The ID advertised by the beacon the client has encountered. Required. + /// The ID advertised by the beacon the client has encountered. Clients may submit an Eddystone-EID `advertised_id`. If the client is not authorized to resolve the given Eddystone-EID, no data will be returned for that beacon. Required. #[serde(rename="advertisedId")] pub advertised_id: Option, /// The array of telemetry bytes received from the beacon. The server is responsible for parsing it. This field may frequently be empty, as with a beacon that transmits telemetry only occasionally. pub telemetry: Option, - /// Time when the beacon was observed. Being sourced from a mobile device, this time may be suspect. + /// Time when the beacon was observed. #[serde(rename="timestampMs")] pub timestamp_ms: Option, } @@ -247,6 +273,7 @@ impl RequestValue for GetInfoForObservedBeaconsRequest {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list namespaces](struct.NamespaceListCall.html) (none) +/// * [update namespaces](struct.NamespaceUpdateCall.html) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Namespace { @@ -258,7 +285,9 @@ pub struct Namespace { pub serving_visibility: Option, } +impl RequestValue for Namespace {} impl Resource for Namespace {} +impl ResponseResult for Namespace {} /// A subset of attachment information served via the `beaconinfo.getforobserved` method, used when your users encounter your beacons. @@ -293,6 +322,35 @@ pub struct AdvertisedId { impl Part for AdvertisedId {} +/// Write-only registration parameters for beacons using Eddystone-EID format. Two ways of securely registering an Eddystone-EID beacon with the service are supported: 1. Perform an ECDH key exchange via this API, including a previous call to `GET /v1beta1/eidparams`. In this case the fields `beacon_ecdh_public_key` and `service_ecdh_public_key` should be populated and `beacon_identity_key` should not be populated. This method ensures that only the two parties in the ECDH key exchange can compute the identity key, which becomes a secret between them. 2. Derive or obtain the beacon's identity key via other secure means (perhaps an ECDH key exchange between the beacon and a mobile device or any other secure method), and then submit the resulting identity key to the service. In this case `beacon_identity_key` field should be populated, and neither of `beacon_ecdh_public_key` nor `service_ecdh_public_key` fields should be. The security of this method depends on how securely the parties involved (in particular the bluetooth client) handle the identity key, and obviously on how securely the identity key was generated. See [the Eddystone specification](https://github.com/google/eddystone/tree/master/eddystone-eid) at GitHub. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EphemeralIdRegistration { + /// An initial ephemeral ID calculated using the clock value submitted as `initial_clock_value`, and the secret key generated by the Diffie-Hellman key exchange using `service_ecdh_public_key` and `service_ecdh_public_key`. This initial EID value will be used by the service to confirm that the key exchange process was successful. + #[serde(rename="initialEid")] + pub initial_eid: Option, + /// Indicates the nominal period between each rotation of the beacon's ephemeral ID. "Nominal" because the beacon should randomize the actual interval. See [the spec at github](https://github.com/google/eddystone/tree/master/eddystone-eid) for details. This value corresponds to a power-of-two scaler on the beacon's clock: when the scaler value is K, the beacon will begin broadcasting a new ephemeral ID on average every 2^K seconds. + #[serde(rename="rotationPeriodExponent")] + pub rotation_period_exponent: Option, + /// The beacon's public key used for the Elliptic curve Diffie-Hellman key exchange. When this field is populated, `service_ecdh_public_key` must also be populated, and `beacon_identity_key` must not be. + #[serde(rename="beaconEcdhPublicKey")] + pub beacon_ecdh_public_key: Option, + /// The initial clock value of the beacon. The beacon's clock must have begun counting at this value immediately prior to transmitting this value to the resolving service. Significant delay in transmitting this value to the service risks registration or resolution failures. If a value is not provided, the default is zero. + #[serde(rename="initialClockValue")] + pub initial_clock_value: Option, + /// The service's public key used for the Elliptic curve Diffie-Hellman key exchange. When this field is populated, `beacon_ecdh_public_key` must also be populated, and `beacon_identity_key` must not be. + #[serde(rename="serviceEcdhPublicKey")] + pub service_ecdh_public_key: Option, + /// The private key of the beacon. If this field is populated, `beacon_ecdh_public_key` and `service_ecdh_public_key` must not be populated. + #[serde(rename="beaconIdentityKey")] + pub beacon_identity_key: Option, +} + +impl Part for EphemeralIdRegistration {} + + /// Diagnostics for a single beacon. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -304,7 +362,7 @@ pub struct Diagnostics { pub estimated_low_battery_date: Option, /// An unordered list of Alerts that the beacon has. pub alerts: Option>, - /// Resource name of the beacon. + /// Resource name of the beacon. For Eddystone-EID beacons, this may be the beacon's current EID, or the beacon's "stable" Eddystone-UID. #[serde(rename="beaconName")] pub beacon_name: Option, } @@ -321,13 +379,11 @@ pub struct BeaconInfo { /// The ID advertised by the beacon. #[serde(rename="advertisedId")] pub advertised_id: Option, + /// Attachments matching the type(s) requested. May be empty if no attachment types were requested, or if none matched. + pub attachments: Option>, /// The name under which the beacon is registered. #[serde(rename="beaconName")] pub beacon_name: Option, - /// Free text used to identify or describe the beacon in a registered establishment. For example: "entrance", "room 101", etc. May be empty. - pub description: Option, - /// Attachments matching the type(s) requested. May be empty if no attachment types were requested, or if none matched. - pub attachments: Option>, } impl Part for BeaconInfo {} @@ -351,7 +407,32 @@ pub struct Empty; impl ResponseResult for Empty {} -/// An object representing a latitude/longitude pair. This is expressed as a pair of doubles representing degrees latitude and degrees longitude. Unless specified otherwise, this must conform to the WGS84 standard. Values must be within normalized ranges. Example of normalization code in Python: def NormalizeLongitude(longitude): """Wrapsdecimal degrees longitude to [-180.0, 180.0].""" q, r = divmod(longitude, 360.0) if r > 180.0 or (r == 180.0 and q <= -1.0): return r - 360.0 return r def NormalizeLatLng(latitude, longitude): """Wraps decimal degrees latitude and longitude to [-180.0, 180.0] and [-90.0, 90.0], respectively.""" r = latitude % 360.0 if r = 270.0: return r - 360, NormalizeLongitude(longitude) else: return 180 - r, NormalizeLongitude(longitude + 180.0) assert 180.0 == NormalizeLongitude(180.0) assert -180.0 == NormalizeLongitude(-180.0) assert -179.0 == NormalizeLongitude(181.0) assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0) assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0) assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0) assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0) assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0) assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0) assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0) assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0) assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0) assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0) +/// Information a client needs to provision and register beacons that broadcast Eddystone-EID format beacon IDs, using Elliptic curve Diffie-Hellman key exchange. See [the Eddystone specification](https://github.com/google/eddystone/tree/master/eddystone-eid) at GitHub. +/// +/// # 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 eidparams](struct.MethodGetEidparamCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EphemeralIdRegistrationParams { + /// Indicates the minimum rotation period supported by the service. See EddystoneEidRegistration.rotation_period_exponent + #[serde(rename="minRotationPeriodExponent")] + pub min_rotation_period_exponent: Option, + /// Indicates the maximum rotation period supported by the service. See EddystoneEidRegistration.rotation_period_exponent + #[serde(rename="maxRotationPeriodExponent")] + pub max_rotation_period_exponent: Option, + /// The beacon service's public key for use by a beacon to derive its Identity Key using Elliptic Curve Diffie-Hellman key exchange. + #[serde(rename="serviceEcdhPublicKey")] + pub service_ecdh_public_key: Option, +} + +impl ResponseResult for EphemeralIdRegistrationParams {} + + +/// An object representing a latitude/longitude pair. This is expressed as a pair of doubles representing degrees latitude and degrees longitude. Unless specified otherwise, this must conform to the WGS84 standard. Values must be within normalized ranges. Example of normalization code in Python: def NormalizeLongitude(longitude): """Wraps decimal degrees longitude to [-180.0, 180.0].""" q, r = divmod(longitude, 360.0) if r > 180.0 or (r == 180.0 and q <= -1.0): return r - 360.0 return r def NormalizeLatLng(latitude, longitude): """Wraps decimal degrees latitude and longitude to [-90.0, 90.0] and [-180.0, 180.0], respectively.""" r = latitude % 360.0 if r = 270.0: return r - 360, NormalizeLongitude(longitude) else: return 180 - r, NormalizeLongitude(longitude + 180.0) assert 180.0 == NormalizeLongitude(180.0) assert -180.0 == NormalizeLongitude(-180.0) assert -179.0 == NormalizeLongitude(181.0) assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0) assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0) assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0) assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0) assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0) assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0) assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0) assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0) assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0) assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0) /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -437,7 +518,10 @@ pub struct Beacon { /// The [Google Places API](/places/place-id) Place ID of the place where the beacon is deployed. This is given when the beacon is registered or updated, not automatically detected in any way. Optional. #[serde(rename="placeId")] pub place_id: Option, - /// The identifier of a beacon as advertised by it. This field must be populated when registering. It may be empty when updating a beacon record because it is ignored in updates. + /// Write-only registration parameters for beacons using Eddystone-EID (remotely resolved ephemeral ID) format. This information will not be populated in API responses. When submitting this data, the `advertised_id` field must contain an ID of type Eddystone-UID. Any other ID type will result in an error. + #[serde(rename="ephemeralIdRegistration")] + pub ephemeral_id_registration: Option, + /// The identifier of a beacon as advertised by it. This field must be populated when registering. It may be empty when updating a beacon record because it is ignored in updates. When registering a beacon that broadcasts Eddystone-EID, this field should contain a "stable" Eddystone-UID that identifies the beacon and links it to its attachments. The stable Eddystone-UID is only used for administering the beacon. #[serde(rename="advertisedId")] pub advertised_id: Option, /// Resource name of this beacon. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone, `1` for iBeacon, or `5` for AltBeacon. This field must be left empty when registering. After reading a beacon, clients can use the name for future operations. @@ -448,6 +532,9 @@ pub struct Beacon { pub expected_stability: Option, /// Properties of the beacon device, for example battery type or firmware version. Optional. pub properties: Option>, + /// Some beacons may require a user to provide an authorization key before changing any of its configuration (e.g. broadcast frames, transmit power). This field provides a place to store and control access to that key. This field is populated in responses to `GET /v1beta1/beacons/3!beaconId` from users with write access to the given beacon. That is to say: If the user is authorized to write the beacon's confidential data in the service, the service considers them authorized to configure the beacon. Note that this key grants nothing on the service, only on the beacon itself. + #[serde(rename="provisioningKey")] + pub provisioning_key: Option, } impl RequestValue for Beacon {} @@ -494,17 +581,17 @@ pub struct ListDiagnosticsResponse { impl ResponseResult for ListDiagnosticsResponse {} -/// Represents a whole calendar date, e.g. date of birth. The time of day and time zone are either specified elsewhere or are not significant. The date is relative to the Proleptic Gregorian Calendar. The day may be 0 to represent a year and month where the day is not significant, e.g. credit card expiration date. The year may be 0 to represent a month and day independent of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][] and `google.protobuf.Timestamp`. +/// Represents a whole calendar date, e.g. date of birth. The time of day and time zone are either specified elsewhere or are not significant. The date is relative to the Proleptic Gregorian Calendar. The day may be 0 to represent a year and month where the day is not significant, e.g. credit card expiration date. The year may be 0 to represent a month and day independent of year, e.g. anniversary date. Related types are google.type.TimeOfDay and `google.protobuf.Timestamp`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Date { - /// Year of date. Must be from 1 to 9,999, or 0 if specifying a date without a year. + /// Year of date. Must be from 1 to 9999, or 0 if specifying a date without a year. pub year: Option, - /// Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a year/month where the day is not sigificant. + /// Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a year/month where the day is not significant. pub day: Option, - /// Month of year of date. Must be from 1 to 12. + /// Month of year. Must be from 1 to 12. pub month: Option, } @@ -575,33 +662,37 @@ impl<'a, C, A> BeaconMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint. + /// Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `beaconName` - The beacon whose attachments are to be fetched. Required. + /// * `beaconName` - Beacon whose attachments should be fetched. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn attachments_list(&self, beacon_name: &str) -> BeaconAttachmentListCall<'a, C, A> { BeaconAttachmentListCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _namespaced_type: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Returns detailed information about the specified beacon. + /// Returns detailed information about the specified beacon. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. Requests may supply an Eddystone-EID beacon name in the form: `beacons/4!beaconId` where the `beaconId` is the base16 ephemeral ID broadcast by the beacon. The returned `Beacon` object will contain the beacon's stable Eddystone-UID. Clients not authorized to resolve the beacon's ephemeral Eddystone-EID broadcast will receive an error. /// /// # Arguments /// - /// * `beaconName` - Beacon that is requested. + /// * `beaconName` - Resource name of this beacon. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn get(&self, beacon_name: &str) -> BeaconGetCall<'a, C, A> { BeaconGetCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } @@ -610,71 +701,79 @@ impl<'a, C, A> BeaconMethods<'a, C, A> { /// /// Associates the given data with the specified beacon. Attachment data must contain two parts: /// - A namespaced type. - /// - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long. + /// - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// /// * `request` - No description provided. - /// * `beaconName` - The beacon on which the attachment should be created. Required. + /// * `beaconName` - Beacon on which the attachment should be created. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn attachments_create(&self, request: BeaconAttachment, beacon_name: &str) -> BeaconAttachmentCreateCall<'a, C, A> { BeaconAttachmentCreateCall { hub: self.hub, _request: request, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again. + /// Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `beaconName` - Beacon that should be decommissioned. Required. + /// * `beaconName` - Beacon that should be decommissioned. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID of the beacon's "stable" UID. Required. pub fn decommission(&self, beacon_name: &str) -> BeaconDecommissionCall<'a, C, A> { BeaconDecommissionCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// (Re)activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code). + /// Activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `beaconName` - The beacon to activate. Required. + /// * `beaconName` - Beacon that should be activated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn activate(&self, beacon_name: &str) -> BeaconActivateCall<'a, C, A> { BeaconActivateCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned. + /// Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. pub fn list(&self) -> BeaconListCall<'a, C, A> { BeaconListCall { hub: self.hub, _q: Default::default(), + _project_id: Default::default(), _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 the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for (de)activation and decommissioning. + /// Updates the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for activation, deactivation, and decommissioning. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// @@ -685,46 +784,52 @@ impl<'a, C, A> BeaconMethods<'a, C, A> { hub: self.hub, _request: request, _beacon_name: beacon_name.to_string(), + _project_id: 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 attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone. + /// Deletes the specified attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `attachmentName` - The attachment name (`attachmentName`) of the attachment to remove. For example: `beacons/3!893737abc9/attachments/c5e937-af0-494-959-ec49d12738` Required. + /// * `attachmentName` - The attachment name (`attachmentName`) of the attachment to remove. For example: `beacons/3!893737abc9/attachments/c5e937-af0-494-959-ec49d12738`. For Eddystone-EID beacons, the beacon ID portion (`3!893737abc9`) may be the beacon's current EID, or its "stable" Eddystone-UID. Required. pub fn attachments_delete(&self, attachment_name: &str) -> BeaconAttachmentDeleteCall<'a, C, A> { BeaconAttachmentDeleteCall { hub: self.hub, _attachment_name: attachment_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code). + /// Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `beaconName` - The beacon name of this beacon. + /// * `beaconName` - Beacon that should be deactivated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn deactivate(&self, beacon_name: &str) -> BeaconDeactivateCall<'a, C, A> { BeaconDeactivateCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once. + /// Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// @@ -733,14 +838,16 @@ impl<'a, C, A> BeaconMethods<'a, C, A> { BeaconRegisterCall { hub: self.hub, _request: request, + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`. + /// List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// @@ -749,27 +856,31 @@ impl<'a, C, A> BeaconMethods<'a, C, A> { BeaconDiagnosticListCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _page_token: Default::default(), _page_size: Default::default(), _alert_filter: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// - /// Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all. + /// Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// # Arguments /// - /// * `beaconName` - The beacon whose attachments are to be deleted. Required. + /// * `beaconName` - The beacon whose attachments should be deleted. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. pub fn attachments_batch_delete(&self, beacon_name: &str) -> BeaconAttachmentBatchDeleteCall<'a, C, A> { BeaconAttachmentBatchDeleteCall { hub: self.hub, _beacon_name: beacon_name.to_string(), + _project_id: Default::default(), _namespaced_type: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } @@ -817,7 +928,7 @@ impl<'a, C, A> BeaconinfoMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Given one or more beacon observations, returns any beacon information and attachments accessible to your application. + /// Given one or more beacon observations, returns any beacon information and attachments accessible to your application. Authorize by using the [API key](https://developers.google.com/beacons/proximity/how-tos/authorizing#APIKey) for the application. /// /// # Arguments /// @@ -834,6 +945,59 @@ impl<'a, C, A> BeaconinfoMethods<'a, C, A> { +/// A builder providing access to all free methods, which are not associated with a particular resource. +/// It is not used directly, but through the `Proximitybeacon` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_proximitybeacon1_beta1 as proximitybeacon1_beta1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use proximitybeacon1_beta1::Proximitybeacon; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Proximitybeacon::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get_eidparams(...)` +/// // to build up your call. +/// let rb = hub.methods(); +/// # } +/// ``` +pub struct MethodMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Proximitybeacon, +} + +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: + /// + /// Gets the Proximity Beacon API's current public key and associated parameters used to initiate the Diffie-Hellman key exchange required to register a beacon that broadcasts the Eddystone-EID format. This key changes periodically; clients may cache it and re-use the same public key to provision and register multiple beacons. However, clients should be prepared to refresh this key when they encounter an error registering an Eddystone-EID beacon. + pub fn get_eidparams(&self) -> MethodGetEidparamCall<'a, C, A> { + MethodGetEidparamCall { + hub: self.hub, + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *namespace* resources. /// It is not used directly, but through the `Proximitybeacon` hub. /// @@ -857,7 +1021,7 @@ impl<'a, C, A> BeaconinfoMethods<'a, C, A> { /// ::default(), None); /// let mut hub = Proximitybeacon::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `list(...)` and `update(...)` /// // to build up your call. /// let rb = hub.namespaces(); /// # } @@ -874,11 +1038,33 @@ impl<'a, C, A> NamespaceMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all attachment namespaces owned by your Google Developers Console project. Attachment data associated with a beacon must include a namespaced type, and the namespace must be owned by your project. + /// Lists all attachment namespaces owned by your Google Developers Console project. Attachment data associated with a beacon must include a namespaced type, and the namespace must be owned by your project. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. pub fn list(&self) -> NamespaceListCall<'a, C, A> { NamespaceListCall { hub: self.hub, + _project_id: Default::default(), _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates the information about the specified namespace. Only the namespace visibility can be updated. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `namespaceName` - Resource name of this namespace. Namespaces names have the format: namespaces/namespace. + pub fn update(&self, request: Namespace, namespace_name: &str) -> NamespaceUpdateCall<'a, C, A> { + NamespaceUpdateCall { + hub: self.hub, + _request: request, + _namespace_name: namespace_name.to_string(), + _project_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), _additional_params: Default::default(), } } @@ -892,7 +1078,7 @@ impl<'a, C, A> NamespaceMethods<'a, C, A> { // CallBuilders ### // ################# -/// Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint. +/// Returns the attachments for the specified beacon that match the specified namespaced-type pattern. To control which namespaced types are returned, you add the `namespacedType` query parameter to the request. You must either use `*/*`, to return all attachments, or the namespace must be one of the ones returned from the `namespaces` endpoint. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *attachments.list* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -919,7 +1105,8 @@ impl<'a, C, A> NamespaceMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().attachments_list("beaconName") -/// .namespaced_type("justo") +/// .project_id("erat") +/// .namespaced_type("labore") /// .doit(); /// # } /// ``` @@ -928,9 +1115,11 @@ pub struct BeaconAttachmentListCall<'a, C, A> hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _namespaced_type: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconAttachmentListCall<'a, C, A> {} @@ -950,12 +1139,15 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } if let Some(value) = self._namespaced_type { params.push(("namespacedType", value.to_string())); } - for &field in ["alt", "beaconName", "namespacedType"].iter() { + for &field in ["alt", "beaconName", "projectId", "namespacedType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -968,17 +1160,8 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -1014,10 +1197,24 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -1068,7 +1265,7 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut BeaconAttachmentListCall<'a, C, A> where C: BorrowMut BeaconAttachmentListCall<'a, C, A> { + self._project_id = Some(new_value.to_string()); + self + } /// Specifies the namespace and type of attachment to include in response in namespace/type format. Accepts `*/*` to specify "all types in all namespaces". /// /// Sets the *namespaced type* query property to the given value. @@ -1124,10 +1328,26 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconAttachmentListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Returns detailed information about the specified beacon. +/// Returns detailed information about the specified beacon. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. Requests may supply an Eddystone-EID beacon name in the form: `beacons/4!beaconId` where the `beaconId` is the base16 ephemeral ID broadcast by the beacon. The returned `Beacon` object will contain the beacon's stable Eddystone-UID. Clients not authorized to resolve the beacon's ephemeral Eddystone-EID broadcast will receive an error. /// /// A builder for the *get* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -1154,6 +1374,7 @@ impl<'a, C, A> BeaconAttachmentListCall<'a, C, A> where C: BorrowMut hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconGetCall<'a, C, A> {} @@ -1183,9 +1406,12 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1198,17 +1424,8 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/{+beaconName}".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -1244,10 +1461,24 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -1298,7 +1529,7 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau } - /// Beacon that is requested. + /// Resource name of this beacon. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. /// /// Sets the *beacon name* path property to the given value. /// @@ -1308,6 +1539,13 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau self._beacon_name = new_value.to_string(); self } + /// The project id of the beacon to request. If the project id is not specified then the project making the request is used. The project id must match the project that owns the beacon. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconGetCall<'a, C, A> { + self._project_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. /// @@ -1347,12 +1585,28 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconGetCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } /// Associates the given data with the specified beacon. Attachment data must contain two parts: /// - A namespaced type. -/// - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long. +/// - The actual attachment data itself. The namespaced type consists of two parts, the namespace and the type. The namespace must be one of the values returned by the `namespaces` endpoint, while the type can be a string of any characters except for the forward slash (`/`) up to 100 characters in length. Attachment data can be up to 1024 bytes long. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *attachments.create* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -1385,6 +1639,7 @@ impl<'a, C, A> BeaconGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().attachments_create(req, "beaconName") +/// .project_id("gubergren") /// .doit(); /// # } /// ``` @@ -1394,8 +1649,10 @@ pub struct BeaconAttachmentCreateCall<'a, C, A> hub: &'a Proximitybeacon, _request: BeaconAttachment, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconAttachmentCreateCall<'a, C, A> {} @@ -1415,9 +1672,12 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1430,17 +1690,8 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -1487,11 +1738,25 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut 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); @@ -1554,7 +1819,7 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut BeaconAttachmentCreateCall<'a, C, A> { + self._project_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. /// @@ -1603,10 +1875,26 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconAttachmentCreateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again. +/// Decommissions the specified beacon in the service. This beacon will no longer be returned from `beaconinfo.getforobserved`. This operation is permanent -- you will not be able to re-register a beacon with this ID again. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *decommission* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -1633,6 +1921,7 @@ impl<'a, C, A> BeaconAttachmentCreateCall<'a, C, A> where C: BorrowMut hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconDecommissionCall<'a, C, A> {} @@ -1662,9 +1953,12 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1677,17 +1971,8 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -1723,10 +2008,24 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -1777,7 +2076,7 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut BeaconDecommissionCall<'a, C, A> where C: BorrowMut BeaconDecommissionCall<'a, C, A> { + self._project_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. /// @@ -1826,10 +2132,26 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconDecommissionCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// (Re)activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code). +/// Activates a beacon. A beacon that is active will return information and attachment data when queried via `beaconinfo.getforobserved`. Calling this method on an already active beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *activate* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -1856,6 +2178,7 @@ impl<'a, C, A> BeaconDecommissionCall<'a, C, A> where C: BorrowMut hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconActivateCall<'a, C, A> {} @@ -1885,9 +2210,12 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.activate", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -1900,17 +2228,8 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/{+beaconName}:activate".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -1946,10 +2265,24 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -2000,7 +2333,7 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A } - /// The beacon to activate. Required. + /// Beacon that should be activated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. /// /// Sets the *beacon name* path property to the given value. /// @@ -2010,6 +2343,13 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A self._beacon_name = new_value.to_string(); self } + /// The project id of the beacon to activate. If the project id is not specified then the project making the request is used. The project id must match the project that owns the beacon. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconActivateCall<'a, C, A> { + self._project_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. /// @@ -2049,10 +2389,26 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconActivateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned. +/// Searches the beacon registry for beacons that match the given search criteria. Only those beacons that the client has permission to list will be returned. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *list* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -2079,9 +2435,10 @@ impl<'a, C, A> BeaconActivateCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().list() -/// .q("nonumy") -/// .page_token("dolores") -/// .page_size(-61) +/// .q("justo") +/// .project_id("justo") +/// .page_token("et") +/// .page_size(-17) /// .doit(); /// # } /// ``` @@ -2090,10 +2447,12 @@ pub struct BeaconListCall<'a, C, A> hub: &'a Proximitybeacon, _q: Option, + _project_id: Option, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconListCall<'a, C, A> {} @@ -2112,17 +2471,20 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); if let Some(value) = self._q { params.push(("q", value.to_string())); } + if let Some(value) = self._project_id { + params.push(("projectId", value.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", "q", "pageToken", "pageSize"].iter() { + for &field in ["alt", "q", "projectId", "pageToken", "pageSize"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2135,17 +2497,8 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/beacons".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } @@ -2157,10 +2510,24 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -2211,13 +2578,20 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa } - /// Filter query string that supports the following field filters: * `description:""` For example: `description:"Room 3"` Returns beacons whose description matches tokens in the string "Room 3" (not necessarily that exact string). The string must be double-quoted. * `status:` For example: `status:active` Returns beacons whose status matches the given value. Values must be one of the Beacon.Status enum values (case insensitive). Accepts multiple filters which will be combined with OR logic. * `stability:` For example: `stability:mobile` Returns beacons whose expected stability matches the given value. Values must be one of the Beacon.Stability enum values (case insensitive). Accepts multiple filters which will be combined with OR logic. * `place_id:""` For example: `place_id:"ChIJVSZzVR8FdkgRXGmmm6SslKw="` Returns beacons explicitly registered at the given place, expressed as a Place ID obtained from [Google Places API](/places/place-id). Does not match places inside the given place. Does not consider the beacon's actual location (which may be different from its registered place). Accepts multiple filters that will be combined with OR logic. The place ID must be double-quoted. * `registration_time[|=]` For example: `registration_time>=1433116800` Returns beacons whose registration time matches the given filter. Supports the operators: , =. Timestamp must be expressed as an integer number of seconds since midnight January 1, 1970 UTC. Accepts at most two filters that will be combined with AND logic, to support "between" semantics. If more than two are supplied, the latter ones are ignored. * `lat: lng: radius:` For example: `lat:51.1232343 lng:-1.093852 radius:1000` Returns beacons whose registered location is within the given circle. When any of these fields are given, all are required. Latitude and longitude must be decimal degrees between -90.0 and 90.0 and between -180.0 and 180.0 respectively. Radius must be an integer number of meters less than 1,000,000 (1000 km). * `property:"="` For example: `property:"battery-type=CR2032"` Returns beacons which have a property of the given name and value. Supports multiple filters which will be combined with OR logic. The entire name=value string must be double-quoted as one string. * `attachment_type:""` For example: `attachment_type:"my-namespace/my-type"` Returns beacons having at least one attachment of the given namespaced type. Supports "any within this namespace" via the partial wildcard syntax: "my-namespace/*". Supports multiple filters which will be combined with OR logic. The string must be double-quoted. Multiple filters on the same field are combined with OR logic (except registration_time which is combined with AND logic). Multiple filters on different fields are combined with AND logic. Filters should be separated by spaces. As with any HTTP query string parameter, the whole filter expression must be URL-encoded. Example REST request: `GET /v1beta1/beacons?q=status:active%20lat:51.123%20lng:-1.095%20radius:1000` + /// Filter query string that supports the following field filters: * `description:""` For example: `description:"Room 3"` Returns beacons whose description matches tokens in the string "Room 3" (not necessarily that exact string). The string must be double-quoted. * `status:` For example: `status:active` Returns beacons whose status matches the given value. Values must be one of the Beacon.Status enum values (case insensitive). Accepts multiple filters which will be combined with OR logic. * `stability:` For example: `stability:mobile` Returns beacons whose expected stability matches the given value. Values must be one of the Beacon.Stability enum values (case insensitive). Accepts multiple filters which will be combined with OR logic. * `place_id:""` For example: `place_id:"ChIJVSZzVR8FdkgRXGmmm6SslKw="` Returns beacons explicitly registered at the given place, expressed as a Place ID obtained from [Google Places API](/places/place-id). Does not match places inside the given place. Does not consider the beacon's actual location (which may be different from its registered place). Accepts multiple filters that will be combined with OR logic. The place ID must be double-quoted. * `registration_time[|=]` For example: `registration_time>=1433116800` Returns beacons whose registration time matches the given filter. Supports the operators: , =. Timestamp must be expressed as an integer number of seconds since midnight January 1, 1970 UTC. Accepts at most two filters that will be combined with AND logic, to support "between" semantics. If more than two are supplied, the latter ones are ignored. * `lat: lng: radius:` For example: `lat:51.1232343 lng:-1.093852 radius:1000` Returns beacons whose registered location is within the given circle. When any of these fields are given, all are required. Latitude and longitude must be decimal degrees between -90.0 and 90.0 and between -180.0 and 180.0 respectively. Radius must be an integer number of meters between 10 and 1,000,000 (1000 km). * `property:"="` For example: `property:"battery-type=CR2032"` Returns beacons which have a property of the given name and value. Supports multiple filters which will be combined with OR logic. The entire name=value string must be double-quoted as one string. * `attachment_type:""` For example: `attachment_type:"my-namespace/my-type"` Returns beacons having at least one attachment of the given namespaced type. Supports "any within this namespace" via the partial wildcard syntax: "my-namespace/*". Supports multiple filters which will be combined with OR logic. The string must be double-quoted. Multiple filters on the same field are combined with OR logic (except registration_time which is combined with AND logic). Multiple filters on different fields are combined with AND logic. Filters should be separated by spaces. As with any HTTP query string parameter, the whole filter expression must be URL-encoded. Example REST request: `GET /v1beta1/beacons?q=status:active%20lat:51.123%20lng:-1.095%20radius:1000` /// /// Sets the *q* query property to the given value. pub fn q(mut self, new_value: &str) -> BeaconListCall<'a, C, A> { self._q = Some(new_value.to_string()); self } + /// The project id to list beacons under. If not present then the project credential that made the request is used as the project. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconListCall<'a, C, A> { + self._project_id = Some(new_value.to_string()); + self + } /// A pagination token obtained from a previous request to list beacons. /// /// Sets the *page token* query property to the given value. @@ -2271,10 +2645,26 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Updates the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for (de)activation and decommissioning. +/// Updates the information about the specified beacon. **Any field that you do not populate in the submitted beacon will be permanently erased**, so you should follow the "read, modify, write" pattern to avoid inadvertently destroying data. Changes to the beacon status via this method will be silently ignored. To update beacon status, use the separate methods on this API for activation, deactivation, and decommissioning. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *update* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -2307,6 +2697,7 @@ impl<'a, C, A> BeaconListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().update(req, "beaconName") +/// .project_id("ipsum") /// .doit(); /// # } /// ``` @@ -2316,8 +2707,10 @@ pub struct BeaconUpdateCall<'a, C, A> hub: &'a Proximitybeacon, _request: Beacon, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconUpdateCall<'a, C, A> {} @@ -2337,9 +2730,12 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2352,17 +2748,8 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/{+beaconName}".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -2409,11 +2796,25 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: 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); @@ -2486,6 +2887,13 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: self._beacon_name = new_value.to_string(); self } + /// The project id of the beacon to update. If the project id is not specified then the project making the request is used. The project id must match the project that owns the beacon. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconUpdateCall<'a, C, A> { + self._project_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. /// @@ -2525,10 +2933,26 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Deletes the specified attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone. +/// Deletes the specified attachment for the given beacon. Each attachment has a unique attachment name (`attachmentName`) which is returned when you fetch the attachment data via this API. You specify this with the delete request to control which attachment is removed. This operation cannot be undone. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *attachments.delete* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -2555,6 +2979,7 @@ impl<'a, C, A> BeaconUpdateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().attachments_delete("attachmentName") +/// .project_id("et") /// .doit(); /// # } /// ``` @@ -2563,8 +2988,10 @@ pub struct BeaconAttachmentDeleteCall<'a, C, A> hub: &'a Proximitybeacon, _attachment_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconAttachmentDeleteCall<'a, C, A> {} @@ -2584,9 +3011,12 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("attachmentName", self._attachment_name.to_string())); - for &field in ["alt", "attachmentName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "attachmentName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2599,17 +3029,8 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+attachmentName}", "attachmentName")].iter() { @@ -2645,10 +3066,24 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -2699,7 +3134,7 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut BeaconAttachmentDeleteCall<'a, C, A> { + self._project_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. /// @@ -2748,10 +3190,26 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconAttachmentDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code). +/// Deactivates a beacon. Once deactivated, the API will not return information nor attachment data for the beacon when queried via `beaconinfo.getforobserved`. Calling this method on an already inactive beacon will do nothing (but will return a successful response code). Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *deactivate* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -2778,6 +3236,7 @@ impl<'a, C, A> BeaconAttachmentDeleteCall<'a, C, A> where C: BorrowMut hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconDeactivateCall<'a, C, A> {} @@ -2807,9 +3268,12 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.deactivate", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); - for &field in ["alt", "beaconName"].iter() { + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "beaconName", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -2822,17 +3286,8 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/{+beaconName}:deactivate".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -2868,10 +3323,24 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -2922,7 +3391,7 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, } - /// The beacon name of this beacon. + /// Beacon that should be deactivated. A beacon name has the format "beacons/N!beaconId" where the beaconId is the base16 ID broadcast by the beacon and N is a code for the beacon's type. Possible values are `3` for Eddystone-UID, `4` for Eddystone-EID, `1` for iBeacon, or `5` for AltBeacon. For Eddystone-EID beacons, you may use either the current EID or the beacon's "stable" UID. Required. /// /// Sets the *beacon name* path property to the given value. /// @@ -2932,6 +3401,13 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, self._beacon_name = new_value.to_string(); self } + /// The project id of the beacon to deactivate. If the project id is not specified then the project making the request is used. The project id must match the project that owns the beacon. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconDeactivateCall<'a, C, A> { + self._project_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. /// @@ -2971,10 +3447,26 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconDeactivateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once. +/// Registers a previously unregistered beacon given its `advertisedId`. These IDs are unique within the system. An ID can be registered only once. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *register* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -3007,6 +3499,7 @@ impl<'a, C, A> BeaconDeactivateCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().register(req) +/// .project_id("sea") /// .doit(); /// # } /// ``` @@ -3015,8 +3508,10 @@ pub struct BeaconRegisterCall<'a, C, A> hub: &'a Proximitybeacon, _request: Beacon, + _project_id: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconRegisterCall<'a, C, A> {} @@ -3035,8 +3530,11 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A }; dlg.begin(MethodInfo { id: "proximitybeacon.beacons.register", 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() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "projectId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3049,17 +3547,8 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A params.push(("alt", "json".to_string())); let mut url = "https://proximitybeacon.googleapis.com/v1beta1/beacons:register".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 self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } @@ -3082,11 +3571,25 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A 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); @@ -3149,6 +3652,13 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A self._request = new_value; self } + /// The project id of the project the beacon will be registered to. If the project id is not specified then the project making the request is used. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> BeaconRegisterCall<'a, C, A> { + self._project_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. /// @@ -3188,10 +3698,26 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A 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::UserlocationBeaconRegistry`. + /// + /// 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) -> BeaconRegisterCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`. +/// List the diagnostics for a single beacon. You can also list diagnostics for all the beacons owned by your Google Developers Console project by using the beacon name `beacons/-`. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *diagnostics.list* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -3218,9 +3744,10 @@ impl<'a, C, A> BeaconRegisterCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.beacons().diagnostics_list("beaconName") -/// .page_token("justo") -/// .page_size(-21) -/// .alert_filter("et") +/// .project_id("eos") +/// .page_token("erat") +/// .page_size(-95) +/// .alert_filter("dolor") /// .doit(); /// # } /// ``` @@ -3229,11 +3756,13 @@ pub struct BeaconDiagnosticListCall<'a, C, A> hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _page_token: Option, _page_size: Option, _alert_filter: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconDiagnosticListCall<'a, C, A> {} @@ -3253,8 +3782,11 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((6 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } @@ -3264,7 +3796,7 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -3323,10 +3846,24 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -3387,6 +3924,13 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut BeaconDiagnosticListCall<'a, C, A> { + self._project_id = Some(new_value.to_string()); + self + } /// Requests results that occur after the `page_token`, obtained from the response to a previous request. Optional. /// /// Sets the *page token* query property to the given value. @@ -3447,10 +3991,26 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconDiagnosticListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all. +/// Deletes multiple attachments on a given beacon. This operation is permanent and cannot be undone. You can optionally specify `namespacedType` to choose which attachments should be deleted. If you do not specify `namespacedType`, all your attachments on the given beacon will be deleted. You also may explicitly specify `*/*` to delete all. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **Is owner** or **Can edit** permissions in the Google Developers Console project. /// /// A builder for the *attachments.batchDelete* method supported by a *beacon* resource. /// It is not used directly, but through a `BeaconMethods` instance. @@ -3477,7 +4037,8 @@ impl<'a, C, A> BeaconDiagnosticListCall<'a, C, A> where C: BorrowMut hub: &'a Proximitybeacon, _beacon_name: String, + _project_id: Option, _namespaced_type: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } impl<'a, C, A> CallBuilder for BeaconAttachmentBatchDeleteCall<'a, C, A> {} @@ -3508,12 +4071,15 @@ impl<'a, C, A> BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((4 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("beaconName", self._beacon_name.to_string())); + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } if let Some(value) = self._namespaced_type { params.push(("namespacedType", value.to_string())); } - for &field in ["alt", "beaconName", "namespacedType"].iter() { + for &field in ["alt", "beaconName", "projectId", "namespacedType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3526,17 +4092,8 @@ impl<'a, C, A> BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() { @@ -3572,10 +4129,24 @@ impl<'a, C, A> BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -3626,7 +4197,7 @@ impl<'a, C, A> BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut BeaconAttachmentBatchDeleteCall<'a, C, A> { + self._project_id = Some(new_value.to_string()); + self + } /// Specifies the namespace and type of attachments to delete in `namespace/type` format. Accepts `*/*` to specify "all types in all namespaces". Optional. /// /// Sets the *namespaced type* query property to the given value. @@ -3682,10 +4260,26 @@ impl<'a, C, A> BeaconAttachmentBatchDeleteCall<'a, C, A> where C: BorrowMut(mut self, scope: T) -> BeaconAttachmentBatchDeleteCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } -/// Given one or more beacon observations, returns any beacon information and attachments accessible to your application. +/// Given one or more beacon observations, returns any beacon information and attachments accessible to your application. Authorize by using the [API key](https://developers.google.com/beacons/proximity/how-tos/authorizing#APIKey) for the application. /// /// A builder for the *getforobserved* method supported by a *beaconinfo* resource. /// It is not used directly, but through a `BeaconinfoMethods` instance. @@ -3902,10 +4496,10 @@ impl<'a, C, A> BeaconinfoGetforobservedCall<'a, C, A> where C: BorrowMut BeaconinfoGetforobservedCall<'a, C, A> where C: BorrowMut +pub struct MethodGetEidparamCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Proximitybeacon, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, + _scopes: BTreeMap } -impl<'a, C, A> CallBuilder for NamespaceListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for MethodGetEidparamCall<'a, C, A> {} -impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { +impl<'a, C, A> MethodGetEidparamCall<'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, ListNamespacesResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, EphemeralIdRegistrationParams)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -3954,7 +4549,7 @@ impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "proximitybeacon.namespaces.list", + dlg.begin(MethodInfo { id: "proximitybeacon.getEidparams", 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() { @@ -3969,18 +4564,9 @@ impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: params.push(("alt", "json".to_string())); - let mut url = "https://proximitybeacon.googleapis.com/v1beta1/namespaces".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) - } + let mut url = "https://proximitybeacon.googleapis.com/v1beta1/eidparams".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); } @@ -3992,10 +4578,24 @@ impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: 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(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); dlg.pre_request(); req.send() @@ -4046,6 +4646,226 @@ impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> MethodGetEidparamCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> MethodGetEidparamCall<'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::UserlocationBeaconRegistry`. + /// + /// 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) -> MethodGetEidparamCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists all attachment namespaces owned by your Google Developers Console project. Attachment data associated with a beacon must include a namespaced type, and the namespace must be owned by your project. Authenticate using an [OAuth access token](https://developers.google.com/identity/protocols/OAuth2) from a signed-in user with **viewer**, **Is owner** or **Can edit** permissions in the Google Developers Console project. +/// +/// A builder for the *list* method supported by a *namespace* resource. +/// It is not used directly, but through a `NamespaceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_proximitybeacon1_beta1 as proximitybeacon1_beta1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use proximitybeacon1_beta1::Proximitybeacon; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Proximitybeacon::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.namespaces().list() +/// .project_id("no") +/// .doit(); +/// # } +/// ``` +pub struct NamespaceListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Proximitybeacon, + _project_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for NamespaceListCall<'a, C, A> {} + +impl<'a, C, A> NamespaceListCall<'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, ListNamespacesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "proximitybeacon.namespaces.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._project_id { + params.push(("projectId", value.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://proximitybeacon.googleapis.com/v1beta1/namespaces".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.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 project id to list namespaces under. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> NamespaceListCall<'a, C, A> { + self._project_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. /// @@ -4085,6 +4905,310 @@ impl<'a, C, A> NamespaceListCall<'a, C, A> where C: BorrowMut, A: 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::UserlocationBeaconRegistry`. + /// + /// 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) -> NamespaceListCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates the information about the specified namespace. Only the namespace visibility can be updated. +/// +/// A builder for the *update* method supported by a *namespace* resource. +/// It is not used directly, but through a `NamespaceMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_proximitybeacon1_beta1 as proximitybeacon1_beta1; +/// use proximitybeacon1_beta1::Namespace; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use proximitybeacon1_beta1::Proximitybeacon; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Proximitybeacon::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 = Namespace::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.namespaces().update(req, "namespaceName") +/// .project_id("eirmod") +/// .doit(); +/// # } +/// ``` +pub struct NamespaceUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Proximitybeacon, + _request: Namespace, + _namespace_name: String, + _project_id: Option, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for NamespaceUpdateCall<'a, C, A> {} + +impl<'a, C, A> NamespaceUpdateCall<'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, Namespace)> { + use url::percent_encoding::{percent_encode, FORM_URLENCODED_ENCODE_SET}; + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "proximitybeacon.namespaces.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("namespaceName", self._namespace_name.to_string())); + if let Some(value) = self._project_id { + params.push(("projectId", value.to_string())); + } + for &field in ["alt", "namespaceName", "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://proximitybeacon.googleapis.com/v1beta1/{+namespaceName}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{+namespaceName}", "namespaceName")].iter() { + let mut replace_with = String::new(); + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = value.to_string(); + break; + } + } + if find_this.as_bytes()[1] == '+' as u8 { + replace_with = percent_encode(replace_with.as_bytes(), FORM_URLENCODED_ENCODE_SET); + } + url = url.replace(find_this, &replace_with); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["namespaceName"].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: Namespace) -> NamespaceUpdateCall<'a, C, A> { + self._request = new_value; + self + } + /// Resource name of this namespace. Namespaces names have the format: namespaces/namespace. + /// + /// Sets the *namespace name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn namespace_name(mut self, new_value: &str) -> NamespaceUpdateCall<'a, C, A> { + self._namespace_name = new_value.to_string(); + self + } + /// The project id of the namespace to update. If the project id is not specified then the project making the request is used. The project id must match the project that owns the beacon. Optional. + /// + /// Sets the *project id* query property to the given value. + pub fn project_id(mut self, new_value: &str) -> NamespaceUpdateCall<'a, C, A> { + self._project_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) -> NamespaceUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> NamespaceUpdateCall<'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::UserlocationBeaconRegistry`. + /// + /// 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) -> NamespaceUpdateCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } } diff --git a/gen/pubsub1-cli/Cargo.toml b/gen/pubsub1-cli/Cargo.toml index 17ca300998..56f667335f 100644 --- a/gen/pubsub1-cli/Cargo.toml +++ b/gen/pubsub1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "pubsub1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-pubsub1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-pubsub1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pubsub1] diff --git a/gen/pubsub1/Cargo.toml b/gen/pubsub1/Cargo.toml index ed942de4d8..244d6676ac 100644 --- a/gen/pubsub1/Cargo.toml +++ b/gen/pubsub1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/pubsub1_beta2-cli/Cargo.toml b/gen/pubsub1_beta2-cli/Cargo.toml index 623d5f4863..5fce0cb880 100644 --- a/gen/pubsub1_beta2-cli/Cargo.toml +++ b/gen/pubsub1_beta2-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "pubsub1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-pubsub1_beta2] diff --git a/gen/pubsub1_beta2/Cargo.toml b/gen/pubsub1_beta2/Cargo.toml index 237366acc9..b3d19a51ef 100644 --- a/gen/pubsub1_beta2/Cargo.toml +++ b/gen/pubsub1_beta2/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/qpxexpress1-cli/Cargo.toml b/gen/qpxexpress1-cli/Cargo.toml index af64134891..2c18742c87 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+20160307" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "qpxexpress1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-qpxexpress1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-qpxexpress1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-qpxexpress1] diff --git a/gen/qpxexpress1-cli/README.md b/gen/qpxexpress1-cli/README.md index 5176b1a07e..2b47f299e0 100644 --- a/gen/qpxexpress1-cli/README.md +++ b/gen/qpxexpress1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *QPX Express* API at revision *20160307*. 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 *0.3.6*. ```bash qpxexpress1 [options] diff --git a/gen/qpxexpress1-cli/mkdocs.yml b/gen/qpxexpress1-cli/mkdocs.yml index 66d80ef85a..021c49e0d4 100644 --- a/gen/qpxexpress1-cli/mkdocs.yml +++ b/gen/qpxexpress1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: QPX Express v0.3.6+20160307 +site_name: QPX Express v0.3.6+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 aceb0bc882..ba973ca41f 100644 --- a/gen/qpxexpress1-cli/src/main.rs +++ b/gen/qpxexpress1-cli/src/main.rs @@ -68,7 +68,6 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { - "request.refundable" => Some(("request.refundable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "request.passengers.kind" => Some(("request.passengers.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "request.passengers.infant-in-lap-count" => Some(("request.passengers.infantInLapCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "request.passengers.senior-count" => Some(("request.passengers.seniorCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), @@ -76,10 +75,12 @@ impl<'n> Engine<'n> { "request.passengers.child-count" => Some(("request.passengers.childCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "request.passengers.adult-count" => Some(("request.passengers.adultCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "request.sale-country" => Some(("request.saleCountry", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "request.solutions" => Some(("request.solutions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "request.max-price" => Some(("request.maxPrice", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "request.ticketing-country" => Some(("request.ticketingCountry", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "request.solutions" => Some(("request.solutions", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "request.refundable" => Some(("request.refundable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["adult-count", "child-count", "infant-in-lap-count", "infant-in-seat-count", "kind", "max-price", "passengers", "refundable", "request", "sale-country", "senior-count", "solutions"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["adult-count", "child-count", "infant-in-lap-count", "infant-in-seat-count", "kind", "max-price", "passengers", "refundable", "request", "sale-country", "senior-count", "solutions", "ticketing-country"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -263,7 +264,7 @@ fn main() { let mut app = App::new("qpxexpress1") .author("Sebastian Thiel ") - .version("0.3.6+20160307") + .version("0.3.6+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/qpxexpress1/Cargo.toml b/gen/qpxexpress1/Cargo.toml index 6110098d7c..b5a3487aa4 100644 --- a/gen/qpxexpress1/Cargo.toml +++ b/gen/qpxexpress1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-qpxexpress1" -version = "0.1.14+20160307" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/qpxexpress1/README.md b/gen/qpxexpress1/README.md index 80f1604856..86b9d9eadd 100644 --- a/gen/qpxexpress1/README.md +++ b/gen/qpxexpress1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-qpxexpress1` library allows access to all features of the *Google QPX Express* service. -This documentation was generated from *QPX Express* crate version *0.1.14+20160307*, where *20160307* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *QPX Express* crate version *0.1.14+20160708*, where *20160708* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *QPX Express* *v1* API can be found at the [official documentation site](http://developers.google.com/qpx-express). diff --git a/gen/qpxexpress1/src/lib.rs b/gen/qpxexpress1/src/lib.rs index 7c2ff8ecc9..33e37f18da 100644 --- a/gen/qpxexpress1/src/lib.rs +++ b/gen/qpxexpress1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *QPX Express* crate version *0.1.14+20160307*, where *20160307* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *QPX Express* crate version *0.1.14+20160708*, where *20160708* is the exact revision of the *qpxExpress:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *QPX Express* *v1* API can be found at the //! [official documentation site](http://developers.google.com/qpx-express). diff --git a/gen/qpxexpress1/src/lib.rs.in b/gen/qpxexpress1/src/lib.rs.in index dd2bb6b2fc..a40b957040 100644 --- a/gen/qpxexpress1/src/lib.rs.in +++ b/gen/qpxexpress1/src/lib.rs.in @@ -309,6 +309,9 @@ impl Part for SegmentInfo {} pub struct TripOptionsRequest { /// Counts for each passenger type in the request. pub passengers: Option, + /// IATA country code representing the point of ticketing. + #[serde(rename="ticketingCountry")] + pub ticketing_country: Option, /// The slices that make up the itinerary of this trip. A slice represents a traveler's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using one slice, round-trips using two. An example of a one slice trip with three segments might be BOS-SYD, SYD-LAX, LAX-BOS if the traveler only stopped in SYD and LAX just long enough to change planes. pub slice: Option>, /// The number of solutions to return, maximum 500. diff --git a/gen/replicapool1_beta2-cli/Cargo.toml b/gen/replicapool1_beta2-cli/Cargo.toml index cdb91a42a0..955b29ef69 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+20150708" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "replicapool1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-replicapool1_beta2/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-replicapool1_beta2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-replicapool1_beta2] diff --git a/gen/replicapool1_beta2-cli/README.md b/gen/replicapool1_beta2-cli/README.md index df3956892e..4cd04829b0 100644 --- a/gen/replicapool1_beta2-cli/README.md +++ b/gen/replicapool1_beta2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *replicapool* API at revision *20150708*. The CLI is at version *0.3.6*. +This documentation was generated from the *replicapool* API at revision *20160512*. The CLI is at version *0.3.6*. ```bash replicapool1-beta2 [options] diff --git a/gen/replicapool1_beta2-cli/mkdocs.yml b/gen/replicapool1_beta2-cli/mkdocs.yml index 8132799775..5c3e070331 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+20150708 +site_name: replicapool v0.3.6+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 e7e9dea7af..4da7d26d4b 100644 --- a/gen/replicapool1_beta2-cli/src/main.rs +++ b/gen/replicapool1_beta2-cli/src/main.rs @@ -1489,8 +1489,8 @@ fn main() { let mut app = App::new("replicapool1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20150708") - .about("The Google Compute Engine Instance Group Manager API provides groups of homogenous Compute Engine Instances.") + .version("0.3.6+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") .long("scope") diff --git a/gen/replicapool1_beta2/Cargo.toml b/gen/replicapool1_beta2/Cargo.toml index a3f3d4fb45..a881bdd227 100644 --- a/gen/replicapool1_beta2/Cargo.toml +++ b/gen/replicapool1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-replicapool1_beta2" -version = "0.1.14+20150708" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/replicapool1_beta2/README.md b/gen/replicapool1_beta2/README.md index 8a41d18259..0d9a82f700 100644 --- a/gen/replicapool1_beta2/README.md +++ b/gen/replicapool1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-replicapool1_beta2` library allows access to all features of the *Google replicapool* service. -This documentation was generated from *replicapool* crate version *0.1.14+20150708*, where *20150708* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *replicapool* crate version *0.1.14+20160512*, where *20160512* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *replicapool* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/compute/docs/instance-groups/manager/v1beta2). diff --git a/gen/replicapool1_beta2/src/lib.rs b/gen/replicapool1_beta2/src/lib.rs index d1eb63183e..82f31d099f 100644 --- a/gen/replicapool1_beta2/src/lib.rs +++ b/gen/replicapool1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *replicapool* crate version *0.1.14+20150708*, where *20150708* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *replicapool* crate version *0.1.14+20160512*, where *20160512* is the exact revision of the *replicapool:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *replicapool* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/compute/docs/instance-groups/manager/v1beta2). diff --git a/gen/replicapoolupdater1_beta1-cli/Cargo.toml b/gen/replicapoolupdater1_beta1-cli/Cargo.toml index 01972855ca..3f230aecf2 100644 --- a/gen/replicapoolupdater1_beta1-cli/Cargo.toml +++ b/gen/replicapoolupdater1_beta1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "replicapoolupdater1-beta1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-replicapoolupdater1_beta1 with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-replicapoolupdater1_beta1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-replicapoolupdater1_beta1] diff --git a/gen/replicapoolupdater1_beta1/Cargo.toml b/gen/replicapoolupdater1_beta1/Cargo.toml index 91edcf0973..5313ce46ca 100644 --- a/gen/replicapoolupdater1_beta1/Cargo.toml +++ b/gen/replicapoolupdater1_beta1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/reseller1_sandbox-cli/Cargo.toml b/gen/reseller1_sandbox-cli/Cargo.toml index 73f174e0e4..4c1e7fa994 100644 --- a/gen/reseller1_sandbox-cli/Cargo.toml +++ b/gen/reseller1_sandbox-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "reseller1-sandbox" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-reseller1_sandbox] diff --git a/gen/reseller1_sandbox/Cargo.toml b/gen/reseller1_sandbox/Cargo.toml index 8a459f904b..c1310cc0ac 100644 --- a/gen/reseller1_sandbox/Cargo.toml +++ b/gen/reseller1_sandbox/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/resourceviews1_beta2-cli/Cargo.toml b/gen/resourceviews1_beta2-cli/Cargo.toml index 9f8eb07100..adc93391c5 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+20150708" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "resourceviews1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-resourceviews1_beta2/nigh with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-resourceviews1_beta2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-resourceviews1_beta2] diff --git a/gen/resourceviews1_beta2-cli/README.md b/gen/resourceviews1_beta2-cli/README.md index 5e00f16dd1..2953cc98b6 100644 --- a/gen/resourceviews1_beta2-cli/README.md +++ b/gen/resourceviews1_beta2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *resourceviews* API at revision *20150708*. The CLI is at version *0.3.6*. +This documentation was generated from the *resourceviews* API at revision *20160512*. The CLI is at version *0.3.6*. ```bash resourceviews1-beta2 [options] diff --git a/gen/resourceviews1_beta2-cli/mkdocs.yml b/gen/resourceviews1_beta2-cli/mkdocs.yml index 88daf1386e..af8b721347 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+20150708 +site_name: resourceviews v0.3.6+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 3be9f3f3b9..a34b2b1a03 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+20150708") + .version("0.3.6+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/resourceviews1_beta2/Cargo.toml b/gen/resourceviews1_beta2/Cargo.toml index 83382e0681..a3b8fe2c6f 100644 --- a/gen/resourceviews1_beta2/Cargo.toml +++ b/gen/resourceviews1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-resourceviews1_beta2" -version = "0.1.14+20150708" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/resourceviews1_beta2/README.md b/gen/resourceviews1_beta2/README.md index 7b22d28a5c..1cb2d3fd7b 100644 --- a/gen/resourceviews1_beta2/README.md +++ b/gen/resourceviews1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-resourceviews1_beta2` library allows access to all features of the *Google resourceviews* service. -This documentation was generated from *resourceviews* crate version *0.1.14+20150708*, where *20150708* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *resourceviews* crate version *0.1.14+20160512*, where *20160512* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *resourceviews* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/compute/). diff --git a/gen/resourceviews1_beta2/src/lib.rs b/gen/resourceviews1_beta2/src/lib.rs index eda5fc2397..a916e30e2b 100644 --- a/gen/resourceviews1_beta2/src/lib.rs +++ b/gen/resourceviews1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *resourceviews* crate version *0.1.14+20150708*, where *20150708* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *resourceviews* crate version *0.1.14+20160512*, where *20160512* is the exact revision of the *resourceviews:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *resourceviews* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/compute/). diff --git a/gen/safebrowsing4-cli/Cargo.toml b/gen/safebrowsing4-cli/Cargo.toml new file mode 100644 index 0000000000..f13bf6b071 --- /dev/null +++ b/gen/safebrowsing4-cli/Cargo.toml @@ -0,0 +1,42 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-safebrowsing4-cli" +version = "0.3.6+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" +homepage = "https://developers.google.com/safe-browsing/" +documentation = "http://byron.github.io/google-apis-rs/google_safebrowsing4_cli" +license = "MIT" +keywords = ["safebrowsing", "google", "cli"] + +[[bin]] +name = "safebrowsing4" + +[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.4" +yup-hyper-mock = "^1.0" +clap = "^2.0" + +[features] +default = ["with-serde-codegen"] +nightly = ["serde_macros","yup-oauth2/nightly","google-safebrowsing4/nightly"] +with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-safebrowsing4/with-serde-codegen"] + +[build-dependencies] +serde_codegen = { version = "^ 0.8", optional = true } + + +[dependencies.google-safebrowsing4] +path = "../safebrowsing4" +optional = true +default-features = false diff --git a/gen/safebrowsing4-cli/LICENSE.md b/gen/safebrowsing4-cli/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/safebrowsing4-cli/LICENSE.md @@ -0,0 +1,30 @@ + +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/safebrowsing4-cli/README.md b/gen/safebrowsing4-cli/README.md new file mode 100644 index 0000000000..1439d271de --- /dev/null +++ b/gen/safebrowsing4-cli/README.md @@ -0,0 +1,115 @@ + +The `safebrowsing4` command-line interface *(CLI)* allows to use most features of the *Google safebrowsing* 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 *safebrowsing* API can be found at the +[official documentation site](https://developers.google.com/safe-browsing/). + +# 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/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) + +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*. + +```bash +safebrowsing4 [options] + full-hashes + find (-r )... [-p ]... [-o ] + threat-list-updates + fetch (-r )... [-p ]... [-o ] + threat-lists + list [-p ]... [-o ] + threat-matches + find (-r )... [-p ]... [-o ] + safebrowsing4 --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 `safebrowsing4-`. 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/safebrowsing4-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/safebrowsing4-secret.json`, assuming that the required *safebrowsing* 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. `safebrowsing4 --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/safebrowsing4-cli/mkdocs.yml b/gen/safebrowsing4-cli/mkdocs.yml new file mode 100644 index 0000000000..55435da6b5 --- /dev/null +++ b/gen/safebrowsing4-cli/mkdocs.yml @@ -0,0 +1,20 @@ +site_name: safebrowsing v0.3.6+20160520 +site_url: http://byron.github.io/google-apis-rs/google-safebrowsing4-cli +site_description: Write integrating applications with bcore + +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/safebrowsing4-cli + +docs_dir: docs +site_dir: build_html + +pages: +- ['index.md', 'Home'] +- ['full-hashes_find.md', 'Full Hashes', 'Find'] +- ['threat-list-updates_fetch.md', 'Threat List Updates', 'Fetch'] +- ['threat-lists_list.md', 'Threat Lists', 'List'] +- ['threat-matches_find.md', 'Threat Matches', 'Find'] + +theme: readthedocs + +copyright: Copyright © 2015-2016, `Sebastian Thiel` + diff --git a/gen/safebrowsing4-cli/src/cmn.rs b/gen/safebrowsing4-cli/src/cmn.rs new file mode 100644 index 0000000000..779c1dc086 --- /dev/null +++ b/gen/safebrowsing4-cli/src/cmn.rs @@ -0,0 +1,721 @@ +// 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/safebrowsing4-cli/src/main.rs b/gen/safebrowsing4-cli/src/main.rs new file mode 100644 index 0000000000..34bc39e3a4 --- /dev/null +++ b/gen/safebrowsing4-cli/src/main.rs @@ -0,0 +1,674 @@ +// 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_safebrowsing4 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::Safebrowsing>, + gp: Vec<&'static str>, + gpm: Vec<(&'static str, &'static str)>, +} + + +impl<'n> Engine<'n> { + fn _full_hashes_find(&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()[..] { + "client.client-version" => Some(("client.clientVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "client.client-id" => Some(("client.clientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "threat-info.threat-types" => Some(("threatInfo.threatTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "threat-info.platform-types" => Some(("threatInfo.platformTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "threat-info.threat-entry-types" => Some(("threatInfo.threatEntryTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "client-states" => Some(("clientStates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["client", "client-id", "client-states", "client-version", "platform-types", "threat-entry-types", "threat-info", "threat-types"]); + 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::FindFullHashesRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.full_hashes().find(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); + 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 _threat_list_updates_fetch(&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()[..] { + "client.client-version" => Some(("client.clientVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "client.client-id" => Some(("client.clientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["client", "client-id", "client-version"]); + 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::FetchThreatListUpdatesRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.threat_list_updates().fetch(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); + 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 _threat_lists_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) + -> Result<(), DoitError> { + let mut call = self.hub.threat_lists().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 { + _ => { + 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 _threat_matches_find(&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()[..] { + "client.client-version" => Some(("client.clientVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "client.client-id" => Some(("client.clientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "threat-info.threat-types" => Some(("threatInfo.threatTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "threat-info.platform-types" => Some(("threatInfo.platformTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + "threat-info.threat-entry-types" => Some(("threatInfo.threatEntryTypes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["client", "client-id", "client-version", "platform-types", "threat-entry-types", "threat-info", "threat-types"]); + 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::FindThreatMatchesRequest = json::value::from_value(object).unwrap(); + let mut call = self.hub.threat_matches().find(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); + 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() { + ("full-hashes", Some(opt)) => { + match opt.subcommand() { + ("find", Some(opt)) => { + call_result = self._full_hashes_find(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("full-hashes".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("threat-list-updates", Some(opt)) => { + match opt.subcommand() { + ("fetch", Some(opt)) => { + call_result = self._threat_list_updates_fetch(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("threat-list-updates".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("threat-lists", Some(opt)) => { + match opt.subcommand() { + ("list", Some(opt)) => { + call_result = self._threat_lists_list(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("threat-lists".to_string())); + writeln!(io::stderr(), "{}\n", opt.usage()).ok(); + } + } + }, + ("threat-matches", Some(opt)) => { + match opt.subcommand() { + ("find", Some(opt)) => { + call_result = self._threat_matches_find(opt, dry_run, &mut err); + }, + _ => { + err.issues.push(CLIError::MissingMethodError("threat-matches".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, "safebrowsing4-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: "safebrowsing4", + 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::Safebrowsing::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 = [ + ("full-hashes", "methods: 'find'", vec![ + ("find", + Some(r##"Finds the full hashes that match the requested hash prefixes."##), + "Details at http://byron.github.io/google-apis-rs/google_safebrowsing4_cli/full-hashes_find", + 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)), + ]), + ]), + + ("threat-list-updates", "methods: 'fetch'", vec![ + ("fetch", + Some(r##"Fetches the most recent threat list updates. A client can request updates for multiple lists at once."##), + "Details at http://byron.github.io/google-apis-rs/google_safebrowsing4_cli/threat-list-updates_fetch", + 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)), + ]), + ]), + + ("threat-lists", "methods: 'list'", vec![ + ("list", + Some(r##"Lists the Safe Browsing threat lists available for download."##), + "Details at http://byron.github.io/google-apis-rs/google_safebrowsing4_cli/threat-lists_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)), + ]), + ]), + + ("threat-matches", "methods: 'find'", vec![ + ("find", + Some(r##"Finds the threat entries that match the Safe Browsing lists."##), + "Details at http://byron.github.io/google-apis-rs/google_safebrowsing4_cli/threat-matches_find", + 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)), + ]), + ]), + + ]; + + let mut app = App::new("safebrowsing4") + .author("Sebastian Thiel ") + .version("0.3.6+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") + .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/safebrowsing4/Cargo.toml b/gen/safebrowsing4/Cargo.toml new file mode 100644 index 0000000000..933b6ac6ce --- /dev/null +++ b/gen/safebrowsing4/Cargo.toml @@ -0,0 +1,34 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-safebrowsing4" +version = "0.1.14+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" +homepage = "https://developers.google.com/safe-browsing/" +documentation = "http://byron.github.io/google-apis-rs/google_safebrowsing4" +license = "MIT" +keywords = ["safebrowsing", "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/safebrowsing4/LICENSE.md b/gen/safebrowsing4/LICENSE.md new file mode 100644 index 0000000000..ff523b4547 --- /dev/null +++ b/gen/safebrowsing4/LICENSE.md @@ -0,0 +1,30 @@ + +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/safebrowsing4/README.md b/gen/safebrowsing4/README.md new file mode 100644 index 0000000000..7a26b6748e --- /dev/null +++ b/gen/safebrowsing4/README.md @@ -0,0 +1,185 @@ + +The `google-safebrowsing4` library allows access to all features of the *Google safebrowsing* service. + +This documentation was generated from *safebrowsing* crate version *0.1.14+20160520*, where *20160520* is the exact revision of the *safebrowsing:v4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. + +Everything else about the *safebrowsing* *v4* API can be found at the +[official documentation site](https://developers.google.com/safe-browsing/). +# Features + +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.Safebrowsing.html) ... + +* full hashes + * [*find*](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.FullHasheFindCall.html) +* threat list updates + * [*fetch*](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.ThreatListUpdateFetchCall.html) +* threat lists + * [*list*](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.ThreatListListCall.html) +* threat matches + * [*find*](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.ThreatMatcheFindCall.html) + + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](http://byron.github.io/google-apis-rs/google_safebrowsing4/struct.Safebrowsing.html)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_safebrowsing4/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_safebrowsing4/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_safebrowsing4/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_safebrowsing4/trait.Part.html)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](http://byron.github.io/google-apis-rs/google_safebrowsing4/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.full_hashes().find(...).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-safebrowsing4 = "*" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate yup_oauth2 as oauth2; +extern crate google_safebrowsing4 as safebrowsing4; +use safebrowsing4::FindFullHashesRequest; +use safebrowsing4::{Result, Error}; +use std::default::Default; +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +use safebrowsing4::Safebrowsing; + +// 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 = Safebrowsing::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 = FindFullHashesRequest::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.full_hashes().find(req) + .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_safebrowsing4/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_safebrowsing4/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_safebrowsing4/../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_safebrowsing4/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_safebrowsing4/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_safebrowsing4/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_safebrowsing4/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_safebrowsing4/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_safebrowsing4/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_safebrowsing4/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_safebrowsing4/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_safebrowsing4/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_safebrowsing4/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 **safebrowsing4** 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/safebrowsing4/src/build.rs b/gen/safebrowsing4/src/build.rs new file mode 100644 index 0000000000..0bebaf0bf0 --- /dev/null +++ b/gen/safebrowsing4/src/build.rs @@ -0,0 +1,25 @@ +#[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/safebrowsing4/src/cmn.rs b/gen/safebrowsing4/src/cmn.rs new file mode 100644 index 0000000000..d75063e466 --- /dev/null +++ b/gen/safebrowsing4/src/cmn.rs @@ -0,0 +1,753 @@ +// 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/safebrowsing4/src/lib.rs b/gen/safebrowsing4/src/lib.rs new file mode 100644 index 0000000000..97f0001da0 --- /dev/null +++ b/gen/safebrowsing4/src/lib.rs @@ -0,0 +1,195 @@ +// DO NOT EDIT ! +// This file was generated automatically from 'src/mako/api/lib.rs.mako' +// DO NOT EDIT ! + +//! This documentation was generated from *safebrowsing* crate version *0.1.14+20160520*, where *20160520* is the exact revision of the *safebrowsing:v4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! +//! Everything else about the *safebrowsing* *v4* API can be found at the +//! [official documentation site](https://developers.google.com/safe-browsing/). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/safebrowsing4). +//! # Features +//! +//! Handle the following *Resources* with ease from the central [hub](struct.Safebrowsing.html) ... +//! +//! * full hashes +//! * [*find*](struct.FullHasheFindCall.html) +//! * threat list updates +//! * [*fetch*](struct.ThreatListUpdateFetchCall.html) +//! * threat lists +//! * [*list*](struct.ThreatListListCall.html) +//! * threat matches +//! * [*find*](struct.ThreatMatcheFindCall.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.Safebrowsing.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.full_hashes().find(...).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-safebrowsing4 = "*" +//! ``` +//! +//! ## A complete example +//! +//! ```test_harness,no_run +//! extern crate hyper; +//! extern crate yup_oauth2 as oauth2; +//! extern crate google_safebrowsing4 as safebrowsing4; +//! use safebrowsing4::FindFullHashesRequest; +//! use safebrowsing4::{Result, Error}; +//! # #[test] fn egal() { +//! use std::default::Default; +//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +//! use safebrowsing4::Safebrowsing; +//! +//! // 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 = Safebrowsing::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 = FindFullHashesRequest::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.full_hashes().find(req) +//! .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/safebrowsing4/src/lib.rs.in b/gen/safebrowsing4/src/lib.rs.in new file mode 100644 index 0000000000..a163a0b10b --- /dev/null +++ b/gen/safebrowsing4/src/lib.rs.in @@ -0,0 +1,1668 @@ +// 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 Safebrowsing related resource activities +/// +/// # Examples +/// +/// Instantiate a new hub +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_safebrowsing4 as safebrowsing4; +/// use safebrowsing4::FindFullHashesRequest; +/// use safebrowsing4::{Result, Error}; +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use safebrowsing4::Safebrowsing; +/// +/// // 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 = Safebrowsing::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 = FindFullHashesRequest::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.full_hashes().find(req) +/// .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 Safebrowsing { + client: RefCell, + auth: RefCell, + _user_agent: String, +} + +impl<'a, C, A> Hub for Safebrowsing {} + +impl<'a, C, A> Safebrowsing + where C: BorrowMut, A: oauth2::GetToken { + + pub fn new(client: C, authenticator: A) -> Safebrowsing { + Safebrowsing { + client: RefCell::new(client), + auth: RefCell::new(authenticator), + _user_agent: "google-api-rust-client/0.1.14".to_string(), + } + } + + pub fn full_hashes(&'a self) -> FullHasheMethods<'a, C, A> { + FullHasheMethods { hub: &self } + } + pub fn threat_list_updates(&'a self) -> ThreatListUpdateMethods<'a, C, A> { + ThreatListUpdateMethods { hub: &self } + } + pub fn threat_lists(&'a self) -> ThreatListMethods<'a, C, A> { + ThreatListMethods { hub: &self } + } + pub fn threat_matches(&'a self) -> ThreatMatcheMethods<'a, C, A> { + ThreatMatcheMethods { 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 ### +// ########## +/// A single list update request. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListUpdateRequest { + /// The type of platform at risk by entries present in the list. + #[serde(rename="platformType")] + pub platform_type: Option, + /// The current state of the client for the requested list (the encrypted client state that was received from the last successful list update). + pub state: Option, + /// The types of entries present in the list. + #[serde(rename="threatEntryType")] + pub threat_entry_type: Option, + /// The type of threat posed by entries present in the list. + #[serde(rename="threatType")] + pub threat_type: Option, + /// The constraints associated with this request. + pub constraints: Option, +} + +impl Part for ListUpdateRequest {} + + +/// An update to an individual list. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListUpdateResponse { + /// The type of response. This may indicate that an action is required by the client when the response is received. + #[serde(rename="responseType")] + pub response_type: Option, + /// The threat type for which data is returned. + #[serde(rename="threatType")] + pub threat_type: Option, + /// A set of entries to remove from a local threat type's list. Repeated for the same reason as above. + pub removals: Option>, + /// The new client state, in encrypted format. Opaque to clients. + #[serde(rename="newClientState")] + pub new_client_state: Option, + /// The expected SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database after applying the provided update. If the client state doesn't match the expected state, the client must disregard this update and retry later. + pub checksum: Option, + /// The format of the threats. + #[serde(rename="threatEntryType")] + pub threat_entry_type: Option, + /// A set of entries to add to a local threat type's list. Repeated to allow for a combination of compressed and raw data to be sent in a single response. + pub additions: Option>, + /// The platform type for which data is returned. + #[serde(rename="platformType")] + pub platform_type: Option, +} + +impl Part for ListUpdateResponse {} + + +/// The metadata associated with a specific threat entry. The client is expected to know the metadata key/value pairs associated with each threat type. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatEntryMetadata { + /// The metadata entries. + pub entries: Option>, +} + +impl Part for ThreatEntryMetadata {} + + +/// The expected state of a client's local database. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Checksum { + /// The SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database. + pub sha256: Option, +} + +impl Part for Checksum {} + + +/// Request to check entries against lists. +/// +/// # 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*). +/// +/// * [find threat matches](struct.ThreatMatcheFindCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FindThreatMatchesRequest { + /// The client metadata. + pub client: Option, + /// The lists and entries to be checked for matches. + #[serde(rename="threatInfo")] + pub threat_info: Option, +} + +impl RequestValue for FindThreatMatchesRequest {} + + +/// A set of threats that should be added or removed from a client's local database. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatEntrySet { + /// The compression type for the entries in this set. + #[serde(rename="compressionType")] + pub compression_type: Option, + /// The raw removal indices for a local list. + #[serde(rename="rawIndices")] + pub raw_indices: Option, + /// The raw SHA256-formatted entries. + #[serde(rename="rawHashes")] + pub raw_hashes: Option, + /// The encoded 4-byte prefixes of SHA256-formatted entries, using a Golomb-Rice encoding. + #[serde(rename="riceHashes")] + pub rice_hashes: Option, + /// The encoded local, lexicographically-sorted list indices, using a Golomb-Rice encoding. Used for sending compressed removal indices. + #[serde(rename="riceIndices")] + pub rice_indices: Option, +} + +impl Part for ThreatEntrySet {} + + +/// The Rice-Golomb encoded data. Used for sending compressed 4-byte hashes or compressed removal indices. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RiceDeltaEncoding { + /// The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`. + #[serde(rename="numEntries")] + pub num_entries: Option, + /// The offset of the first entry in the encoded data, or, if only a single integer was encoded, that single integer's value. + #[serde(rename="firstValue")] + pub first_value: Option, + /// The Golomb-Rice parameter, which is a number between 2 and 28. This field is missing (that is, zero) if `num_entries` is zero. + #[serde(rename="riceParameter")] + pub rice_parameter: Option, + /// The encoded deltas that are encoded using the Golomb-Rice coder. + #[serde(rename="encodedData")] + pub encoded_data: Option, +} + +impl Part for RiceDeltaEncoding {} + + +/// The information regarding one or more threats that a client submits when checking for matches in threat lists. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatInfo { + /// The threat types to be checked. + #[serde(rename="threatTypes")] + pub threat_types: Option>, + /// The entry types to be checked. + #[serde(rename="threatEntryTypes")] + pub threat_entry_types: Option>, + /// The threat entries to be checked. + #[serde(rename="threatEntries")] + pub threat_entries: Option>, + /// The platform types to be checked. + #[serde(rename="platformTypes")] + pub platform_types: Option>, +} + +impl Part for ThreatInfo {} + + +/// The constraints for this update. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Constraints { + /// Sets the maximum number of entries that the client is willing to have in the local database. This should be a power of 2 between 2**10 and 2**20. If zero, no database size limit is set. + #[serde(rename="maxDatabaseEntries")] + pub max_database_entries: Option, + /// Requests the list for a specific geographic location. If not set the server may pick that value based on the user's IP address. Expects ISO 3166-1 alpha-2 format. + pub region: Option, + /// The compression types supported by the client. + #[serde(rename="supportedCompressions")] + pub supported_compressions: Option>, + /// The maximum size in number of entries. The update will not contain more entries than this value. This should be a power of 2 between 2**10 and 2**20. If zero, no update size limit is set. + #[serde(rename="maxUpdateEntries")] + pub max_update_entries: Option, +} + +impl Part for Constraints {} + + +/// A match when checking a threat entry in the Safe Browsing threat lists. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatMatch { + /// The threat type matching this threat. + #[serde(rename="threatType")] + pub threat_type: Option, + /// The threat matching this threat. + pub threat: Option, + /// Optional metadata associated with this threat. + #[serde(rename="threatEntryMetadata")] + pub threat_entry_metadata: Option, + /// The threat entry type matching this threat. + #[serde(rename="threatEntryType")] + pub threat_entry_type: Option, + /// The platform type matching this threat. + #[serde(rename="platformType")] + pub platform_type: Option, + /// The cache lifetime for the returned match. Clients must not cache this response for more than this duration to avoid false positives. + #[serde(rename="cacheDuration")] + pub cache_duration: Option, +} + +impl Part for ThreatMatch {} + + +/// The client metadata associated with Safe Browsing API requests. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClientInfo { + /// A client ID that (hopefully) uniquely identifies the client implementation of the Safe Browsing API. + #[serde(rename="clientId")] + pub client_id: Option, + /// The version of the client implementation. + #[serde(rename="clientVersion")] + pub client_version: Option, +} + +impl Part for ClientInfo {} + + +/// 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*). +/// +/// * [find threat matches](struct.ThreatMatcheFindCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FindThreatMatchesResponse { + /// The threat list matches. + pub matches: Option>, +} + +impl ResponseResult for FindThreatMatchesResponse {} + + +/// Describes an individual threat list. A list is defined by three parameters: the type of threat posed, the type of platform targeted by the threat, and the type of entries in the list. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatListDescriptor { + /// The threat type posed by the list's entries. + #[serde(rename="threatType")] + pub threat_type: Option, + /// The entry types contained in the list. + #[serde(rename="threatEntryType")] + pub threat_entry_type: Option, + /// The platform type targeted by the list's entries. + #[serde(rename="platformType")] + pub platform_type: Option, +} + +impl Part for ThreatListDescriptor {} + + +/// 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*). +/// +/// * [find full hashes](struct.FullHasheFindCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FindFullHashesResponse { + /// The full hashes that matched the requested prefixes. + pub matches: Option>, + /// For requested entities that did not match the threat list, how long to cache the response. + #[serde(rename="negativeCacheDuration")] + pub negative_cache_duration: Option, + /// The minimum duration the client must wait before issuing any find hashes request. If this field is not set, clients can issue a request as soon as they want. + #[serde(rename="minimumWaitDuration")] + pub minimum_wait_duration: Option, +} + +impl ResponseResult for FindFullHashesResponse {} + + +/// An individual threat; for example, a malicious URL or its hash representation. Only one of these fields should be set. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ThreatEntry { + /// A URL. + pub url: Option, + /// A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 hash. This field is in binary format. + pub hash: Option, + /// The digest of an executable in SHA256 format. The API supports both binary and hex digests. + pub digest: Option, +} + +impl Part for ThreatEntry {} + + +/// A single metadata 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 MetadataEntry { + /// The metadata entry key. + pub key: Option, + /// The metadata entry value. + pub value: Option, +} + +impl Part for MetadataEntry {} + + +/// 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*). +/// +/// * [fetch threat list updates](struct.ThreatListUpdateFetchCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FetchThreatListUpdatesResponse { + /// The list updates requested by the clients. + #[serde(rename="listUpdateResponses")] + pub list_update_responses: Option>, + /// The minimum duration the client must wait before issuing any update request. If this field is not set clients may update as soon as they want. + #[serde(rename="minimumWaitDuration")] + pub minimum_wait_duration: Option, +} + +impl ResponseResult for FetchThreatListUpdatesResponse {} + + +/// 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 threat lists](struct.ThreatListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListThreatListsResponse { + /// The lists available for download by the client. + #[serde(rename="threatLists")] + pub threat_lists: Option>, +} + +impl ResponseResult for ListThreatListsResponse {} + + +/// A set of raw indices to remove from a local list. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RawIndices { + /// The indices to remove from a lexicographically-sorted local list. + pub indices: Option>, +} + +impl Part for RawIndices {} + + +/// Describes a Safe Browsing API update request. Clients can request updates for multiple lists in a single request. NOTE: Field index 2 is unused. NEXT: 4 +/// +/// # 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*). +/// +/// * [fetch threat list updates](struct.ThreatListUpdateFetchCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FetchThreatListUpdatesRequest { + /// The client metadata. + pub client: Option, + /// The requested threat list updates. + #[serde(rename="listUpdateRequests")] + pub list_update_requests: Option>, +} + +impl RequestValue for FetchThreatListUpdatesRequest {} + + +/// The uncompressed threat entries in hash format of a particular prefix length. Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 bytes, but some hashes are lengthened if they collide with the hash of a popular URL. Used for sending ThreatEntrySet to clients that do not support compression, or when sending non-4-byte hashes to clients that do support compression. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RawHashes { + /// The number of bytes for each prefix encoded below. This field can be anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). + #[serde(rename="prefixSize")] + pub prefix_size: Option, + /// The hashes, all concatenated into one long string. Each hash has a prefix size of |prefix_size| above. Hashes are sorted in lexicographic order. + #[serde(rename="rawHashes")] + pub raw_hashes: Option, +} + +impl Part for RawHashes {} + + +/// Request to return full hashes matched by the provided hash prefixes. +/// +/// # 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*). +/// +/// * [find full hashes](struct.FullHasheFindCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FindFullHashesRequest { + /// The client metadata. + pub client: Option, + /// The lists and hashes to be checked. + #[serde(rename="threatInfo")] + pub threat_info: Option, + /// The current client states for each of the client's local threat lists. + #[serde(rename="clientStates")] + pub client_states: Option>, +} + +impl RequestValue for FindFullHashesRequest {} + + + +// ################### +// MethodBuilders ### +// ################# + +/// A builder providing access to all methods supported on *threatList* resources. +/// It is not used directly, but through the `Safebrowsing` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_safebrowsing4 as safebrowsing4; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use safebrowsing4::Safebrowsing; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Safebrowsing::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.threat_lists(); +/// # } +/// ``` +pub struct ThreatListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, +} + +impl<'a, C, A> MethodsBuilder for ThreatListMethods<'a, C, A> {} + +impl<'a, C, A> ThreatListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Lists the Safe Browsing threat lists available for download. + pub fn list(&self) -> ThreatListListCall<'a, C, A> { + ThreatListListCall { + hub: self.hub, + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *threatMatche* resources. +/// It is not used directly, but through the `Safebrowsing` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_safebrowsing4 as safebrowsing4; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use safebrowsing4::Safebrowsing; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Safebrowsing::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `find(...)` +/// // to build up your call. +/// let rb = hub.threat_matches(); +/// # } +/// ``` +pub struct ThreatMatcheMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, +} + +impl<'a, C, A> MethodsBuilder for ThreatMatcheMethods<'a, C, A> {} + +impl<'a, C, A> ThreatMatcheMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Finds the threat entries that match the Safe Browsing lists. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn find(&self, request: FindThreatMatchesRequest) -> ThreatMatcheFindCall<'a, C, A> { + ThreatMatcheFindCall { + hub: self.hub, + _request: request, + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *threatListUpdate* resources. +/// It is not used directly, but through the `Safebrowsing` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_safebrowsing4 as safebrowsing4; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use safebrowsing4::Safebrowsing; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Safebrowsing::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `fetch(...)` +/// // to build up your call. +/// let rb = hub.threat_list_updates(); +/// # } +/// ``` +pub struct ThreatListUpdateMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, +} + +impl<'a, C, A> MethodsBuilder for ThreatListUpdateMethods<'a, C, A> {} + +impl<'a, C, A> ThreatListUpdateMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Fetches the most recent threat list updates. A client can request updates for multiple lists at once. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn fetch(&self, request: FetchThreatListUpdatesRequest) -> ThreatListUpdateFetchCall<'a, C, A> { + ThreatListUpdateFetchCall { + hub: self.hub, + _request: request, + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *fullHashe* resources. +/// It is not used directly, but through the `Safebrowsing` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_safebrowsing4 as safebrowsing4; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use safebrowsing4::Safebrowsing; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// ::default(), None); +/// let mut hub = Safebrowsing::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `find(...)` +/// // to build up your call. +/// let rb = hub.full_hashes(); +/// # } +/// ``` +pub struct FullHasheMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, +} + +impl<'a, C, A> MethodsBuilder for FullHasheMethods<'a, C, A> {} + +impl<'a, C, A> FullHasheMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Finds the full hashes that match the requested hash prefixes. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn find(&self, request: FindFullHashesRequest) -> FullHasheFindCall<'a, C, A> { + FullHasheFindCall { + hub: self.hub, + _request: request, + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + + + +// ################### +// CallBuilders ### +// ################# + +/// Lists the Safe Browsing threat lists available for download. +/// +/// A builder for the *list* method supported by a *threatList* resource. +/// It is not used directly, but through a `ThreatListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_safebrowsing4 as safebrowsing4; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use safebrowsing4::Safebrowsing; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Safebrowsing::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.threat_lists().list() +/// .doit(); +/// # } +/// ``` +pub struct ThreatListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for ThreatListListCall<'a, C, A> {} + +impl<'a, C, A> ThreatListListCall<'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, ListThreatListsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "safebrowsing.threatLists.list", + 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://safebrowsing.googleapis.com/v4/threatLists".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) -> ThreatListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ThreatListListCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Finds the threat entries that match the Safe Browsing lists. +/// +/// A builder for the *find* method supported by a *threatMatche* resource. +/// It is not used directly, but through a `ThreatMatcheMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_safebrowsing4 as safebrowsing4; +/// use safebrowsing4::FindThreatMatchesRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use safebrowsing4::Safebrowsing; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Safebrowsing::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 = FindThreatMatchesRequest::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.threat_matches().find(req) +/// .doit(); +/// # } +/// ``` +pub struct ThreatMatcheFindCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, + _request: FindThreatMatchesRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for ThreatMatcheFindCall<'a, C, A> {} + +impl<'a, C, A> ThreatMatcheFindCall<'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, FindThreatMatchesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "safebrowsing.threatMatches.find", + 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://safebrowsing.googleapis.com/v4/threatMatches:find".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)); + } + + 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 { + 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(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: FindThreatMatchesRequest) -> ThreatMatcheFindCall<'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) -> ThreatMatcheFindCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ThreatMatcheFindCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Fetches the most recent threat list updates. A client can request updates for multiple lists at once. +/// +/// A builder for the *fetch* method supported by a *threatListUpdate* resource. +/// It is not used directly, but through a `ThreatListUpdateMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_safebrowsing4 as safebrowsing4; +/// use safebrowsing4::FetchThreatListUpdatesRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use safebrowsing4::Safebrowsing; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Safebrowsing::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 = FetchThreatListUpdatesRequest::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.threat_list_updates().fetch(req) +/// .doit(); +/// # } +/// ``` +pub struct ThreatListUpdateFetchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, + _request: FetchThreatListUpdatesRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for ThreatListUpdateFetchCall<'a, C, A> {} + +impl<'a, C, A> ThreatListUpdateFetchCall<'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, FetchThreatListUpdatesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "safebrowsing.threatListUpdates.fetch", + 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://safebrowsing.googleapis.com/v4/threatListUpdates:fetch".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)); + } + + 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 { + 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(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: FetchThreatListUpdatesRequest) -> ThreatListUpdateFetchCall<'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) -> ThreatListUpdateFetchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> ThreatListUpdateFetchCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Finds the full hashes that match the requested hash prefixes. +/// +/// A builder for the *find* method supported by a *fullHashe* resource. +/// It is not used directly, but through a `FullHasheMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_safebrowsing4 as safebrowsing4; +/// use safebrowsing4::FindFullHashesRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use safebrowsing4::Safebrowsing; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = Safebrowsing::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 = FindFullHashesRequest::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.full_hashes().find(req) +/// .doit(); +/// # } +/// ``` +pub struct FullHasheFindCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Safebrowsing, + _request: FindFullHashesRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for FullHasheFindCall<'a, C, A> {} + +impl<'a, C, A> FullHasheFindCall<'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, FindFullHashesResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "safebrowsing.fullHashes.find", + 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://safebrowsing.googleapis.com/v4/fullHashes:find".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)); + } + + 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 { + 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(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: FindFullHashesRequest) -> FullHasheFindCall<'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) -> FullHasheFindCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> FullHasheFindCall<'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/serviceregistryalpha-cli/Cargo.toml b/gen/serviceregistryalpha-cli/Cargo.toml index a45e6a5fa4..2d58405903 100644 --- a/gen/serviceregistryalpha-cli/Cargo.toml +++ b/gen/serviceregistryalpha-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "serviceregistryalpha" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-serviceregistryalpha/nigh with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-serviceregistryalpha/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-serviceregistryalpha] diff --git a/gen/serviceregistryalpha/Cargo.toml b/gen/serviceregistryalpha/Cargo.toml index 18533df924..fda5843e49 100644 --- a/gen/serviceregistryalpha/Cargo.toml +++ b/gen/serviceregistryalpha/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/siteverification1-cli/Cargo.toml b/gen/siteverification1-cli/Cargo.toml index cc26e68d3a..607f0c2c17 100644 --- a/gen/siteverification1-cli/Cargo.toml +++ b/gen/siteverification1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "siteverification1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-siteverification1/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-siteverification1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-siteverification1] diff --git a/gen/siteverification1/Cargo.toml b/gen/siteverification1/Cargo.toml index 5ce6f7b3d5..4ec6b3917a 100644 --- a/gen/siteverification1/Cargo.toml +++ b/gen/siteverification1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/spectrum1_explorer-cli/Cargo.toml b/gen/spectrum1_explorer-cli/Cargo.toml index 80b701a21c..b181278f9f 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+20160206" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "spectrum1-explorer" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-spectrum1_explorer/nightl with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-spectrum1_explorer/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-spectrum1_explorer] diff --git a/gen/spectrum1_explorer-cli/README.md b/gen/spectrum1_explorer-cli/README.md index 0a72bfe21d..8e5ca5c9e3 100644 --- a/gen/spectrum1_explorer-cli/README.md +++ b/gen/spectrum1_explorer-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *spectrum* API at revision *20160206*. The CLI is at version *0.3.6*. +This documentation was generated from the *spectrum* API at revision *20160606*. The CLI is at version *0.3.6*. ```bash spectrum1-explorer [options] diff --git a/gen/spectrum1_explorer-cli/mkdocs.yml b/gen/spectrum1_explorer-cli/mkdocs.yml index 436172cba4..1b0523be3f 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+20160206 +site_name: spectrum v0.3.6+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 8e6aaf9b28..dc10fdccd4 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+20160206") + .version("0.3.6+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/spectrum1_explorer/Cargo.toml b/gen/spectrum1_explorer/Cargo.toml index ea889d4e44..a6bee5d6b5 100644 --- a/gen/spectrum1_explorer/Cargo.toml +++ b/gen/spectrum1_explorer/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-spectrum1_explorer" -version = "0.1.14+20160206" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/spectrum1_explorer/README.md b/gen/spectrum1_explorer/README.md index 3fc09546ea..250287e208 100644 --- a/gen/spectrum1_explorer/README.md +++ b/gen/spectrum1_explorer/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-spectrum1_explorer` library allows access to all features of the *Google spectrum* service. -This documentation was generated from *spectrum* crate version *0.1.14+20160206*, where *20160206* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *spectrum* crate version *0.1.14+20160606*, where *20160606* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *spectrum* *v1_explorer* API can be found at the [official documentation site](http://developers.google.com/spectrum). diff --git a/gen/spectrum1_explorer/src/lib.rs b/gen/spectrum1_explorer/src/lib.rs index 8325c5c1a6..d60bba9a08 100644 --- a/gen/spectrum1_explorer/src/lib.rs +++ b/gen/spectrum1_explorer/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *spectrum* crate version *0.1.14+20160206*, where *20160206* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *spectrum* crate version *0.1.14+20160606*, where *20160606* is the exact revision of the *spectrum:v1explorer* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *spectrum* *v1_explorer* API can be found at the //! [official documentation site](http://developers.google.com/spectrum). diff --git a/gen/sqladmin1_beta4-cli/Cargo.toml b/gen/sqladmin1_beta4-cli/Cargo.toml index e4dffe08e2..70a68632a8 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+20160321" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "sqladmin1-beta4" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-sqladmin1_beta4] diff --git a/gen/sqladmin1_beta4-cli/README.md b/gen/sqladmin1_beta4-cli/README.md index dde8c68987..caee45d482 100644 --- a/gen/sqladmin1_beta4-cli/README.md +++ b/gen/sqladmin1_beta4-cli/README.md @@ -24,13 +24,14 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *SQL Admin* API at revision *20160321*. 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 *0.3.6*. ```bash sqladmin1-beta4 [options] backup-runs delete [-p ]... [-o ] get [-p ]... [-o ] + insert (-r )... [-p ]... [-o ] list [-p ]... [-o ] databases delete [-p ]... [-o ] diff --git a/gen/sqladmin1_beta4-cli/mkdocs.yml b/gen/sqladmin1_beta4-cli/mkdocs.yml index 15bcf498e6..5aae687d1e 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+20160321 +site_name: SQL Admin v0.3.6+20160907 site_url: http://byron.github.io/google-apis-rs/google-sqladmin1_beta4-cli site_description: Write integrating applications with bcore @@ -11,6 +11,7 @@ pages: - ['index.md', 'Home'] - ['backup-runs_delete.md', 'Backup Runs', 'Delete'] - ['backup-runs_get.md', 'Backup Runs', 'Get'] +- ['backup-runs_insert.md', 'Backup Runs', 'Insert'] - ['backup-runs_list.md', 'Backup Runs', 'List'] - ['databases_delete.md', 'Databases', 'Delete'] - ['databases_get.md', 'Databases', 'Get'] diff --git a/gen/sqladmin1_beta4-cli/src/main.rs b/gen/sqladmin1_beta4-cli/src/main.rs index e7cb58229c..5dc89814fa 100644 --- a/gen/sqladmin1_beta4-cli/src/main.rs +++ b/gen/sqladmin1_beta4-cli/src/main.rs @@ -149,6 +149,104 @@ impl<'n> Engine<'n> { } } + fn _backup_runs_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 })), + "window-start-time" => Some(("windowStartTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "enqueued-time" => Some(("enqueuedTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "instance" => Some(("instance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "start-time" => Some(("startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "error.kind" => Some(("error.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "error.code" => Some(("error.code", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "error.message" => Some(("error.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "end-time" => Some(("endTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "type" => Some(("type", 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 })), + _ => { + let suggestion = FieldCursor::did_you_mean(key, &vec!["code", "description", "end-time", "enqueued-time", "error", "id", "instance", "kind", "message", "self-link", "start-time", "status", "type", "window-start-time"]); + 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::BackupRun = json::value::from_value(object).unwrap(); + let mut call = self.hub.backup_runs().insert(request, opt.value_of("project").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 _backup_runs_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.backup_runs().list(opt.value_of("project").unwrap_or(""), opt.value_of("instance").unwrap_or("")); @@ -1223,6 +1321,7 @@ impl<'n> Engine<'n> { "settings.tier" => Some(("settings.tier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.pricing-plan" => Some(("settings.pricingPlan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.settings-version" => Some(("settings.settingsVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.storage-auto-resize" => Some(("settings.storageAutoResize", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "settings.location-preference.kind" => Some(("settings.locationPreference.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.zone" => Some(("settings.locationPreference.zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.follow-gae-application" => Some(("settings.locationPreference.followGaeApplication", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1243,7 +1342,7 @@ impl<'n> Engine<'n> { "replica-configuration.mysql-replica-configuration.client-key" => Some(("replicaConfiguration.mysqlReplicaConfiguration.clientKey", 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!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "storage-auto-resize", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1433,6 +1532,7 @@ impl<'n> Engine<'n> { "settings.tier" => Some(("settings.tier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.pricing-plan" => Some(("settings.pricingPlan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.settings-version" => Some(("settings.settingsVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.storage-auto-resize" => Some(("settings.storageAutoResize", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "settings.location-preference.kind" => Some(("settings.locationPreference.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.zone" => Some(("settings.locationPreference.zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.follow-gae-application" => Some(("settings.locationPreference.followGaeApplication", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1453,7 +1553,7 @@ impl<'n> Engine<'n> { "replica-configuration.mysql-replica-configuration.client-key" => Some(("replicaConfiguration.mysqlReplicaConfiguration.clientKey", 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!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "storage-auto-resize", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -1931,6 +2031,7 @@ impl<'n> Engine<'n> { "settings.tier" => Some(("settings.tier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.pricing-plan" => Some(("settings.pricingPlan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.settings-version" => Some(("settings.settingsVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "settings.storage-auto-resize" => Some(("settings.storageAutoResize", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "settings.location-preference.kind" => Some(("settings.locationPreference.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.zone" => Some(("settings.locationPreference.zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "settings.location-preference.follow-gae-application" => Some(("settings.locationPreference.followGaeApplication", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -1951,7 +2052,7 @@ impl<'n> Engine<'n> { "replica-configuration.mysql-replica-configuration.client-key" => Some(("replicaConfiguration.mysqlReplicaConfiguration.clientKey", 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!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["activation-policy", "authorized-gae-applications", "available", "backend-type", "backup-configuration", "binary-log-enabled", "ca-certificate", "cert", "cert-serial-number", "client-certificate", "client-key", "common-name", "connect-retry-interval", "crash-safe-replication-enabled", "create-time", "current-disk-size", "data-disk-size-gb", "data-disk-type", "database-replication-enabled", "database-version", "day", "dump-file-path", "enabled", "etag", "expiration-time", "failover-replica", "failover-target", "follow-gae-application", "host-port", "hour", "instance", "instance-type", "ip-configuration", "ipv4-enabled", "ipv6-address", "kind", "location-preference", "maintenance-window", "master-heartbeat-period", "master-instance-name", "max-disk-size", "mysql-replica-configuration", "name", "on-premises-configuration", "password", "pricing-plan", "project", "region", "replica-configuration", "replica-names", "replication-type", "require-ssl", "self-link", "server-ca-cert", "service-account-email-address", "settings", "settings-version", "sha1-fingerprint", "ssl-cipher", "start-time", "state", "storage-auto-resize", "suspension-reason", "tier", "update-track", "username", "verify-server-certificate", "zone"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2799,6 +2900,9 @@ impl<'n> Engine<'n> { ("get", Some(opt)) => { call_result = self._backup_runs_get(opt, dry_run, &mut err); }, + ("insert", Some(opt)) => { + call_result = self._backup_runs_insert(opt, dry_run, &mut err); + }, ("list", Some(opt)) => { call_result = self._backup_runs_list(opt, dry_run, &mut err); }, @@ -3051,7 +3155,7 @@ impl<'n> Engine<'n> { fn main() { let mut exit_status = 0i32; let arg_data = [ - ("backup-runs", "methods: 'delete', 'get' and 'list'", vec![ + ("backup-runs", "methods: 'delete', 'get', 'insert' and 'list'", vec![ ("delete", Some(r##"Deletes the backup taken by a backup run."##), "Details at http://byron.github.io/google-apis-rs/google_sqladmin1_beta4_cli/backup-runs_delete", @@ -3114,6 +3218,40 @@ fn main() { 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 new backup run on demand. This method is applicable only to Second Generation instances."##), + "Details at http://byron.github.io/google-apis-rs/google_sqladmin1_beta4_cli/backup-runs_insert", + vec![ + (Some(r##"project"##), + None, + Some(r##"Project ID of the project that contains the instance."##), + Some(true), + Some(false)), + + (Some(r##"instance"##), + None, + Some(r##"Cloud SQL instance ID. This does not include the project ID."##), + 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"##), @@ -4275,7 +4413,7 @@ fn main() { let mut app = App::new("sqladmin1-beta4") .author("Sebastian Thiel ") - .version("0.3.6+20160321") + .version("0.3.6+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/sqladmin1_beta4/Cargo.toml b/gen/sqladmin1_beta4/Cargo.toml index ba3487e623..da7bd4780b 100644 --- a/gen/sqladmin1_beta4/Cargo.toml +++ b/gen/sqladmin1_beta4/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-sqladmin1_beta4" -version = "0.1.14+20160321" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/sqladmin1_beta4/README.md b/gen/sqladmin1_beta4/README.md index cdc6b708b8..6b6c0e2fa0 100644 --- a/gen/sqladmin1_beta4/README.md +++ b/gen/sqladmin1_beta4/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-sqladmin1_beta4` library allows access to all features of the *Google SQL Admin* service. -This documentation was generated from *SQL Admin* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *SQL Admin* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *SQL Admin* *v1_beta4* API can be found at the [official documentation site](https://cloud.google.com/sql/docs/reference/latest). @@ -14,7 +14,7 @@ Everything else about the *SQL Admin* *v1_beta4* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.SQLAdmin.html) ... * [backup runs](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRun.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunListCall.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.BackupRunListCall.html) * [databases](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.Database.html) * [*delete*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabaseDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabaseGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabaseInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabaseListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabasePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.DatabaseUpdateCall.html) * [flags](http://byron.github.io/google-apis-rs/google_sqladmin1_beta4/struct.Flag.html) @@ -82,6 +82,7 @@ let r = hub.instances().start_replica(...).doit() let r = hub.users().insert(...).doit() let r = hub.instances().insert(...).doit() let r = hub.instances().import(...).doit() +let r = hub.backup_runs().insert(...).doit() let r = hub.instances().update(...).doit() let r = hub.instances().restart(...).doit() let r = hub.instances().export(...).doit() diff --git a/gen/sqladmin1_beta4/src/lib.rs b/gen/sqladmin1_beta4/src/lib.rs index c8edcd6424..67e8771195 100644 --- a/gen/sqladmin1_beta4/src/lib.rs +++ b/gen/sqladmin1_beta4/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *SQL Admin* crate version *0.1.14+20160321*, where *20160321* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *SQL Admin* crate version *0.1.14+20160907*, where *20160907* is the exact revision of the *sqladmin:v1beta4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *SQL Admin* *v1_beta4* API can be found at the //! [official documentation site](https://cloud.google.com/sql/docs/reference/latest). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.SQLAdmin.html) ... //! //! * [backup runs](struct.BackupRun.html) -//! * [*delete*](struct.BackupRunDeleteCall.html), [*get*](struct.BackupRunGetCall.html) and [*list*](struct.BackupRunListCall.html) +//! * [*delete*](struct.BackupRunDeleteCall.html), [*get*](struct.BackupRunGetCall.html), [*insert*](struct.BackupRunInsertCall.html) and [*list*](struct.BackupRunListCall.html) //! * [databases](struct.Database.html) //! * [*delete*](struct.DatabaseDeleteCall.html), [*get*](struct.DatabaseGetCall.html), [*insert*](struct.DatabaseInsertCall.html), [*list*](struct.DatabaseListCall.html), [*patch*](struct.DatabasePatchCall.html) and [*update*](struct.DatabaseUpdateCall.html) //! * [flags](struct.Flag.html) @@ -82,6 +82,7 @@ //! let r = hub.users().insert(...).doit() //! let r = hub.instances().insert(...).doit() //! let r = hub.instances().import(...).doit() +//! let r = hub.backup_runs().insert(...).doit() //! let r = hub.instances().update(...).doit() //! let r = hub.instances().restart(...).doit() //! let r = hub.instances().export(...).doit() diff --git a/gen/sqladmin1_beta4/src/lib.rs.in b/gen/sqladmin1_beta4/src/lib.rs.in index 7ad602f842..be9e4e19df 100644 --- a/gen/sqladmin1_beta4/src/lib.rs.in +++ b/gen/sqladmin1_beta4/src/lib.rs.in @@ -205,6 +205,7 @@ impl Part for OperationErrors {} /// /// * [delete backup runs](struct.BackupRunDeleteCall.html) (none) /// * [get backup runs](struct.BackupRunGetCall.html) (response) +/// * [insert backup runs](struct.BackupRunInsertCall.html) (request) /// * [list backup runs](struct.BackupRunListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -213,6 +214,8 @@ pub struct BackupRun { pub status: Option, /// This is always sql#backupRun. pub kind: Option, + /// The description of this run, only applicable to on-demand backups. + pub description: Option, /// The start time of the backup window during which this the backup was attempted in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="windowStartTime")] pub window_start_time: Option, @@ -228,6 +231,9 @@ pub struct BackupRun { /// The time the backup operation completed in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="endTime")] pub end_time: Option, + /// The type of this run; can be either "AUTOMATED" or "ON_DEMAND". + #[serde(rename="type")] + pub type_: Option, /// The time the run was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="enqueuedTime")] pub enqueued_time: Option, @@ -236,6 +242,7 @@ pub struct BackupRun { pub self_link: Option, } +impl RequestValue for BackupRun {} impl Resource for BackupRun {} impl ResponseResult for BackupRun {} @@ -409,9 +416,11 @@ impl Part for ReplicaConfiguration {} pub struct SslCertsInsertResponse { /// This is always sql#sslCertsInsert. pub kind: Option, - /// The new client certificate and private key. The new certificate will not work until the instance is restarted. + /// The new client certificate and private key. The new certificate will not work until the instance is restarted for First Generation instances. #[serde(rename="clientCert")] pub client_cert: Option, + /// The operation to track the ssl certs insert request. + pub operation: Option, /// The server Certificate Authority's certificate. If this is missing you can force a new one to be generated by calling resetSslConfig method on instances resource. #[serde(rename="serverCaCert")] pub server_ca_cert: Option, @@ -810,7 +819,7 @@ impl Part for DatabaseFlags {} pub struct DatabaseInstanceFailoverReplica { /// The availability status of the failover replica. A false status indicates that the failover replica is out of sync. The master can only failover to the falover replica when the status is true. pub available: Option, - /// The name of the failover replica. + /// The name of the failover replica. If specified at instance creation, a failover replica is created for the instance. The name doesn't include the project ID. This property is applicable only to Second Generation instances. pub name: Option, } @@ -885,10 +894,10 @@ impl Part for MySqlReplicaConfiguration {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Settings { - /// The activation policy for this instance. This specifies when the instance should be activated and is applicable only when the instance state is RUNNABLE. This can be one of the following. - /// ALWAYS: The instance should always be active. - /// NEVER: The instance should never be activated. - /// ON_DEMAND: The instance is activated upon receiving requests; only applicable to First Generation instances. + /// The activation policy specifies when the instance is activated; it is applicable only when the instance state is RUNNABLE. The activation policy cannot be updated together with other settings for Second Generation instances. Valid values: + /// ALWAYS: The instance is on; it is not deactivated by inactivity. + /// NEVER: The instance is off; it is not activated, even if a connection request arrives. + /// ON_DEMAND: The instance responds to incoming requests, and turns itself off when not in use. Instances with PER_USE pricing turn off after 15 minutes of inactivity. Instances with PER_PACKAGE pricing turn off after 12 hours of inactivity. #[serde(rename="activationPolicy")] pub activation_policy: Option, /// The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. The IPv4 address cannot be disabled for Second Generation instances. @@ -905,10 +914,13 @@ pub struct Settings { /// The version of instance settings. This is a required field for update method to make sure concurrent updates are handled properly. During update, use the most recent settingsVersion value for this instance and do not try to update this value. #[serde(rename="settingsVersion")] pub settings_version: Option, + /// Configuration to increase storage size automatically. The default value is false. Applies only to Second Generation instances. + #[serde(rename="storageAutoResize")] + pub storage_auto_resize: Option, /// The location preference settings. This allows the instance to be located as near as possible to either an App Engine app or GCE zone for better performance. App Engine co-location is only applicable to First Generation instances. #[serde(rename="locationPreference")] pub location_preference: Option, - /// The size of data disk, in GB. The data disk size minimum is 10GB. This property is only applicable to Second Generation instances. + /// The size of data disk, in GB. The data disk size minimum is 10GB. Applies only to Second Generation instances. #[serde(rename="dataDiskSizeGb")] pub data_disk_size_gb: Option, /// The database flags passed to the instance at startup. @@ -916,7 +928,7 @@ pub struct Settings { pub database_flags: Option>, /// This is always sql#settings. pub kind: Option, - /// The type of data disk. Only supported for Second Generation instances. The default type is PD_SSD. This property is only applicable to Second Generation instances. + /// The type of data disk. Only supported for Second Generation instances. The default type is PD_SSD. Applies only to Second Generation instances. #[serde(rename="dataDiskType")] pub data_disk_type: Option, /// The App Engine app IDs that can access this instance. This property is only applicable to First Generation instances. @@ -931,7 +943,7 @@ pub struct Settings { /// The pricing plan for this instance. This can be either PER_USE or PACKAGE. Only PER_USE is supported for Second Generation instances. #[serde(rename="pricingPlan")] pub pricing_plan: Option, - /// The maintenance window for this instance. This specifies when the instance may be restarted for maintenance purposes. This property is only applicable to Second Generation instances. + /// The maintenance window for this instance. This specifies when the instance may be restarted for maintenance purposes. Applies only to Second Generation instances. #[serde(rename="maintenanceWindow")] pub maintenance_window: Option, } @@ -1315,6 +1327,7 @@ impl Part for BinLogCoordinates {} /// * [insert users](struct.UserInsertCall.html) (response) /// * [insert instances](struct.InstanceInsertCall.html) (response) /// * [import instances](struct.InstanceImportCall.html) (response) +/// * [insert backup runs](struct.BackupRunInsertCall.html) (response) /// * [update instances](struct.InstanceUpdateCall.html) (response) /// * [restart instances](struct.InstanceRestartCall.html) (response) /// * [export instances](struct.InstanceExportCall.html) (response) @@ -2440,7 +2453,7 @@ impl<'a, C, A> SslCertMethods<'a, C, A> { /// ::default(), None); /// let mut hub = SQLAdmin::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)` and `list(...)` +/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.backup_runs(); /// # } @@ -2517,6 +2530,27 @@ impl<'a, C, A> BackupRunMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Creates a new backup run on demand. This method is applicable only to Second Generation instances. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Project ID of the project that contains the instance. + /// * `instance` - Cloud SQL instance ID. This does not include the project ID. + pub fn insert(&self, request: BackupRun, project: &str, instance: &str) -> BackupRunInsertCall<'a, C, A> { + BackupRunInsertCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _instance: instance.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -12513,3 +12547,281 @@ impl<'a, C, A> BackupRunDeleteCall<'a, C, A> where C: BorrowMut, } +/// Creates a new backup run on demand. This method is applicable only to Second Generation instances. +/// +/// A builder for the *insert* method supported by a *backupRun* resource. +/// It is not used directly, but through a `BackupRunMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_sqladmin1_beta4 as sqladmin1_beta4; +/// use sqladmin1_beta4::BackupRun; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use sqladmin1_beta4::SQLAdmin; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # ::default(), None); +/// # let mut hub = SQLAdmin::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 = BackupRun::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.backup_runs().insert(req, "project", "instance") +/// .doit(); +/// # } +/// ``` +pub struct BackupRunInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a SQLAdmin, + _request: BackupRun, + _project: String, + _instance: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a, C, A> CallBuilder for BackupRunInsertCall<'a, C, A> {} + +impl<'a, C, A> BackupRunInsertCall<'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: "sql.backupRuns.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(("instance", self._instance.to_string())); + for &field in ["alt", "project", "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/sql/v1beta4/projects/{project}/instances/{instance}/backupRuns".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{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(2); + for param_name in ["instance", "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: BackupRun) -> BackupRunInsertCall<'a, C, A> { + self._request = new_value; + self + } + /// Project ID of the project that contains the instance. + /// + /// 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) -> BackupRunInsertCall<'a, C, A> { + self._project = new_value.to_string(); + self + } + /// Cloud SQL instance ID. This does not include the project ID. + /// + /// 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) -> BackupRunInsertCall<'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) -> BackupRunInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not 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) -> BackupRunInsertCall<'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) -> BackupRunInsertCall<'a, C, A> + where T: AsRef { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/storage1-cli/Cargo.toml b/gen/storage1-cli/Cargo.toml index ad674c9414..eb2fc819bf 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+20160330" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "storage1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-storage1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-storage1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-storage1] diff --git a/gen/storage1-cli/README.md b/gen/storage1-cli/README.md index 8a48db20ad..5619a5acf3 100644 --- a/gen/storage1-cli/README.md +++ b/gen/storage1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *storage* API at revision *20160330*. The CLI is at version *0.3.6*. +This documentation was generated from the *storage* API at revision *20160901*. The CLI is at version *0.3.6*. ```bash storage1 [options] diff --git a/gen/storage1-cli/mkdocs.yml b/gen/storage1-cli/mkdocs.yml index 97a52a1ed7..4d2cf0475e 100644 --- a/gen/storage1-cli/mkdocs.yml +++ b/gen/storage1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: storage v0.3.6+20160330 +site_name: storage v0.3.6+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 83960fa4c0..b2f29d951e 100644 --- a/gen/storage1-cli/src/main.rs +++ b/gen/storage1-cli/src/main.rs @@ -626,6 +626,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "time-created" => Some(("timeCreated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption.default-kms-key-name" => Some(("encryption.default_kms_key_name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "project-number" => Some(("projectNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "metageneration" => Some(("metageneration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -636,7 +637,7 @@ impl<'n> Engine<'n> { "versioning.enabled" => Some(("versioning.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "storage-class" => Some(("storageClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["enabled", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["default-kms-key-name", "enabled", "encryption", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -803,6 +804,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "time-created" => Some(("timeCreated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption.default-kms-key-name" => Some(("encryption.default_kms_key_name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "project-number" => Some(("projectNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "metageneration" => Some(("metageneration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -813,7 +815,7 @@ impl<'n> Engine<'n> { "versioning.enabled" => Some(("versioning.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "storage-class" => Some(("storageClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["enabled", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["default-kms-key-name", "enabled", "encryption", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -921,6 +923,7 @@ impl<'n> Engine<'n> { "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "time-created" => Some(("timeCreated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "encryption.default-kms-key-name" => Some(("encryption.default_kms_key_name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "project-number" => Some(("projectNumber", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "metageneration" => Some(("metageneration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -931,7 +934,7 @@ impl<'n> Engine<'n> { "versioning.enabled" => Some(("versioning.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "storage-class" => Some(("storageClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["enabled", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["default-kms-key-name", "enabled", "encryption", "entity", "entity-id", "etag", "id", "kind", "location", "log-bucket", "log-object-prefix", "logging", "main-page-suffix", "metageneration", "name", "not-found-page", "owner", "project-number", "self-link", "storage-class", "time-created", "updated", "versioning", "website"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2035,6 +2038,7 @@ impl<'n> Engine<'n> { "destination.generation" => Some(("destination.generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "destination.component-count" => Some(("destination.componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "destination.media-link" => Some(("destination.mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "destination.kms-key-name" => Some(("destination.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "destination.owner.entity-id" => Some(("destination.owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "destination.owner.entity" => Some(("destination.owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "destination.cache-control" => Some(("destination.cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2060,7 +2064,7 @@ impl<'n> Engine<'n> { "destination.storage-class" => Some(("destination.storageClass", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "destination.self-link" => Some(("destination.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "destination", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "destination", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2075,6 +2079,9 @@ impl<'n> Engine<'n> { for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "kms-key-name" => { + call = call.kms_key_name(value.unwrap_or("")); + }, "if-metageneration-match" => { call = call.if_metageneration_match(value.unwrap_or("")); }, @@ -2100,7 +2107,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["if-metageneration-match", "if-generation-match", "destination-predefined-acl"].iter().map(|v|*v)); + v.extend(["if-metageneration-match", "if-generation-match", "destination-predefined-acl", "kms-key-name"].iter().map(|v|*v)); v } )); } } @@ -2165,6 +2172,7 @@ impl<'n> Engine<'n> { "generation" => Some(("generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "component-count" => Some(("componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "media-link" => Some(("mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kms-key-name" => Some(("kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity-id" => Some(("owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity" => Some(("owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cache-control" => Some(("cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2190,7 +2198,7 @@ impl<'n> Engine<'n> { "storage-class" => Some(("storageClass", 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!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2459,6 +2467,7 @@ impl<'n> Engine<'n> { "generation" => Some(("generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "component-count" => Some(("componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "media-link" => Some(("mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kms-key-name" => Some(("kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity-id" => Some(("owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity" => Some(("owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cache-control" => Some(("cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2484,7 +2493,7 @@ impl<'n> Engine<'n> { "storage-class" => Some(("storageClass", 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!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2507,6 +2516,9 @@ impl<'n> Engine<'n> { "name" => { call = call.name(value.unwrap_or("")); }, + "kms-key-name" => { + call = call.kms_key_name(value.unwrap_or("")); + }, "if-metageneration-not-match" => { call = call.if_metageneration_not_match(value.unwrap_or("")); }, @@ -2535,7 +2547,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["if-generation-match", "if-generation-not-match", "content-encoding", "if-metageneration-match", "name", "predefined-acl", "if-metageneration-not-match", "projection"].iter().map(|v|*v)); + v.extend(["if-generation-match", "projection", "if-metageneration-match", "content-encoding", "if-generation-not-match", "kms-key-name", "predefined-acl", "if-metageneration-not-match", "name"].iter().map(|v|*v)); v } )); } } @@ -2672,6 +2684,7 @@ impl<'n> Engine<'n> { "generation" => Some(("generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "component-count" => Some(("componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "media-link" => Some(("mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kms-key-name" => Some(("kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity-id" => Some(("owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity" => Some(("owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cache-control" => Some(("cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2697,7 +2710,7 @@ impl<'n> Engine<'n> { "storage-class" => Some(("storageClass", 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!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2805,6 +2818,7 @@ impl<'n> Engine<'n> { "generation" => Some(("generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "component-count" => Some(("componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "media-link" => Some(("mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kms-key-name" => Some(("kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity-id" => Some(("owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity" => Some(("owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cache-control" => Some(("cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2830,7 +2844,7 @@ impl<'n> Engine<'n> { "storage-class" => Some(("storageClass", 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!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2883,6 +2897,9 @@ impl<'n> Engine<'n> { "destination-predefined-acl" => { call = call.destination_predefined_acl(value.unwrap_or("")); }, + "destination-kms-key-name" => { + call = call.destination_kms_key_name(value.unwrap_or("")); + }, _ => { let mut found = false; for param in &self.gp { @@ -2896,7 +2913,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["if-source-generation-match", "if-generation-match", "projection", "if-source-metageneration-not-match", "if-metageneration-not-match", "source-generation", "max-bytes-rewritten-per-call", "if-source-generation-not-match", "destination-predefined-acl", "if-source-metageneration-match", "rewrite-token", "if-metageneration-match", "if-generation-not-match"].iter().map(|v|*v)); + v.extend(["if-source-generation-match", "if-generation-match", "projection", "if-source-metageneration-not-match", "destination-kms-key-name", "if-metageneration-not-match", "source-generation", "max-bytes-rewritten-per-call", "if-source-generation-not-match", "destination-predefined-acl", "if-source-metageneration-match", "rewrite-token", "if-metageneration-match", "if-generation-not-match"].iter().map(|v|*v)); v } )); } } @@ -2956,6 +2973,7 @@ impl<'n> Engine<'n> { "generation" => Some(("generation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "component-count" => Some(("componentCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "media-link" => Some(("mediaLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "kms-key-name" => Some(("kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity-id" => Some(("owner.entityId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "owner.entity" => Some(("owner.entity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cache-control" => Some(("cacheControl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2981,7 +2999,7 @@ impl<'n> Engine<'n> { "storage-class" => Some(("storageClass", 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!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket", "cache-control", "component-count", "content-disposition", "content-encoding", "content-language", "content-type", "crc32c", "customer-encryption", "encryption-algorithm", "entity", "entity-id", "etag", "generation", "id", "key-sha256", "kind", "kms-key-name", "md5-hash", "media-link", "metadata", "metageneration", "name", "owner", "self-link", "size", "storage-class", "time-created", "time-deleted", "updated"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -4476,7 +4494,7 @@ fn main() { let mut app = App::new("storage1") .author("Sebastian Thiel ") - .version("0.3.6+20160330") + .version("0.3.6+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/storage1/Cargo.toml b/gen/storage1/Cargo.toml index bb42bd75cc..ca2fd9b3ee 100644 --- a/gen/storage1/Cargo.toml +++ b/gen/storage1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-storage1" -version = "0.1.14+20160330" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/storage1/README.md b/gen/storage1/README.md index e720392090..8b5384b071 100644 --- a/gen/storage1/README.md +++ b/gen/storage1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-storage1` library allows access to all features of the *Google storage* service. -This documentation was generated from *storage* crate version *0.1.14+20160330*, where *20160330* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *storage* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *storage* *v1* API can be found at the [official documentation site](https://developers.google.com/storage/docs/json_api/). @@ -148,6 +148,7 @@ let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destina .if_generation_not_match("nonumy") .if_generation_match("dolores") .destination_predefined_acl("gubergren") + .destination_kms_key_name("sadipscing") .doit(); match result { diff --git a/gen/storage1/src/lib.rs b/gen/storage1/src/lib.rs index 196c9bbb58..d9a6dc9fae 100644 --- a/gen/storage1/src/lib.rs +++ b/gen/storage1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *storage* crate version *0.1.14+20160330*, where *20160330* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *storage* crate version *0.1.14+20160901*, where *20160901* is the exact revision of the *storage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *storage* *v1* API can be found at the //! [official documentation site](https://developers.google.com/storage/docs/json_api/). @@ -136,19 +136,20 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") -//! .source_generation("accusam") -//! .rewrite_token("dolores") -//! .projection("consetetur") -//! .max_bytes_rewritten_per_call("dolor") -//! .if_source_metageneration_not_match("aliquyam") -//! .if_source_metageneration_match("elitr") -//! .if_source_generation_not_match("ea") -//! .if_source_generation_match("et") -//! .if_metageneration_not_match("Stet") -//! .if_metageneration_match("sed") -//! .if_generation_not_match("dolor") -//! .if_generation_match("sanctus") -//! .destination_predefined_acl("dolore") +//! .source_generation("elitr") +//! .rewrite_token("ea") +//! .projection("et") +//! .max_bytes_rewritten_per_call("Stet") +//! .if_source_metageneration_not_match("sed") +//! .if_source_metageneration_match("dolor") +//! .if_source_generation_not_match("sanctus") +//! .if_source_generation_match("dolore") +//! .if_metageneration_not_match("Lorem") +//! .if_metageneration_match("consetetur") +//! .if_generation_not_match("consetetur") +//! .if_generation_match("eirmod") +//! .destination_predefined_acl("labore") +//! .destination_kms_key_name("gubergren") //! .doit(); //! //! match result { diff --git a/gen/storage1/src/lib.rs.in b/gen/storage1/src/lib.rs.in index 46bb1d2891..69a1ed20d3 100644 --- a/gen/storage1/src/lib.rs.in +++ b/gen/storage1/src/lib.rs.in @@ -115,18 +115,19 @@ impl Default for Scope { /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") /// .source_generation("justo") -/// .rewrite_token("justo") +/// .rewrite_token("et") /// .projection("et") -/// .max_bytes_rewritten_per_call("et") -/// .if_source_metageneration_not_match("diam") -/// .if_source_metageneration_match("ipsum") -/// .if_source_generation_not_match("Lorem") -/// .if_source_generation_match("et") -/// .if_metageneration_not_match("duo") -/// .if_metageneration_match("aliquyam") -/// .if_generation_not_match("sea") -/// .if_generation_match("Lorem") -/// .destination_predefined_acl("eos") +/// .max_bytes_rewritten_per_call("diam") +/// .if_source_metageneration_not_match("ipsum") +/// .if_source_metageneration_match("Lorem") +/// .if_source_generation_not_match("et") +/// .if_source_generation_match("duo") +/// .if_metageneration_not_match("aliquyam") +/// .if_metageneration_match("sea") +/// .if_generation_not_match("Lorem") +/// .if_generation_match("eos") +/// .destination_predefined_acl("erat") +/// .destination_kms_key_name("sadipscing") /// .doit(); /// /// match result { @@ -245,7 +246,7 @@ pub struct ObjectAccessControlProjectTeam { /// The project number. #[serde(rename="projectNumber")] pub project_number: Option, - /// The team. Can be owners, editors, or viewers. + /// The team. pub team: Option, } @@ -276,16 +277,16 @@ impl NestedType for BucketLifecycleRuleCondition {} impl Part for BucketLifecycleRuleCondition {} -/// The bucket's website configuration. +/// The bucket's website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the Static Website Examples for more information. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketWebsite { - /// The custom object to return when a requested resource is not found. + /// If the requested object path is missing, and any mainPageSuffix object is missing, if applicable, the service will return the named object from this bucket as the content for a 404 Not Found result. #[serde(rename="notFoundPage")] pub not_found_page: Option, - /// Behaves as the bucket's directory index where missing objects are treated as potential directories. + /// If the requested object path is missing, the service will ensure the path has a trailing '/', append this suffix, and attempt to retrieve the resulting object. This allows the creation of index.html objects to represent directory pages. #[serde(rename="mainPageSuffix")] pub main_page_suffix: Option, } @@ -407,7 +408,7 @@ pub struct Object { pub self_link: Option, /// The modification time of the object metadata in RFC 3339 format. pub updated: Option, - /// Content-Type of the object data. + /// Content-Type of the object data. If contentType is not specified, object downloads will be served as application/octet-stream. #[serde(rename="contentType")] pub content_type: Option, /// The creation time of the object in RFC 3339 format. @@ -426,9 +427,12 @@ pub struct Object { /// Media download link. #[serde(rename="mediaLink")] pub media_link: Option, + /// Cloud KMS Key used to encrypt this object, if the object is encrypted by such a key. + #[serde(rename="kmsKeyName")] + pub kms_key_name: Option, /// The owner of the object. This will always be the uploader of the object. pub owner: Option, - /// Cache-Control directive for the object data. + /// Cache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600. #[serde(rename="cacheControl")] pub cache_control: Option, /// Access controls on the object. @@ -551,7 +555,7 @@ pub struct BucketAccessControlProjectTeam { /// The project number. #[serde(rename="projectNumber")] pub project_number: Option, - /// The team. Can be owners, editors, or viewers. + /// The team. pub team: Option, } @@ -609,7 +613,7 @@ impl Part for ComposeRequestSourceObjects {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Bucket { - /// The bucket's website configuration. + /// The bucket's website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the Static Website Examples for more information. pub website: Option, /// The modification time of the bucket in RFC 3339 format. pub updated: Option, @@ -637,6 +641,8 @@ pub struct Bucket { pub logging: Option, /// The name of the bucket. pub name: Option, + /// Encryption configuration used by default for newly inserted objects, when no encryption config is specified. + pub encryption: Option, /// The project number of the project the bucket belongs to. #[serde(rename="projectNumber")] pub project_number: Option, @@ -659,6 +665,20 @@ impl Resource for Bucket {} impl ResponseResult for Bucket {} +/// Encryption configuration used by default for newly inserted objects, when no encryption config is 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 BucketEncryption { + /// no description provided + pub default_kms_key_name: Option, +} + +impl NestedType for BucketEncryption {} +impl Part for BucketEncryption {} + + /// Metadata of customer-supplied encryption key, if the object is encrypted by such a key. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -716,7 +736,7 @@ pub struct BucketAccessControl { pub email: Option, /// HTTP 1.1 Entity tag for the access-control entry. pub etag: Option, - /// The access permission for the entity. Can be READER, WRITER, or OWNER. + /// The access permission for the entity. pub role: Option, /// The ID for the entity, if any. #[serde(rename="entityId")] @@ -783,7 +803,7 @@ pub struct ObjectAccessControl { pub email: Option, /// HTTP 1.1 Entity tag for the access-control entry. pub etag: Option, - /// The access permission for the entity. Can be READER or OWNER. + /// The access permission for the entity. pub role: Option, /// The ID for the entity, if any. #[serde(rename="entityId")] @@ -1378,6 +1398,7 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _if_generation_not_match: Default::default(), _if_generation_match: Default::default(), _destination_predefined_acl: Default::default(), + _destination_kms_key_name: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1478,6 +1499,7 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _projection: Default::default(), _predefined_acl: Default::default(), _name: Default::default(), + _kms_key_name: Default::default(), _if_metageneration_not_match: Default::default(), _if_metageneration_match: Default::default(), _if_generation_not_match: Default::default(), @@ -1504,6 +1526,7 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _request: request, _destination_bucket: destination_bucket.to_string(), _destination_object: destination_object.to_string(), + _kms_key_name: Default::default(), _if_metageneration_match: Default::default(), _if_generation_match: Default::default(), _destination_predefined_acl: Default::default(), @@ -2550,8 +2573,8 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.default_object_access_controls().list("bucket") -/// .if_metageneration_not_match("elitr") -/// .if_metageneration_match("amet") +/// .if_metageneration_not_match("no") +/// .if_metageneration_match("labore") /// .doit(); /// # } /// ``` @@ -5338,19 +5361,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") -/// .source_generation("sed") +/// .source_generation("dolor") /// .rewrite_token("dolor") -/// .projection("dolor") -/// .max_bytes_rewritten_per_call("dolor") -/// .if_source_metageneration_not_match("et") -/// .if_source_metageneration_match("consetetur") -/// .if_source_generation_not_match("amet.") -/// .if_source_generation_match("voluptua.") -/// .if_metageneration_not_match("Lorem") -/// .if_metageneration_match("gubergren") -/// .if_generation_not_match("justo") -/// .if_generation_match("sit") -/// .destination_predefined_acl("vero") +/// .projection("et") +/// .max_bytes_rewritten_per_call("consetetur") +/// .if_source_metageneration_not_match("amet.") +/// .if_source_metageneration_match("voluptua.") +/// .if_source_generation_not_match("Lorem") +/// .if_source_generation_match("gubergren") +/// .if_metageneration_not_match("justo") +/// .if_metageneration_match("sit") +/// .if_generation_not_match("vero") +/// .if_generation_match("diam") +/// .destination_predefined_acl("rebum.") +/// .destination_kms_key_name("consetetur") /// .doit(); /// # } /// ``` @@ -5376,6 +5400,7 @@ pub struct ObjectRewriteCall<'a, C, A> _if_generation_not_match: Option, _if_generation_match: Option, _destination_predefined_acl: Option, + _destination_kms_key_name: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -5397,7 +5422,7 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "storage.objects.rewrite", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((20 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((21 + self._additional_params.len())); params.push(("sourceBucket", self._source_bucket.to_string())); params.push(("sourceObject", self._source_object.to_string())); params.push(("destinationBucket", self._destination_bucket.to_string())); @@ -5441,7 +5466,10 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._destination_predefined_acl { params.push(("destinationPredefinedAcl", value.to_string())); } - for &field in ["alt", "sourceBucket", "sourceObject", "destinationBucket", "destinationObject", "sourceGeneration", "rewriteToken", "projection", "maxBytesRewrittenPerCall", "ifSourceMetagenerationNotMatch", "ifSourceMetagenerationMatch", "ifSourceGenerationNotMatch", "ifSourceGenerationMatch", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { + if let Some(value) = self._destination_kms_key_name { + params.push(("destinationKmsKeyName", value.to_string())); + } + for &field in ["alt", "sourceBucket", "sourceObject", "destinationBucket", "destinationObject", "sourceGeneration", "rewriteToken", "projection", "maxBytesRewrittenPerCall", "ifSourceMetagenerationNotMatch", "ifSourceMetagenerationMatch", "ifSourceGenerationNotMatch", "ifSourceGenerationMatch", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "destinationPredefinedAcl", "destinationKmsKeyName"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5711,6 +5739,13 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut, A: self._destination_predefined_acl = Some(new_value.to_string()); self } + /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any. + /// + /// Sets the *destination kms key name* query property to the given value. + pub fn destination_kms_key_name(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._destination_kms_key_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. /// @@ -5795,12 +5830,12 @@ impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().get("bucket", "object") -/// .projection("consetetur") -/// .if_metageneration_not_match("sadipscing") -/// .if_metageneration_match("vero") -/// .if_generation_not_match("sadipscing") -/// .if_generation_match("invidunt") -/// .generation("consetetur") +/// .projection("sadipscing") +/// .if_metageneration_not_match("invidunt") +/// .if_metageneration_match("consetetur") +/// .if_generation_not_match("dolore") +/// .if_generation_match("duo") +/// .generation("aliquyam") /// .doit(); /// # } /// ``` @@ -6141,13 +6176,13 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().update(req, "bucket", "object") -/// .projection("aliquyam") -/// .predefined_acl("Lorem") -/// .if_metageneration_not_match("et") -/// .if_metageneration_match("clita") -/// .if_generation_not_match("consetetur") -/// .if_generation_match("takimata") -/// .generation("nonumy") +/// .projection("clita") +/// .predefined_acl("consetetur") +/// .if_metageneration_not_match("takimata") +/// .if_metageneration_match("nonumy") +/// .if_generation_not_match("kasd") +/// .if_generation_match("sanctus") +/// .generation("takimata") /// .doit(); /// # } /// ``` @@ -6519,12 +6554,12 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().watch_all(req, "bucket") -/// .versions(true) -/// .projection("takimata") -/// .prefix("At") -/// .page_token("labore") -/// .max_results(64) -/// .delimiter("ea") +/// .versions(false) +/// .projection("invidunt") +/// .prefix("ea") +/// .page_token("sadipscing") +/// .max_results(35) +/// .delimiter("dolore") /// .doit(); /// # } /// ``` @@ -6863,14 +6898,15 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().insert(req, "bucket") -/// .projection("rebum.") -/// .predefined_acl("dolore") -/// .name("nonumy") -/// .if_metageneration_not_match("sed") -/// .if_metageneration_match("aliquyam") -/// .if_generation_not_match("sit") -/// .if_generation_match("eirmod") -/// .content_encoding("consetetur") +/// .projection("sed") +/// .predefined_acl("aliquyam") +/// .name("sit") +/// .kms_key_name("eirmod") +/// .if_metageneration_not_match("consetetur") +/// .if_metageneration_match("labore") +/// .if_generation_not_match("sed") +/// .if_generation_match("ea") +/// .content_encoding("gubergren") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6883,6 +6919,7 @@ pub struct ObjectInsertCall<'a, C, A> _projection: Option, _predefined_acl: Option, _name: Option, + _kms_key_name: Option, _if_metageneration_not_match: Option, _if_metageneration_match: Option, _if_generation_not_match: Option, @@ -6910,7 +6947,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "storage.objects.insert", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); params.push(("bucket", self._bucket.to_string())); if let Some(value) = self._projection { params.push(("projection", value.to_string())); @@ -6921,6 +6958,9 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._name { params.push(("name", value.to_string())); } + if let Some(value) = self._kms_key_name { + params.push(("kmsKeyName", value.to_string())); + } if let Some(value) = self._if_metageneration_not_match { params.push(("ifMetagenerationNotMatch", value.to_string())); } @@ -6936,7 +6976,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._content_encoding { params.push(("contentEncoding", value.to_string())); } - for &field in ["bucket", "projection", "predefinedAcl", "name", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "contentEncoding"].iter() { + for &field in ["bucket", "projection", "predefinedAcl", "name", "kmsKeyName", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "contentEncoding"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7230,6 +7270,13 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut, A: self._name = Some(new_value.to_string()); self } + /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any. + /// + /// Sets the *kms key name* query property to the given value. + pub fn kms_key_name(mut self, new_value: &str) -> ObjectInsertCall<'a, C, A> { + self._kms_key_name = Some(new_value.to_string()); + self + } /// Makes the operation conditional on whether the object's current metageneration does not match the given value. /// /// Sets the *if metageneration not match* query property to the given value. @@ -7355,9 +7402,10 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().compose(req, "destinationBucket", "destinationObject") -/// .if_metageneration_match("ea") -/// .if_generation_match("gubergren") -/// .destination_predefined_acl("aliquyam") +/// .kms_key_name("tempor") +/// .if_metageneration_match("sea") +/// .if_generation_match("labore") +/// .destination_predefined_acl("ipsum") /// .doit(); /// # } /// ``` @@ -7368,6 +7416,7 @@ pub struct ObjectComposeCall<'a, C, A> _request: ComposeRequest, _destination_bucket: String, _destination_object: String, + _kms_key_name: Option, _if_metageneration_match: Option, _if_generation_match: Option, _destination_predefined_acl: Option, @@ -7392,9 +7441,12 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut, A: }; dlg.begin(MethodInfo { id: "storage.objects.compose", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); params.push(("destinationBucket", self._destination_bucket.to_string())); params.push(("destinationObject", self._destination_object.to_string())); + if let Some(value) = self._kms_key_name { + params.push(("kmsKeyName", value.to_string())); + } if let Some(value) = self._if_metageneration_match { params.push(("ifMetagenerationMatch", value.to_string())); } @@ -7404,7 +7456,7 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut, A: if let Some(value) = self._destination_predefined_acl { params.push(("destinationPredefinedAcl", value.to_string())); } - for &field in ["destinationBucket", "destinationObject", "ifMetagenerationMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { + for &field in ["destinationBucket", "destinationObject", "kmsKeyName", "ifMetagenerationMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7579,6 +7631,13 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut, A: self._destination_object = new_value.to_string(); self } + /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any. + /// + /// Sets the *kms key name* query property to the given value. + pub fn kms_key_name(mut self, new_value: &str) -> ObjectComposeCall<'a, C, A> { + self._kms_key_name = Some(new_value.to_string()); + self + } /// Makes the operation conditional on whether the object's current metageneration matches the given value. /// /// Sets the *if metageneration match* query property to the given value. @@ -7679,11 +7738,11 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().delete("bucket", "object") -/// .if_metageneration_not_match("sea") -/// .if_metageneration_match("labore") -/// .if_generation_not_match("ipsum") -/// .if_generation_match("aliquyam") -/// .generation("dolores") +/// .if_metageneration_not_match("sit") +/// .if_metageneration_match("diam") +/// .if_generation_not_match("ut") +/// .if_generation_match("justo") +/// .generation("est") /// .doit(); /// # } /// ``` @@ -7976,11 +8035,11 @@ impl<'a, C, A> ObjectDeleteCall<'a, C, A> where C: BorrowMut, A: /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().list("bucket") /// .versions(true) -/// .projection("ut") -/// .prefix("justo") -/// .page_token("est") -/// .max_results(55) -/// .delimiter("accusam") +/// .projection("clita") +/// .prefix("diam") +/// .page_token("justo") +/// .max_results(44) +/// .delimiter("clita") /// .doit(); /// # } /// ``` @@ -8293,17 +8352,17 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().copy(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") -/// .source_generation("clita") -/// .projection("invidunt") -/// .if_source_metageneration_not_match("ut") -/// .if_source_metageneration_match("dolores") -/// .if_source_generation_not_match("eos") -/// .if_source_generation_match("voluptua.") -/// .if_metageneration_not_match("duo") -/// .if_metageneration_match("sed") -/// .if_generation_not_match("aliquyam") -/// .if_generation_match("ea") -/// .destination_predefined_acl("ea") +/// .source_generation("voluptua.") +/// .projection("duo") +/// .if_source_metageneration_not_match("sed") +/// .if_source_metageneration_match("aliquyam") +/// .if_source_generation_not_match("ea") +/// .if_source_generation_match("ea") +/// .if_metageneration_not_match("et") +/// .if_metageneration_match("dolor") +/// .if_generation_not_match("diam") +/// .if_generation_match("kasd") +/// .destination_predefined_acl("invidunt") /// .doit(); /// # } /// ``` @@ -8743,13 +8802,13 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().patch(req, "bucket", "object") -/// .projection("diam") -/// .predefined_acl("kasd") -/// .if_metageneration_not_match("invidunt") -/// .if_metageneration_match("rebum.") -/// .if_generation_not_match("Lorem") -/// .if_generation_match("clita") -/// .generation("invidunt") +/// .projection("clita") +/// .predefined_acl("invidunt") +/// .if_metageneration_not_match("eirmod") +/// .if_metageneration_match("At") +/// .if_generation_not_match("consetetur") +/// .if_generation_match("et") +/// .generation("sed") /// .doit(); /// # } /// ``` @@ -9105,7 +9164,7 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.object_access_controls().insert(req, "bucket", "object") -/// .generation("consetetur") +/// .generation("elitr") /// .doit(); /// # } /// ``` @@ -9395,7 +9454,7 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut ObjectAccessControlListCall<'a, C, A> where C: BorrowMut ObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut BucketUpdateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().get("bucket") -/// .projection("sed") -/// .if_metageneration_not_match("et") -/// .if_metageneration_match("ipsum") +/// .projection("vero") +/// .if_metageneration_not_match("dolor") +/// .if_metageneration_match("takimata") /// .doit(); /// # } /// ``` @@ -11380,8 +11439,8 @@ impl<'a, C, A> BucketGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().delete("bucket") -/// .if_metageneration_not_match("dolore") -/// .if_metageneration_match("vero") +/// .if_metageneration_not_match("nonumy") +/// .if_metageneration_match("et") /// .doit(); /// # } /// ``` @@ -11634,9 +11693,9 @@ impl<'a, C, A> BucketDeleteCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().insert(req, "project") -/// .projection("takimata") -/// .predefined_default_object_acl("et") -/// .predefined_acl("nonumy") +/// .projection("no") +/// .predefined_default_object_acl("invidunt") +/// .predefined_acl("rebum.") /// .doit(); /// # } /// ``` @@ -11915,11 +11974,11 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().patch(req, "bucket") -/// .projection("sed") -/// .predefined_default_object_acl("no") -/// .predefined_acl("invidunt") -/// .if_metageneration_not_match("rebum.") -/// .if_metageneration_match("labore") +/// .projection("aliquyam") +/// .predefined_default_object_acl("elitr") +/// .predefined_acl("consetetur") +/// .if_metageneration_not_match("sea") +/// .if_metageneration_match("elitr") /// .doit(); /// # } /// ``` @@ -12235,10 +12294,10 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().list("project") -/// .projection("elitr") +/// .projection("sea") /// .prefix("consetetur") -/// .page_token("sea") -/// .max_results(58) +/// .page_token("diam") +/// .max_results(79) /// .doit(); /// # } /// ``` diff --git a/gen/storagetransfer1-cli/Cargo.toml b/gen/storagetransfer1-cli/Cargo.toml index f97f963a99..e4eebf0589 100644 --- a/gen/storagetransfer1-cli/Cargo.toml +++ b/gen/storagetransfer1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "storagetransfer1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-storagetransfer1/nightly" with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-storagetransfer1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-storagetransfer1] diff --git a/gen/storagetransfer1/Cargo.toml b/gen/storagetransfer1/Cargo.toml index c403118ca3..1e6a5ed7d7 100644 --- a/gen/storagetransfer1/Cargo.toml +++ b/gen/storagetransfer1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/tagmanager1-cli/Cargo.toml b/gen/tagmanager1-cli/Cargo.toml index 4e41d00925..4871bde658 100644 --- a/gen/tagmanager1-cli/Cargo.toml +++ b/gen/tagmanager1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "tagmanager1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-tagmanager1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-tagmanager1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-tagmanager1] diff --git a/gen/tagmanager1/Cargo.toml b/gen/tagmanager1/Cargo.toml index e6afc420d1..8ff53661db 100644 --- a/gen/tagmanager1/Cargo.toml +++ b/gen/tagmanager1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/taskqueue1_beta2-cli/Cargo.toml b/gen/taskqueue1_beta2-cli/Cargo.toml index 54fba0f893..0b9ea30cf3 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+20141111" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "taskqueue1-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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","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] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-taskqueue1_beta2] diff --git a/gen/taskqueue1_beta2-cli/README.md b/gen/taskqueue1_beta2-cli/README.md index ad18ec4853..bcb8ff8ff3 100644 --- a/gen/taskqueue1_beta2-cli/README.md +++ b/gen/taskqueue1_beta2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *taskqueue* API at revision *20141111*. The CLI is at version *0.3.6*. +This documentation was generated from the *taskqueue* API at revision *20160428*. The CLI is at version *0.3.6*. ```bash taskqueue1-beta2 [options] diff --git a/gen/taskqueue1_beta2-cli/mkdocs.yml b/gen/taskqueue1_beta2-cli/mkdocs.yml index 6cfcabea47..8cae9b3329 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+20141111 +site_name: taskqueue v0.3.6+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 d549fd43d8..df3d857b34 100644 --- a/gen/taskqueue1_beta2-cli/src/main.rs +++ b/gen/taskqueue1_beta2-cli/src/main.rs @@ -1009,8 +1009,8 @@ fn main() { let mut app = App::new("taskqueue1-beta2") .author("Sebastian Thiel ") - .version("0.3.6+20141111") - .about("Lets you access a Google App Engine Pull Task Queue over REST.") + .version("0.3.6+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") .long("scope") diff --git a/gen/taskqueue1_beta2/Cargo.toml b/gen/taskqueue1_beta2/Cargo.toml index c5f00c3237..98d30fc7df 100644 --- a/gen/taskqueue1_beta2/Cargo.toml +++ b/gen/taskqueue1_beta2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-taskqueue1_beta2" -version = "0.1.14+20141111" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/taskqueue1_beta2/README.md b/gen/taskqueue1_beta2/README.md index 0b2ef43142..e879ab2719 100644 --- a/gen/taskqueue1_beta2/README.md +++ b/gen/taskqueue1_beta2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-taskqueue1_beta2` library allows access to all features of the *Google taskqueue* service. -This documentation was generated from *taskqueue* crate version *0.1.14+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *taskqueue* crate version *0.1.14+20160428*, where *20160428* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *taskqueue* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/appengine/docs/python/taskqueue/rest). diff --git a/gen/taskqueue1_beta2/src/lib.rs b/gen/taskqueue1_beta2/src/lib.rs index d524854d4b..81943348a0 100644 --- a/gen/taskqueue1_beta2/src/lib.rs +++ b/gen/taskqueue1_beta2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *taskqueue* crate version *0.1.14+20141111*, where *20141111* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *taskqueue* crate version *0.1.14+20160428*, where *20160428* is the exact revision of the *taskqueue:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *taskqueue* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/appengine/docs/python/taskqueue/rest). diff --git a/gen/tasks1-cli/Cargo.toml b/gen/tasks1-cli/Cargo.toml index f939404525..5b8a0efdc6 100644 --- a/gen/tasks1-cli/Cargo.toml +++ b/gen/tasks1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "tasks1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-tasks1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-tasks1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-tasks1] diff --git a/gen/tasks1/Cargo.toml b/gen/tasks1/Cargo.toml index 8e4cd9255f..d2532106cb 100644 --- a/gen/tasks1/Cargo.toml +++ b/gen/tasks1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/translate2-cli/Cargo.toml b/gen/translate2-cli/Cargo.toml index ab11e641b2..e0be9cee8e 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+20160217" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "translate2" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-translate2/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-translate2/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-translate2] diff --git a/gen/translate2-cli/README.md b/gen/translate2-cli/README.md index 429343958a..7eebed8275 100644 --- a/gen/translate2-cli/README.md +++ b/gen/translate2-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *translate* API at revision *20160217*. The CLI is at version *0.3.6*. +This documentation was generated from the *translate* API at revision *20160627*. The CLI is at version *0.3.6*. ```bash translate2 [options] diff --git a/gen/translate2-cli/mkdocs.yml b/gen/translate2-cli/mkdocs.yml index 0f02e0485b..7887238a5a 100644 --- a/gen/translate2-cli/mkdocs.yml +++ b/gen/translate2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: translate v0.3.6+20160217 +site_name: translate v0.3.6+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 747778ac92..03eb727b1b 100644 --- a/gen/translate2-cli/src/main.rs +++ b/gen/translate2-cli/src/main.rs @@ -405,8 +405,8 @@ fn main() { let mut app = App::new("translate2") .author("Sebastian Thiel ") - .version("0.3.6+20160217") - .about("Lets you translate text from one language to another") + .version("0.3.6+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") .long("config-dir") diff --git a/gen/translate2/Cargo.toml b/gen/translate2/Cargo.toml index 543e153e38..7e9e190dcb 100644 --- a/gen/translate2/Cargo.toml +++ b/gen/translate2/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-translate2" -version = "0.1.14+20160217" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/translate2/README.md b/gen/translate2/README.md index 5d943767d2..4bc2d0b3c3 100644 --- a/gen/translate2/README.md +++ b/gen/translate2/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-translate2` library allows access to all features of the *Google translate* service. -This documentation was generated from *translate* crate version *0.1.14+20160217*, where *20160217* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *translate* crate version *0.1.14+20160627*, where *20160627* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *translate* *v2* API can be found at the [official documentation site](https://developers.google.com/translate/v2/using_rest). diff --git a/gen/translate2/src/lib.rs b/gen/translate2/src/lib.rs index 4326a1ac67..e49e61b3c2 100644 --- a/gen/translate2/src/lib.rs +++ b/gen/translate2/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *translate* crate version *0.1.14+20160217*, where *20160217* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *translate* crate version *0.1.14+20160627*, where *20160627* is the exact revision of the *translate:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *translate* *v2* API can be found at the //! [official documentation site](https://developers.google.com/translate/v2/using_rest). diff --git a/gen/urlshortener1-cli/Cargo.toml b/gen/urlshortener1-cli/Cargo.toml index 9e94bb92a5..45ba6e8d11 100644 --- a/gen/urlshortener1-cli/Cargo.toml +++ b/gen/urlshortener1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "urlshortener1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-urlshortener1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-urlshortener1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-urlshortener1] diff --git a/gen/urlshortener1/Cargo.toml b/gen/urlshortener1/Cargo.toml index 56e5726e7c..b2f5955bab 100644 --- a/gen/urlshortener1/Cargo.toml +++ b/gen/urlshortener1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/webfonts1-cli/Cargo.toml b/gen/webfonts1-cli/Cargo.toml index 622de32144..6b199533bc 100644 --- a/gen/webfonts1-cli/Cargo.toml +++ b/gen/webfonts1-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "webfonts1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-webfonts1/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-webfonts1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-webfonts1] diff --git a/gen/webfonts1/Cargo.toml b/gen/webfonts1/Cargo.toml index 283abbd8ad..7c57f5fdd9 100644 --- a/gen/webfonts1/Cargo.toml +++ b/gen/webfonts1/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/webmasters3-cli/Cargo.toml b/gen/webmasters3-cli/Cargo.toml index 13e1fb6792..e408f86fc5 100644 --- a/gen/webmasters3-cli/Cargo.toml +++ b/gen/webmasters3-cli/Cargo.toml @@ -19,10 +19,10 @@ name = "webmasters3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-webmasters3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-webmasters3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-webmasters3] diff --git a/gen/webmasters3/Cargo.toml b/gen/webmasters3/Cargo.toml index e8b5f0d752..14a75c0349 100644 --- a/gen/webmasters3/Cargo.toml +++ b/gen/webmasters3/Cargo.toml @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/youtube3-cli/Cargo.toml b/gen/youtube3-cli/Cargo.toml index ad6d2989fe..5bb4ee03ca 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+20160222" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "youtube3" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-youtube3/nightly"] with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtube3/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtube3] diff --git a/gen/youtube3-cli/README.md b/gen/youtube3-cli/README.md index 08b37b4922..32f646b7cd 100644 --- a/gen/youtube3-cli/README.md +++ b/gen/youtube3-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *YouTube* API at revision *20160222*. The CLI is at version *0.3.6*. +This documentation was generated from the *YouTube* API at revision *20160805*. The CLI is at version *0.3.6*. ```bash youtube3 [options] diff --git a/gen/youtube3-cli/mkdocs.yml b/gen/youtube3-cli/mkdocs.yml index 607034abb8..e1a8db89d4 100644 --- a/gen/youtube3-cli/mkdocs.yml +++ b/gen/youtube3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube v0.3.6+20160222 +site_name: YouTube v0.3.6+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 f3a1173b40..3373edb661 100644 --- a/gen/youtube3-cli/src/main.rs +++ b/gen/youtube3-cli/src/main.rs @@ -2546,18 +2546,20 @@ impl<'n> Engine<'n> { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.concurrent-viewers" => Some(("statistics.concurrentViewers", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.total-chat-count" => Some(("statistics.totalChatCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "content-details.closed-captions-type" => Some(("contentDetails.closedCaptionsType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-low-latency" => Some(("contentDetails.enableLowLatency", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "content-details.monitor-stream.broadcast-stream-delay-ms" => Some(("contentDetails.monitorStream.broadcastStreamDelayMs", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "content-details.monitor-stream.embed-html" => Some(("contentDetails.monitorStream.embedHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.monitor-stream.enable-monitor-stream" => Some(("contentDetails.monitorStream.enableMonitorStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.bound-stream-id" => Some(("contentDetails.boundStreamId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-embed" => Some(("contentDetails.enableEmbed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.enable-closed-captions" => Some(("contentDetails.enableClosedCaptions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.start-with-slate" => Some(("contentDetails.startWithSlate", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "content-details.closed-captions-type" => Some(("contentDetails.closedCaptionsType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.bound-stream-last-update-time-ms" => Some(("contentDetails.boundStreamLastUpdateTimeMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-content-encryption" => Some(("contentDetails.enableContentEncryption", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.record-from-start" => Some(("contentDetails.recordFromStart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.enable-dvr" => Some(("contentDetails.enableDvr", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "content-details.monitor-stream.broadcast-stream-delay-ms" => Some(("contentDetails.monitorStream.broadcastStreamDelayMs", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "content-details.monitor-stream.embed-html" => Some(("contentDetails.monitorStream.embedHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "content-details.monitor-stream.enable-monitor-stream" => Some(("contentDetails.monitorStream.enableMonitorStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "content-details.projection" => Some(("contentDetails.projection", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.actual-end-time" => Some(("snippet.actualEndTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.description" => Some(("snippet.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.title" => Some(("snippet.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2586,7 +2588,7 @@ impl<'n> Engine<'n> { "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["actual-end-time", "actual-start-time", "bound-stream-id", "broadcast-stream-delay-ms", "channel-id", "closed-captions-type", "concurrent-viewers", "content-details", "default", "description", "embed-html", "enable-closed-captions", "enable-content-encryption", "enable-dvr", "enable-embed", "enable-low-latency", "enable-monitor-stream", "etag", "height", "high", "id", "is-default-broadcast", "kind", "life-cycle-status", "live-broadcast-priority", "live-chat-id", "maxres", "medium", "monitor-stream", "privacy-status", "published-at", "record-from-start", "recording-status", "scheduled-end-time", "scheduled-start-time", "snippet", "standard", "start-with-slate", "statistics", "status", "thumbnails", "title", "total-chat-count", "url", "width"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["actual-end-time", "actual-start-time", "bound-stream-id", "bound-stream-last-update-time-ms", "broadcast-stream-delay-ms", "channel-id", "closed-captions-type", "concurrent-viewers", "content-details", "default", "description", "embed-html", "enable-closed-captions", "enable-content-encryption", "enable-dvr", "enable-embed", "enable-low-latency", "enable-monitor-stream", "etag", "height", "high", "id", "is-default-broadcast", "kind", "life-cycle-status", "live-broadcast-priority", "live-chat-id", "maxres", "medium", "monitor-stream", "privacy-status", "projection", "published-at", "record-from-start", "recording-status", "scheduled-end-time", "scheduled-start-time", "snippet", "standard", "start-with-slate", "statistics", "status", "thumbnails", "title", "total-chat-count", "url", "width"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -2819,18 +2821,20 @@ impl<'n> Engine<'n> { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.concurrent-viewers" => Some(("statistics.concurrentViewers", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "statistics.total-chat-count" => Some(("statistics.totalChatCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "content-details.closed-captions-type" => Some(("contentDetails.closedCaptionsType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-low-latency" => Some(("contentDetails.enableLowLatency", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "content-details.monitor-stream.broadcast-stream-delay-ms" => Some(("contentDetails.monitorStream.broadcastStreamDelayMs", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), + "content-details.monitor-stream.embed-html" => Some(("contentDetails.monitorStream.embedHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.monitor-stream.enable-monitor-stream" => Some(("contentDetails.monitorStream.enableMonitorStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.bound-stream-id" => Some(("contentDetails.boundStreamId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-embed" => Some(("contentDetails.enableEmbed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.enable-closed-captions" => Some(("contentDetails.enableClosedCaptions", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.start-with-slate" => Some(("contentDetails.startWithSlate", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "content-details.closed-captions-type" => Some(("contentDetails.closedCaptionsType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.bound-stream-last-update-time-ms" => Some(("contentDetails.boundStreamLastUpdateTimeMs", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.enable-content-encryption" => Some(("contentDetails.enableContentEncryption", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.record-from-start" => Some(("contentDetails.recordFromStart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.enable-dvr" => Some(("contentDetails.enableDvr", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), - "content-details.monitor-stream.broadcast-stream-delay-ms" => Some(("contentDetails.monitorStream.broadcastStreamDelayMs", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), - "content-details.monitor-stream.embed-html" => Some(("contentDetails.monitorStream.embedHtml", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "content-details.monitor-stream.enable-monitor-stream" => Some(("contentDetails.monitorStream.enableMonitorStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), + "content-details.projection" => Some(("contentDetails.projection", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.actual-end-time" => Some(("snippet.actualEndTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.description" => Some(("snippet.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.title" => Some(("snippet.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -2859,7 +2863,7 @@ impl<'n> Engine<'n> { "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["actual-end-time", "actual-start-time", "bound-stream-id", "broadcast-stream-delay-ms", "channel-id", "closed-captions-type", "concurrent-viewers", "content-details", "default", "description", "embed-html", "enable-closed-captions", "enable-content-encryption", "enable-dvr", "enable-embed", "enable-low-latency", "enable-monitor-stream", "etag", "height", "high", "id", "is-default-broadcast", "kind", "life-cycle-status", "live-broadcast-priority", "live-chat-id", "maxres", "medium", "monitor-stream", "privacy-status", "published-at", "record-from-start", "recording-status", "scheduled-end-time", "scheduled-start-time", "snippet", "standard", "start-with-slate", "statistics", "status", "thumbnails", "title", "total-chat-count", "url", "width"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["actual-end-time", "actual-start-time", "bound-stream-id", "bound-stream-last-update-time-ms", "broadcast-stream-delay-ms", "channel-id", "closed-captions-type", "concurrent-viewers", "content-details", "default", "description", "embed-html", "enable-closed-captions", "enable-content-encryption", "enable-dvr", "enable-embed", "enable-low-latency", "enable-monitor-stream", "etag", "height", "high", "id", "is-default-broadcast", "kind", "life-cycle-status", "live-broadcast-priority", "live-chat-id", "maxres", "medium", "monitor-stream", "privacy-status", "projection", "published-at", "record-from-start", "recording-status", "scheduled-end-time", "scheduled-start-time", "snippet", "standard", "start-with-slate", "statistics", "status", "thumbnails", "title", "total-chat-count", "url", "width"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3132,16 +3136,31 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { "snippet.display-message" => Some(("snippet.displayMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.message-retracted-details.retracted-message-id" => Some(("snippet.messageRetractedDetails.retractedMessageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.fan-funding-event-details.currency" => Some(("snippet.fanFundingEventDetails.currency", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.fan-funding-event-details.amount-display-string" => Some(("snippet.fanFundingEventDetails.amountDisplayString", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.fan-funding-event-details.user-comment" => Some(("snippet.fanFundingEventDetails.userComment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.fan-funding-event-details.amount-micros" => Some(("snippet.fanFundingEventDetails.amountMicros", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.has-display-content" => Some(("snippet.hasDisplayContent", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "snippet.published-at" => Some(("snippet.publishedAt", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.ban-duration-seconds" => Some(("snippet.userBannedDetails.banDurationSeconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.banned-user-details.channel-id" => Some(("snippet.userBannedDetails.bannedUserDetails.channelId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.banned-user-details.display-name" => Some(("snippet.userBannedDetails.bannedUserDetails.displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.banned-user-details.profile-image-url" => Some(("snippet.userBannedDetails.bannedUserDetails.profileImageUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.banned-user-details.channel-url" => Some(("snippet.userBannedDetails.bannedUserDetails.channelUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.user-banned-details.ban-type" => Some(("snippet.userBannedDetails.banType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.live-chat-id" => Some(("snippet.liveChatId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.author-channel-id" => Some(("snippet.authorChannelId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-edited-details.prompt" => Some(("snippet.pollEditedDetails.prompt", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-edited-details.id" => Some(("snippet.pollEditedDetails.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.text-message-details.message-text" => Some(("snippet.textMessageDetails.messageText", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.message-deleted-details.deleted-message-id" => Some(("snippet.messageDeletedDetails.deletedMessageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-voted-details.item-id" => Some(("snippet.pollVotedDetails.itemId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-voted-details.poll-id" => Some(("snippet.pollVotedDetails.pollId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-opened-details.prompt" => Some(("snippet.pollOpenedDetails.prompt", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-opened-details.id" => Some(("snippet.pollOpenedDetails.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.type" => Some(("snippet.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "snippet.poll-closed-details.poll-id" => Some(("snippet.pollClosedDetails.pollId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "author-details.display-name" => Some(("authorDetails.displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -3154,7 +3173,7 @@ impl<'n> Engine<'n> { "author-details.channel-url" => Some(("authorDetails.channelUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["amount-display-string", "amount-micros", "author-channel-id", "author-details", "channel-id", "channel-url", "currency", "display-message", "display-name", "etag", "fan-funding-event-details", "has-display-content", "id", "is-chat-moderator", "is-chat-owner", "is-chat-sponsor", "is-verified", "kind", "live-chat-id", "message-text", "profile-image-url", "published-at", "snippet", "text-message-details", "type", "user-comment"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["amount-display-string", "amount-micros", "author-channel-id", "author-details", "ban-duration-seconds", "ban-type", "banned-user-details", "channel-id", "channel-url", "currency", "deleted-message-id", "display-message", "display-name", "etag", "fan-funding-event-details", "has-display-content", "id", "is-chat-moderator", "is-chat-owner", "is-chat-sponsor", "is-verified", "item-id", "kind", "live-chat-id", "message-deleted-details", "message-retracted-details", "message-text", "poll-closed-details", "poll-edited-details", "poll-id", "poll-opened-details", "poll-voted-details", "profile-image-url", "prompt", "published-at", "retracted-message-id", "snippet", "text-message-details", "type", "user-banned-details", "user-comment"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3554,10 +3573,12 @@ impl<'n> Engine<'n> { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.is-reusable" => Some(("contentDetails.isReusable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.closed-captions-ingestion-url" => Some(("contentDetails.closedCaptionsIngestionUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cdn.frame-rate" => Some(("cdn.frameRate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-type" => Some(("cdn.ingestionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.backup-ingestion-address" => Some(("cdn.ingestionInfo.backupIngestionAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.stream-name" => Some(("cdn.ingestionInfo.streamName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.ingestion-address" => Some(("cdn.ingestionInfo.ingestionAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cdn.resolution" => Some(("cdn.resolution", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.format" => Some(("cdn.format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.is-default-stream" => Some(("snippet.isDefaultStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "snippet.channel-id" => Some(("snippet.channelId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -3567,7 +3588,7 @@ impl<'n> Engine<'n> { "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-ingestion-address", "cdn", "channel-id", "closed-captions-ingestion-url", "content-details", "description", "etag", "format", "health-status", "id", "ingestion-address", "ingestion-info", "ingestion-type", "is-default-stream", "is-reusable", "kind", "last-update-time-seconds", "published-at", "snippet", "status", "stream-name", "stream-status", "title"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-ingestion-address", "cdn", "channel-id", "closed-captions-ingestion-url", "content-details", "description", "etag", "format", "frame-rate", "health-status", "id", "ingestion-address", "ingestion-info", "ingestion-type", "is-default-stream", "is-reusable", "kind", "last-update-time-seconds", "published-at", "resolution", "snippet", "status", "stream-name", "stream-status", "title"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -3734,10 +3755,12 @@ impl<'n> Engine<'n> { "kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.is-reusable" => Some(("contentDetails.isReusable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.closed-captions-ingestion-url" => Some(("contentDetails.closedCaptionsIngestionUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cdn.frame-rate" => Some(("cdn.frameRate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-type" => Some(("cdn.ingestionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.backup-ingestion-address" => Some(("cdn.ingestionInfo.backupIngestionAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.stream-name" => Some(("cdn.ingestionInfo.streamName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.ingestion-info.ingestion-address" => Some(("cdn.ingestionInfo.ingestionAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "cdn.resolution" => Some(("cdn.resolution", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "cdn.format" => Some(("cdn.format", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "snippet.is-default-stream" => Some(("snippet.isDefaultStream", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "snippet.channel-id" => Some(("snippet.channelId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -3747,7 +3770,7 @@ impl<'n> Engine<'n> { "etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-ingestion-address", "cdn", "channel-id", "closed-captions-ingestion-url", "content-details", "description", "etag", "format", "health-status", "id", "ingestion-address", "ingestion-info", "ingestion-type", "is-default-stream", "is-reusable", "kind", "last-update-time-seconds", "published-at", "snippet", "status", "stream-name", "stream-status", "title"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-ingestion-address", "cdn", "channel-id", "closed-captions-ingestion-url", "content-details", "description", "etag", "format", "frame-rate", "health-status", "id", "ingestion-address", "ingestion-info", "ingestion-type", "is-default-stream", "is-reusable", "kind", "last-update-time-seconds", "published-at", "resolution", "snippet", "status", "stream-name", "stream-status", "title"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -4935,6 +4958,9 @@ impl<'n> Engine<'n> { "my-subscribers" => { call = call.my_subscribers(arg_from_str(value.unwrap_or("false"), err, "my-subscribers", "boolean")); }, + "my-recent-subscribers" => { + call = call.my_recent_subscribers(arg_from_str(value.unwrap_or("false"), err, "my-recent-subscribers", "boolean")); + }, "mine" => { call = call.mine(arg_from_str(value.unwrap_or("false"), err, "mine", "boolean")); }, @@ -4963,7 +4989,7 @@ impl<'n> Engine<'n> { err.issues.push(CLIError::UnknownParameter(key.to_string(), {let mut v = Vec::new(); v.extend(self.gp.iter().map(|v|*v)); - v.extend(["on-behalf-of-content-owner", "on-behalf-of-content-owner-channel", "channel-id", "mine", "max-results", "id", "page-token", "my-subscribers", "for-channel-id", "order"].iter().map(|v|*v)); + v.extend(["on-behalf-of-content-owner", "on-behalf-of-content-owner-channel", "channel-id", "mine", "max-results", "id", "page-token", "my-subscribers", "for-channel-id", "order", "my-recent-subscribers"].iter().map(|v|*v)); v } )); } } @@ -5319,6 +5345,7 @@ impl<'n> Engine<'n> { "statistics.dislike-count" => Some(("statistics.dislikeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "statistics.like-count" => Some(("statistics.likeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "content-details.definition" => Some(("contentDetails.definition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.projection" => Some(("contentDetails.projection", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.country-restriction.exception" => Some(("contentDetails.countryRestriction.exception", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "content-details.country-restriction.allowed" => Some(("contentDetails.countryRestriction.allowed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.content-rating.yt-rating" => Some(("contentDetails.contentRating.ytRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -5375,6 +5402,7 @@ impl<'n> Engine<'n> { "content-details.content-rating.russia-rating" => Some(("contentDetails.contentRating.russiaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.mpaa-rating" => Some(("contentDetails.contentRating.mpaaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.kfcb-rating" => Some(("contentDetails.contentRating.kfcbRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.content-rating.fpb-rating-reasons" => Some(("contentDetails.contentRating.fpbRatingReasons", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "content-details.content-rating.agcom-rating" => Some(("contentDetails.contentRating.agcomRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.chvrs-rating" => Some(("contentDetails.contentRating.chvrsRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.cna-rating" => Some(("contentDetails.contentRating.cnaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -5465,7 +5493,7 @@ impl<'n> Engine<'n> { "recording-details.location.longitude" => Some(("recordingDetails.location.longitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["acb-rating", "access", "active-live-chat-id", "actual-end-time", "actual-start-time", "agcom-rating", "age-gating", "alcohol-content", "allowed", "altitude", "anatel-rating", "bbfc-rating", "bfvc-rating", "bitrate-bps", "blocked", "bmukk-rating", "caption", "category-id", "catv-rating", "catvfr-rating", "cbfc-rating", "ccc-rating", "cce-rating", "channel-id", "channel-title", "chfilm-rating", "chvrs-rating", "cicf-rating", "cna-rating", "cnc-rating", "comment-count", "concurrent-viewers", "container", "content-details", "content-rating", "country-restriction", "creation-time", "csa-rating", "cscf-rating", "czfilm-rating", "default", "default-audio-language", "default-language", "definition", "description", "dimension", "dislike-count", "djctq-rating", "djctq-rating-reasons", "duration", "duration-ms", "ecbmct-rating", "editor-suggestions", "editor-suggestions-availability", "eefilm-rating", "egfilm-rating", "eirin-rating", "embed-html", "embeddable", "etag", "exception", "failure-reason", "favorite-count", "fcbm-rating", "fco-rating", "file-details", "file-details-availability", "file-name", "file-size", "file-type", "fmoc-rating", "fpb-rating", "fsk-rating", "grfilm-rating", "height", "high", "icaa-rating", "id", "ifco-rating", "ilfilm-rating", "incaa-rating", "kfcb-rating", "kijkwijzer-rating", "kind", "kmrb-rating", "latitude", "license", "licensed-content", "like-count", "live-broadcast-content", "live-streaming-details", "localized", "location", "location-description", "longitude", "lsf-rating", "maxres", "mccaa-rating", "mccyp-rating", "mda-rating", "medietilsynet-rating", "medium", "meku-rating", "mibac-rating", "moc-rating", "moctw-rating", "monetization-details", "mpaa-rating", "mtrcb-rating", "nbc-rating", "nbcpl-rating", "nfrc-rating", "nfvcb-rating", "nkclv-rating", "oflc-rating", "parts-processed", "parts-total", "pefilm-rating", "player", "privacy-status", "processing-details", "processing-errors", "processing-failure-reason", "processing-hints", "processing-issues-availability", "processing-progress", "processing-status", "processing-warnings", "project-details", "public-stats-viewable", "publish-at", "published-at", "rcnof-rating", "recording-date", "recording-details", "recording-location", "region-restriction", "rejection-reason", "relevant-topic-ids", "resorteviolencia-rating", "restricted", "rtc-rating", "rte-rating", "russia-rating", "scheduled-end-time", "scheduled-start-time", "skfilm-rating", "smais-rating", "smsa-rating", "snippet", "standard", "statistics", "status", "suggestions", "tag-suggestions-availability", "tags", "thumbnails", "thumbnails-availability", "time-left-ms", "title", "topic-details", "topic-ids", "tvpg-rating", "upload-status", "url", "video-game-rating", "view-count", "width", "yt-rating"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["acb-rating", "access", "active-live-chat-id", "actual-end-time", "actual-start-time", "agcom-rating", "age-gating", "alcohol-content", "allowed", "altitude", "anatel-rating", "bbfc-rating", "bfvc-rating", "bitrate-bps", "blocked", "bmukk-rating", "caption", "category-id", "catv-rating", "catvfr-rating", "cbfc-rating", "ccc-rating", "cce-rating", "channel-id", "channel-title", "chfilm-rating", "chvrs-rating", "cicf-rating", "cna-rating", "cnc-rating", "comment-count", "concurrent-viewers", "container", "content-details", "content-rating", "country-restriction", "creation-time", "csa-rating", "cscf-rating", "czfilm-rating", "default", "default-audio-language", "default-language", "definition", "description", "dimension", "dislike-count", "djctq-rating", "djctq-rating-reasons", "duration", "duration-ms", "ecbmct-rating", "editor-suggestions", "editor-suggestions-availability", "eefilm-rating", "egfilm-rating", "eirin-rating", "embed-html", "embeddable", "etag", "exception", "failure-reason", "favorite-count", "fcbm-rating", "fco-rating", "file-details", "file-details-availability", "file-name", "file-size", "file-type", "fmoc-rating", "fpb-rating", "fpb-rating-reasons", "fsk-rating", "grfilm-rating", "height", "high", "icaa-rating", "id", "ifco-rating", "ilfilm-rating", "incaa-rating", "kfcb-rating", "kijkwijzer-rating", "kind", "kmrb-rating", "latitude", "license", "licensed-content", "like-count", "live-broadcast-content", "live-streaming-details", "localized", "location", "location-description", "longitude", "lsf-rating", "maxres", "mccaa-rating", "mccyp-rating", "mda-rating", "medietilsynet-rating", "medium", "meku-rating", "mibac-rating", "moc-rating", "moctw-rating", "monetization-details", "mpaa-rating", "mtrcb-rating", "nbc-rating", "nbcpl-rating", "nfrc-rating", "nfvcb-rating", "nkclv-rating", "oflc-rating", "parts-processed", "parts-total", "pefilm-rating", "player", "privacy-status", "processing-details", "processing-errors", "processing-failure-reason", "processing-hints", "processing-issues-availability", "processing-progress", "processing-status", "processing-warnings", "project-details", "projection", "public-stats-viewable", "publish-at", "published-at", "rcnof-rating", "recording-date", "recording-details", "recording-location", "region-restriction", "rejection-reason", "relevant-topic-ids", "resorteviolencia-rating", "restricted", "rtc-rating", "rte-rating", "russia-rating", "scheduled-end-time", "scheduled-start-time", "skfilm-rating", "smais-rating", "smsa-rating", "snippet", "standard", "statistics", "status", "suggestions", "tag-suggestions-availability", "tags", "thumbnails", "thumbnails-availability", "time-left-ms", "title", "topic-details", "topic-ids", "tvpg-rating", "upload-status", "url", "video-game-rating", "view-count", "width", "yt-rating"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -5797,6 +5825,7 @@ impl<'n> Engine<'n> { "statistics.dislike-count" => Some(("statistics.dislikeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "statistics.like-count" => Some(("statistics.likeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })), "content-details.definition" => Some(("contentDetails.definition", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.projection" => Some(("contentDetails.projection", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.country-restriction.exception" => Some(("contentDetails.countryRestriction.exception", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "content-details.country-restriction.allowed" => Some(("contentDetails.countryRestriction.allowed", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "content-details.content-rating.yt-rating" => Some(("contentDetails.contentRating.ytRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -5853,6 +5882,7 @@ impl<'n> Engine<'n> { "content-details.content-rating.russia-rating" => Some(("contentDetails.contentRating.russiaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.mpaa-rating" => Some(("contentDetails.contentRating.mpaaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.kfcb-rating" => Some(("contentDetails.contentRating.kfcbRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "content-details.content-rating.fpb-rating-reasons" => Some(("contentDetails.contentRating.fpbRatingReasons", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })), "content-details.content-rating.agcom-rating" => Some(("contentDetails.contentRating.agcomRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.chvrs-rating" => Some(("contentDetails.contentRating.chvrsRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "content-details.content-rating.cna-rating" => Some(("contentDetails.contentRating.cnaRating", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), @@ -5943,7 +5973,7 @@ impl<'n> Engine<'n> { "recording-details.location.longitude" => Some(("recordingDetails.location.longitude", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), _ => { - let suggestion = FieldCursor::did_you_mean(key, &vec!["acb-rating", "access", "active-live-chat-id", "actual-end-time", "actual-start-time", "agcom-rating", "age-gating", "alcohol-content", "allowed", "altitude", "anatel-rating", "bbfc-rating", "bfvc-rating", "bitrate-bps", "blocked", "bmukk-rating", "caption", "category-id", "catv-rating", "catvfr-rating", "cbfc-rating", "ccc-rating", "cce-rating", "channel-id", "channel-title", "chfilm-rating", "chvrs-rating", "cicf-rating", "cna-rating", "cnc-rating", "comment-count", "concurrent-viewers", "container", "content-details", "content-rating", "country-restriction", "creation-time", "csa-rating", "cscf-rating", "czfilm-rating", "default", "default-audio-language", "default-language", "definition", "description", "dimension", "dislike-count", "djctq-rating", "djctq-rating-reasons", "duration", "duration-ms", "ecbmct-rating", "editor-suggestions", "editor-suggestions-availability", "eefilm-rating", "egfilm-rating", "eirin-rating", "embed-html", "embeddable", "etag", "exception", "failure-reason", "favorite-count", "fcbm-rating", "fco-rating", "file-details", "file-details-availability", "file-name", "file-size", "file-type", "fmoc-rating", "fpb-rating", "fsk-rating", "grfilm-rating", "height", "high", "icaa-rating", "id", "ifco-rating", "ilfilm-rating", "incaa-rating", "kfcb-rating", "kijkwijzer-rating", "kind", "kmrb-rating", "latitude", "license", "licensed-content", "like-count", "live-broadcast-content", "live-streaming-details", "localized", "location", "location-description", "longitude", "lsf-rating", "maxres", "mccaa-rating", "mccyp-rating", "mda-rating", "medietilsynet-rating", "medium", "meku-rating", "mibac-rating", "moc-rating", "moctw-rating", "monetization-details", "mpaa-rating", "mtrcb-rating", "nbc-rating", "nbcpl-rating", "nfrc-rating", "nfvcb-rating", "nkclv-rating", "oflc-rating", "parts-processed", "parts-total", "pefilm-rating", "player", "privacy-status", "processing-details", "processing-errors", "processing-failure-reason", "processing-hints", "processing-issues-availability", "processing-progress", "processing-status", "processing-warnings", "project-details", "public-stats-viewable", "publish-at", "published-at", "rcnof-rating", "recording-date", "recording-details", "recording-location", "region-restriction", "rejection-reason", "relevant-topic-ids", "resorteviolencia-rating", "restricted", "rtc-rating", "rte-rating", "russia-rating", "scheduled-end-time", "scheduled-start-time", "skfilm-rating", "smais-rating", "smsa-rating", "snippet", "standard", "statistics", "status", "suggestions", "tag-suggestions-availability", "tags", "thumbnails", "thumbnails-availability", "time-left-ms", "title", "topic-details", "topic-ids", "tvpg-rating", "upload-status", "url", "video-game-rating", "view-count", "width", "yt-rating"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["acb-rating", "access", "active-live-chat-id", "actual-end-time", "actual-start-time", "agcom-rating", "age-gating", "alcohol-content", "allowed", "altitude", "anatel-rating", "bbfc-rating", "bfvc-rating", "bitrate-bps", "blocked", "bmukk-rating", "caption", "category-id", "catv-rating", "catvfr-rating", "cbfc-rating", "ccc-rating", "cce-rating", "channel-id", "channel-title", "chfilm-rating", "chvrs-rating", "cicf-rating", "cna-rating", "cnc-rating", "comment-count", "concurrent-viewers", "container", "content-details", "content-rating", "country-restriction", "creation-time", "csa-rating", "cscf-rating", "czfilm-rating", "default", "default-audio-language", "default-language", "definition", "description", "dimension", "dislike-count", "djctq-rating", "djctq-rating-reasons", "duration", "duration-ms", "ecbmct-rating", "editor-suggestions", "editor-suggestions-availability", "eefilm-rating", "egfilm-rating", "eirin-rating", "embed-html", "embeddable", "etag", "exception", "failure-reason", "favorite-count", "fcbm-rating", "fco-rating", "file-details", "file-details-availability", "file-name", "file-size", "file-type", "fmoc-rating", "fpb-rating", "fpb-rating-reasons", "fsk-rating", "grfilm-rating", "height", "high", "icaa-rating", "id", "ifco-rating", "ilfilm-rating", "incaa-rating", "kfcb-rating", "kijkwijzer-rating", "kind", "kmrb-rating", "latitude", "license", "licensed-content", "like-count", "live-broadcast-content", "live-streaming-details", "localized", "location", "location-description", "longitude", "lsf-rating", "maxres", "mccaa-rating", "mccyp-rating", "mda-rating", "medietilsynet-rating", "medium", "meku-rating", "mibac-rating", "moc-rating", "moctw-rating", "monetization-details", "mpaa-rating", "mtrcb-rating", "nbc-rating", "nbcpl-rating", "nfrc-rating", "nfvcb-rating", "nkclv-rating", "oflc-rating", "parts-processed", "parts-total", "pefilm-rating", "player", "privacy-status", "processing-details", "processing-errors", "processing-failure-reason", "processing-hints", "processing-issues-availability", "processing-progress", "processing-status", "processing-warnings", "project-details", "projection", "public-stats-viewable", "publish-at", "published-at", "rcnof-rating", "recording-date", "recording-details", "recording-location", "region-restriction", "rejection-reason", "relevant-topic-ids", "resorteviolencia-rating", "restricted", "rtc-rating", "rte-rating", "russia-rating", "scheduled-end-time", "scheduled-start-time", "skfilm-rating", "smais-rating", "smsa-rating", "snippet", "standard", "statistics", "status", "suggestions", "tag-suggestions-availability", "tags", "thumbnails", "thumbnails-availability", "time-left-ms", "title", "topic-details", "topic-ids", "tvpg-rating", "upload-status", "url", "video-game-rating", "view-count", "width", "yt-rating"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -8322,8 +8352,8 @@ fn main() { let mut app = App::new("youtube3") .author("Sebastian Thiel ") - .version("0.3.6+20160222") - .about("Programmatic access to YouTube features.") + .version("0.3.6+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") .long("scope") diff --git a/gen/youtube3/Cargo.toml b/gen/youtube3/Cargo.toml index f3ee3b6bf3..e8a184d385 100644 --- a/gen/youtube3/Cargo.toml +++ b/gen/youtube3/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtube3" -version = "0.1.14+20160222" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/youtube3/README.md b/gen/youtube3/README.md index 22adf037ae..bb6e858105 100644 --- a/gen/youtube3/README.md +++ b/gen/youtube3/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-youtube3` library allows access to all features of the *Google YouTube* service. -This documentation was generated from *YouTube* crate version *0.1.14+20160222*, where *20160222* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *YouTube* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *YouTube* *v3* API can be found at the [official documentation site](https://developers.google.com/youtube/v3). diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index 7d69ff34cb..5ee9a908f9 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *YouTube* crate version *0.1.14+20160222*, where *20160222* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *YouTube* crate version *0.1.14+20160805*, where *20160805* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *YouTube* *v3* API can be found at the //! [official documentation site](https://developers.google.com/youtube/v3). @@ -167,16 +167,16 @@ //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.videos().list("part") -//! .video_category_id("sit") -//! .region_code("amet") -//! .page_token("eirmod") -//! .on_behalf_of_content_owner("sanctus") -//! .my_rating("Lorem") -//! .max_results(100) -//! .locale("diam") -//! .id("eirmod") -//! .hl("sadipscing") -//! .chart("Lorem") +//! .video_category_id("amet") +//! .region_code("eirmod") +//! .page_token("sanctus") +//! .on_behalf_of_content_owner("Lorem") +//! .my_rating("amet.") +//! .max_results(60) +//! .locale("eirmod") +//! .id("sadipscing") +//! .hl("Lorem") +//! .chart("sed") //! .doit(); //! //! match result { diff --git a/gen/youtube3/src/lib.rs.in b/gen/youtube3/src/lib.rs.in index 6c27f77021..0e761f9d8d 100644 --- a/gen/youtube3/src/lib.rs.in +++ b/gen/youtube3/src/lib.rs.in @@ -510,17 +510,39 @@ pub struct ChannelSettings { impl Part for ChannelSettings {} +/// 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 LiveChatPollEditedDetails { + /// no description provided + pub items: Option>, + /// no description provided + pub prompt: Option, + /// no description provided + pub id: Option, +} + +impl Part for LiveChatPollEditedDetails {} + + /// Brief description of the live stream cdn settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CdnSettings { + /// The resolution of the inbound video data. + pub resolution: Option, /// The format of the video stream that you are sending to Youtube. pub format: Option, /// The ingestionInfo object contains information that YouTube provides that you need to transmit your RTMP or HTTP stream to YouTube. #[serde(rename="ingestionInfo")] pub ingestion_info: Option, + /// The frame rate of the inbound video data. + #[serde(rename="frameRate")] + pub frame_rate: Option, /// The method or protocol used to transmit the video stream. #[serde(rename="ingestionType")] pub ingestion_type: Option, @@ -531,30 +553,16 @@ impl Part for CdnSettings {} /// 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 rating videos](struct.VideoGetRatingCall.html) (response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct VideoGetRatingResponse { - /// Serialized EventId of the request which produced this response. - #[serde(rename="eventId")] - pub event_id: Option, - /// A list of ratings that match the request criteria. - pub items: Option>, - /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoGetRatingResponse". - pub kind: Option, - /// Etag of this resource. - pub etag: Option, - /// The visitorId identifies the visitor. - #[serde(rename="visitorId")] - pub visitor_id: Option, +pub struct LiveChatMessageDeletedDetails { + /// no description provided + #[serde(rename="deletedMessageId")] + pub deleted_message_id: Option, } -impl ResponseResult for VideoGetRatingResponse {} +impl Part for LiveChatMessageDeletedDetails {} /// There is no detailed description. @@ -1297,6 +1305,20 @@ pub struct CaptionSnippet { impl Part for CaptionSnippet {} +/// 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 LiveChatMessageRetractedDetails { + /// no description provided + #[serde(rename="retractedMessageId")] + pub retracted_message_id: Option, +} + +impl Part for LiveChatMessageRetractedDetails {} + + /// There is no detailed description. /// /// # Activities @@ -1481,6 +1503,9 @@ pub struct LiveChatMessageSnippet { /// Contains a string that can be displayed to the user. If this field is not present the message is silent, at the moment only messages of type TOMBSTONE and CHAT_ENDED_EVENT are silent. #[serde(rename="displayMessage")] pub display_message: Option, + /// no description provided + #[serde(rename="messageRetractedDetails")] + pub message_retracted_details: Option, /// Details about the funding event, this is only set if the type is 'fanFundingEvent'. #[serde(rename="fanFundingEventDetails")] pub fan_funding_event_details: Option, @@ -1491,17 +1516,35 @@ pub struct LiveChatMessageSnippet { #[serde(rename="publishedAt")] pub published_at: Option, /// no description provided + #[serde(rename="userBannedDetails")] + pub user_banned_details: Option, + /// no description provided #[serde(rename="liveChatId")] pub live_chat_id: Option, - /// The ID of the user that authored this message, this field is not always filled. textMessageEvent - the user that wrote the message fanFundingEvent - the user that funded the broadcast newSponsorEvent - the user that just became a sponsor + /// The ID of the user that authored this message, this field is not always filled. textMessageEvent - the user that wrote the message fanFundingEvent - the user that funded the broadcast newSponsorEvent - the user that just became a sponsor messageDeletedEvent - the moderator that took the action messageRetractedEvent - the author that retracted their message userBannedEvent - the moderator that took the action #[serde(rename="authorChannelId")] pub author_channel_id: Option, + /// no description provided + #[serde(rename="pollEditedDetails")] + pub poll_edited_details: Option, /// Details about the text message, this is only set if the type is 'textMessageEvent'. #[serde(rename="textMessageDetails")] pub text_message_details: Option, + /// no description provided + #[serde(rename="messageDeletedDetails")] + pub message_deleted_details: Option, + /// no description provided + #[serde(rename="pollVotedDetails")] + pub poll_voted_details: Option, + /// no description provided + #[serde(rename="pollOpenedDetails")] + pub poll_opened_details: Option, /// The type of message, this will always be present, it determines the contents of the message as well as which fields will be present. #[serde(rename="type")] pub type_: Option, + /// no description provided + #[serde(rename="pollClosedDetails")] + pub poll_closed_details: Option, } impl Part for LiveChatMessageSnippet {} @@ -2353,7 +2396,7 @@ pub struct LiveStreamStatus { impl Part for LiveStreamStatus {} -/// Ratings schemes. The country-specific ratings are mostly for movies and shows. NEXT_ID: 67 +/// Ratings schemes. The country-specific ratings are mostly for movies and shows. NEXT_ID: 68 /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -2539,6 +2582,9 @@ pub struct ContentRating { /// The video's Anatel (Asociación Nacional de Televisión) rating for Chilean television. #[serde(rename="anatelRating")] pub anatel_rating: Option, + /// Reasons that explain why the video received its FPB (South Africa) rating. + #[serde(rename="fpbRatingReasons")] + pub fpb_rating_reasons: Option>, /// The video's rating from Statens medieråd (Sweden's National Media Council). #[serde(rename="smsaRating")] pub smsa_rating: Option, @@ -2860,6 +2906,23 @@ pub struct IngestionInfo { impl Part for IngestionInfo {} +/// 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 LiveChatPollOpenedDetails { + /// no description provided + pub items: Option>, + /// no description provided + pub prompt: Option, + /// no description provided + pub id: Option, +} + +impl Part for LiveChatPollOpenedDetails {} + + /// A videoCategory resource identifies a category that has been or could be associated with uploaded videos. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3011,6 +3074,26 @@ pub struct ActivityContentDetailsLike { impl Part for ActivityContentDetailsLike {} +/// 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 LiveChatUserBannedMessageDetails { + /// The duration of the ban. This property is only present if the banType is temporary. + #[serde(rename="banDurationSeconds")] + pub ban_duration_seconds: Option, + /// The type of ban. + #[serde(rename="banType")] + pub ban_type: Option, + /// The details of the user that was banned. + #[serde(rename="bannedUserDetails")] + pub banned_user_details: Option, +} + +impl Part for LiveChatUserBannedMessageDetails {} + + /// A playlist resource represents a YouTube playlist. A playlist is a collection of videos that can be viewed sequentially and shared with other users. A playlist can contain up to 200 videos, and YouTube does not limit the number of playlists that each user creates. By default, playlists are publicly visible to other users, but playlists can be public or private. /// /// YouTube also uses playlists to identify special collections of videos for a channel, such as: @@ -3463,6 +3546,20 @@ pub struct ChannelBrandingSettings { impl Part for ChannelBrandingSettings {} +/// 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 LiveChatPollClosedDetails { + /// The id of the poll that was closed. + #[serde(rename="pollId")] + pub poll_id: Option, +} + +impl Part for LiveChatPollClosedDetails {} + + /// There is no detailed description. /// /// # Activities @@ -3823,40 +3920,20 @@ pub struct LiveChatModeratorSnippet { impl Part for LiveChatModeratorSnippet {} -/// Details about the content of an activity: the video that was shared, the channel that was subscribed to, etc. +/// 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 ActivityContentDetails { - /// The comment object contains information about a resource that received a comment. This property is only present if the snippet.type is comment. - pub comment: Option, - /// The playlistItem object contains information about a new playlist item. This property is only present if the snippet.type is playlistItem. - #[serde(rename="playlistItem")] - pub playlist_item: Option, - /// The like object contains information about a resource that received a positive (like) rating. This property is only present if the snippet.type is like. - pub like: Option, - /// The promotedItem object contains details about a resource which is being promoted. This property is only present if the snippet.type is promotedItem. - #[serde(rename="promotedItem")] - pub promoted_item: Option, - /// The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation. - pub recommendation: Option, - /// The favorite object contains information about a video that was marked as a favorite video. This property is only present if the snippet.type is favorite. - pub favorite: Option, - /// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload. - pub upload: Option, - /// The social object contains details about a social network post. This property is only present if the snippet.type is social. - pub social: Option, - /// The channelItem object contains details about a resource which was added to a channel. This property is only present if the snippet.type is channelItem. - #[serde(rename="channelItem")] - pub channel_item: Option, - /// The bulletin object contains details about a channel bulletin post. This object is only present if the snippet.type is bulletin. - pub bulletin: Option, - /// The subscription object contains information about a channel that a user subscribed to. This property is only present if the snippet.type is subscription. - pub subscription: Option, +pub struct LiveChatPollItem { + /// no description provided + #[serde(rename="itemId")] + pub item_id: Option, + /// Plain text description of the item. + pub description: Option, } -impl Part for ActivityContentDetails {} +impl Part for LiveChatPollItem {} /// There is no detailed description. @@ -4001,7 +4078,7 @@ pub struct ChannelSnippet { impl Part for ChannelSnippet {} -/// Branding properties for the watch. +/// Branding properties for the watch. All deprecated. /// /// This type is not used in any activity, and only used as *part* of another schema. /// @@ -4021,6 +4098,34 @@ pub struct WatchSettings { impl Part for WatchSettings {} +/// 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 rating videos](struct.VideoGetRatingCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VideoGetRatingResponse { + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + pub event_id: Option, + /// A list of ratings that match the request criteria. + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoGetRatingResponse". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + pub visitor_id: Option, +} + +impl ResponseResult for VideoGetRatingResponse {} + + /// A video resource represents a YouTube video. /// /// # Activities @@ -4128,6 +4233,8 @@ impl ToParts for Video { pub struct VideoContentDetails { /// The value of definition indicates whether the video is available in high definition or only in standard definition. pub definition: Option, + /// Specifies the projection format of the video. + pub projection: Option, /// The countryRestriction object contains information about the countries where a video is (or is not) viewable. #[serde(rename="countryRestriction")] pub country_restriction: Option, @@ -5136,6 +5243,42 @@ pub struct LiveBroadcastSnippet { impl Part for LiveBroadcastSnippet {} +/// Details about the content of an activity: the video that was shared, the channel that was subscribed to, etc. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetails { + /// The comment object contains information about a resource that received a comment. This property is only present if the snippet.type is comment. + pub comment: Option, + /// The playlistItem object contains information about a new playlist item. This property is only present if the snippet.type is playlistItem. + #[serde(rename="playlistItem")] + pub playlist_item: Option, + /// The like object contains information about a resource that received a positive (like) rating. This property is only present if the snippet.type is like. + pub like: Option, + /// The promotedItem object contains details about a resource which is being promoted. This property is only present if the snippet.type is promotedItem. + #[serde(rename="promotedItem")] + pub promoted_item: Option, + /// The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation. + pub recommendation: Option, + /// The favorite object contains information about a video that was marked as a favorite video. This property is only present if the snippet.type is favorite. + pub favorite: Option, + /// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload. + pub upload: Option, + /// The social object contains details about a social network post. This property is only present if the snippet.type is social. + pub social: Option, + /// The channelItem object contains details about a resource which was added to a channel. This property is only present if the snippet.type is channelItem. + #[serde(rename="channelItem")] + pub channel_item: Option, + /// The bulletin object contains details about a channel bulletin post. This object is only present if the snippet.type is bulletin. + pub bulletin: Option, + /// The subscription object contains information about a channel that a user subscribed to. This property is only present if the snippet.type is subscription. + pub subscription: Option, +} + +impl Part for ActivityContentDetails {} + + /// Basic details about a comment thread. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -5171,12 +5314,11 @@ impl Part for CommentThreadSnippet {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LiveBroadcastContentDetails { - /// Indicates whether this broadcast has low latency enabled. - #[serde(rename="enableLowLatency")] - pub enable_low_latency: Option, - /// The monitorStream object contains information about the monitor stream, which the broadcaster can use to review the event content before the broadcast stream is shown publicly. - #[serde(rename="monitorStream")] - pub monitor_stream: Option, + /// The date and time that the live stream referenced by boundStreamId was last updated. + #[serde(rename="boundStreamLastUpdateTimeMs")] + pub bound_stream_last_update_time_ms: Option, + /// The projection format of this broadcast. This defaults to rectangular. + pub projection: Option, /// This value uniquely identifies the live stream bound to the broadcast. #[serde(rename="boundStreamId")] pub bound_stream_id: Option, @@ -5186,6 +5328,12 @@ pub struct LiveBroadcastContentDetails { /// This setting indicates whether HTTP POST closed captioning is enabled for this broadcast. The ingestion URL of the closed captions is returned through the liveStreams API. This is mutually exclusive with using the closed_captions_type property, and is equivalent to setting closed_captions_type to CLOSED_CAPTIONS_HTTP_POST. #[serde(rename="enableClosedCaptions")] pub enable_closed_captions: Option, + /// Indicates whether this broadcast has low latency enabled. + #[serde(rename="enableLowLatency")] + pub enable_low_latency: Option, + /// This setting indicates whether the broadcast should automatically begin with an in-stream slate when you update the broadcast's status to live. After updating the status, you then need to send a liveCuepoints.insert request that sets the cuepoint's eventState to end to remove the in-stream slate and make your broadcast stream visible to viewers. + #[serde(rename="startWithSlate")] + pub start_with_slate: Option, /// no description provided #[serde(rename="closedCaptionsType")] pub closed_captions_type: Option, @@ -5206,9 +5354,9 @@ pub struct LiveBroadcastContentDetails { /// Important: You must set the value to true and also set the enableArchive property's value to true if you want to make playback available immediately after the broadcast ends. #[serde(rename="enableDvr")] pub enable_dvr: Option, - /// This setting indicates whether the broadcast should automatically begin with an in-stream slate when you update the broadcast's status to live. After updating the status, you then need to send a liveCuepoints.insert request that sets the cuepoint's eventState to end to remove the in-stream slate and make your broadcast stream visible to viewers. - #[serde(rename="startWithSlate")] - pub start_with_slate: Option, + /// The monitorStream object contains information about the monitor stream, which the broadcaster can use to review the event content before the broadcast stream is shown publicly. + #[serde(rename="monitorStream")] + pub monitor_stream: Option, } impl Part for LiveBroadcastContentDetails {} @@ -5457,6 +5605,23 @@ pub struct LiveBroadcastTopic { impl Part for LiveBroadcastTopic {} +/// 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 LiveChatPollVotedDetails { + /// The poll item the user chose. + #[serde(rename="itemId")] + pub item_id: Option, + /// The poll the user voted on. + #[serde(rename="pollId")] + pub poll_id: Option, +} + +impl Part for LiveChatPollVotedDetails {} + + // ################### // MethodBuilders ### @@ -7336,6 +7501,7 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { _on_behalf_of_content_owner_channel: Default::default(), _on_behalf_of_content_owner: Default::default(), _my_subscribers: Default::default(), + _my_recent_subscribers: Default::default(), _mine: Default::default(), _max_results: Default::default(), _id: Default::default(), @@ -22888,11 +23054,12 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut _on_behalf_of_content_owner_channel: Option, _on_behalf_of_content_owner: Option, _my_subscribers: Option, + _my_recent_subscribers: Option, _mine: Option, _max_results: Option, _id: Option, @@ -22932,7 +23100,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "youtube.subscriptions.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((14 + self._additional_params.len())); params.push(("part", self._part.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); @@ -22949,6 +23117,9 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._my_subscribers { params.push(("mySubscribers", value.to_string())); } + if let Some(value) = self._my_recent_subscribers { + params.push(("myRecentSubscribers", value.to_string())); + } if let Some(value) = self._mine { params.push(("mine", value.to_string())); } @@ -22964,7 +23135,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut, if let Some(value) = self._channel_id { params.push(("channelId", value.to_string())); } - for &field in ["alt", "part", "pageToken", "order", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "mySubscribers", "mine", "maxResults", "id", "forChannelId", "channelId"].iter() { + for &field in ["alt", "part", "pageToken", "order", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "mySubscribers", "myRecentSubscribers", "mine", "maxResults", "id", "forChannelId", "channelId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -23104,13 +23275,20 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut, self._on_behalf_of_content_owner = Some(new_value.to_string()); self } - /// Set this parameter's value to true to retrieve a feed of the subscribers of the authenticated user. + /// Set this parameter's value to true to retrieve a feed of the subscribers of the authenticated user in no particular order. /// /// Sets the *my subscribers* query property to the given value. pub fn my_subscribers(mut self, new_value: bool) -> SubscriptionListCall<'a, C, A> { self._my_subscribers = Some(new_value); self } + /// Set this parameter's value to true to retrieve a feed of the subscribers of the authenticated user in reverse chronological order (newest first). + /// + /// Sets the *my recent subscribers* query property to the given value. + pub fn my_recent_subscribers(mut self, new_value: bool) -> SubscriptionListCall<'a, C, A> { + self._my_recent_subscribers = Some(new_value); + self + } /// Set this parameter's value to true to retrieve a feed of the authenticated user's subscriptions. /// /// Sets the *mine* query property to the given value. @@ -23694,9 +23872,9 @@ impl<'a, C, A> LiveChatBanDeleteCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sponsors().list("part") -/// .page_token("sea") -/// .max_results(5) -/// .filter("diam") +/// .page_token("consetetur") +/// .max_results(22) +/// .filter("accusam") /// .doit(); /// # } /// ``` @@ -23964,7 +24142,7 @@ impl<'a, C, A> SponsorListCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.video_abuse_report_reasons().list("part") -/// .hl("dolores") +/// .hl("consetetur") /// .doit(); /// # } /// ``` @@ -24211,11 +24389,11 @@ impl<'a, C, A> VideoAbuseReportReasonListCall<'a, C, A> where C: BorrowMut LiveBroadcastControlCall<'a, C, A> where C: BorrowMut LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut LiveBroadcastBindCall<'a, C, A> where C: BorrowMut /// req.status = Default::default(); // is LiveBroadcastStatus /// req.content_details = Default::default(); // is LiveBroadcastContentDetails /// req.snippet = Default::default(); // is LiveBroadcastSnippet -/// req.id = Some("labore".to_string()); +/// req.id = Some("gubergren".to_string()); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().insert(req) -/// .on_behalf_of_content_owner_channel("gubergren") -/// .on_behalf_of_content_owner("et") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("sadipscing") /// .doit(); /// # } /// ``` @@ -25441,8 +25619,8 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut LiveBroadcastDeleteCall<'a, C, A> where C: BorrowMut LiveBroadcastListCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().transition("broadcastStatus", "id", "part") -/// .on_behalf_of_content_owner_channel("tempor") -/// .on_behalf_of_content_owner("gubergren") +/// .on_behalf_of_content_owner_channel("gubergren") +/// .on_behalf_of_content_owner("dolore") /// .doit(); /// # } /// ``` @@ -26316,7 +26494,7 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut ChannelBannerInsertCall<'a, C, A> where C: BorrowMut SearchListCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.thumbnails().set("videoId") -/// .on_behalf_of_content_owner("aliquyam") +/// .on_behalf_of_content_owner("sadipscing") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -27610,9 +27788,9 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.fan_funding_events().list("part") -/// .page_token("magna") -/// .max_results(40) -/// .hl("sit") +/// .page_token("gubergren") +/// .max_results(3) +/// .hl("gubergren") /// .doit(); /// # } /// ``` diff --git a/gen/youtubeanalytics1-cli/Cargo.toml b/gen/youtubeanalytics1-cli/Cargo.toml index ad57354355..45b5a7e4a2 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+20160301" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "youtubeanalytics1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-youtubeanalytics1/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtubeanalytics1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtubeanalytics1] diff --git a/gen/youtubeanalytics1-cli/README.md b/gen/youtubeanalytics1-cli/README.md index e71438faaf..cc323cc174 100644 --- a/gen/youtubeanalytics1-cli/README.md +++ b/gen/youtubeanalytics1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *YouTube Analytics* API at revision *20160301*. 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 *0.3.6*. ```bash youtubeanalytics1 [options] diff --git a/gen/youtubeanalytics1-cli/mkdocs.yml b/gen/youtubeanalytics1-cli/mkdocs.yml index 96d3ebfe7d..3da5f3d8c7 100644 --- a/gen/youtubeanalytics1-cli/mkdocs.yml +++ b/gen/youtubeanalytics1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube Analytics v0.3.6+20160301 +site_name: YouTube Analytics v0.3.6+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 726ef4f36d..3640b6b4d2 100644 --- a/gen/youtubeanalytics1-cli/src/main.rs +++ b/gen/youtubeanalytics1-cli/src/main.rs @@ -1125,8 +1125,8 @@ fn main() { let mut app = App::new("youtubeanalytics1") .author("Sebastian Thiel ") - .version("0.3.6+20160301") - .about("Retrieves your YouTube Analytics reports.") + .version("0.3.6+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") .long("scope") diff --git a/gen/youtubeanalytics1/Cargo.toml b/gen/youtubeanalytics1/Cargo.toml index 05885bc967..c80d15d277 100644 --- a/gen/youtubeanalytics1/Cargo.toml +++ b/gen/youtubeanalytics1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubeanalytics1" -version = "0.1.14+20160301" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/youtubeanalytics1/README.md b/gen/youtubeanalytics1/README.md index 3f4b54dd76..9593e4f073 100644 --- a/gen/youtubeanalytics1/README.md +++ b/gen/youtubeanalytics1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-youtubeanalytics1` library allows access to all features of the *Google YouTube Analytics* service. -This documentation was generated from *YouTube Analytics* crate version *0.1.14+20160301*, where *20160301* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *YouTube Analytics* crate version *0.1.14+20160513*, where *20160513* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *YouTube Analytics* *v1* API can be found at the [official documentation site](http://developers.google.com/youtube/analytics/). diff --git a/gen/youtubeanalytics1/src/lib.rs b/gen/youtubeanalytics1/src/lib.rs index 3fd8406ff4..a272a57e83 100644 --- a/gen/youtubeanalytics1/src/lib.rs +++ b/gen/youtubeanalytics1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *YouTube Analytics* crate version *0.1.14+20160301*, where *20160301* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *YouTube Analytics* crate version *0.1.14+20160513*, where *20160513* is the exact revision of the *youtubeAnalytics:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *YouTube Analytics* *v1* API can be found at the //! [official documentation site](http://developers.google.com/youtube/analytics/). diff --git a/gen/youtubereporting1-cli/Cargo.toml b/gen/youtubereporting1-cli/Cargo.toml index 4ae77c0f93..da56b658d2 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+20160315" +version = "0.3.6+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" @@ -19,10 +19,10 @@ name = "youtubereporting1" [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 } +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.4" yup-hyper-mock = "^1.0" clap = "^2.0" @@ -33,7 +33,7 @@ nightly = ["serde_macros","yup-oauth2/nightly","google-youtubereporting1/nightly with-serde-codegen = ["serde_codegen","yup-oauth2/with-serde-codegen","google-youtubereporting1/with-serde-codegen"] [build-dependencies] -serde_codegen = { version = "^ 0.7.14", optional = true } +serde_codegen = { version = "^ 0.8", optional = true } [dependencies.google-youtubereporting1] diff --git a/gen/youtubereporting1-cli/README.md b/gen/youtubereporting1-cli/README.md index 5d48dc4fd8..476b0eefdc 100644 --- a/gen/youtubereporting1-cli/README.md +++ b/gen/youtubereporting1-cli/README.md @@ -24,7 +24,7 @@ Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/ma # Usage -This documentation was generated from the *YouTube Reporting* API at revision *20160315*. 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 *0.3.6*. ```bash youtubereporting1 [options] diff --git a/gen/youtubereporting1-cli/mkdocs.yml b/gen/youtubereporting1-cli/mkdocs.yml index 440748e87a..7e8b56c9e0 100644 --- a/gen/youtubereporting1-cli/mkdocs.yml +++ b/gen/youtubereporting1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube Reporting v0.3.6+20160315 +site_name: YouTube Reporting v0.3.6+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 4568d3dde0..83989c87fa 100644 --- a/gen/youtubereporting1-cli/src/main.rs +++ b/gen/youtubereporting1-cli/src/main.rs @@ -68,13 +68,14 @@ impl<'n> Engine<'n> { let type_info: Option<(&'static str, JsonTypeInfo)> = match &temp_cursor.to_string()[..] { + "name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "create-time" => Some(("createTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), + "expire-time" => Some(("expireTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "report-type-id" => Some(("reportTypeId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), "system-managed" => Some(("systemManaged", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })), "id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })), - "create-time" => Some(("createTime", 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!["create-time", "id", "name", "report-type-id", "system-managed"]); + let suggestion = FieldCursor::did_you_mean(key, &vec!["create-time", "expire-time", "id", "name", "report-type-id", "system-managed"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); None } @@ -849,7 +850,7 @@ fn main() { vec![ (Some(r##"resource-name"##), None, - Some(r##"Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name."##), + Some(r##"Name of the media that is being downloaded. See ReadRequest.resource_name."##), Some(true), Some(false)), @@ -890,8 +891,8 @@ fn main() { let mut app = App::new("youtubereporting1") .author("Sebastian Thiel ") - .version("0.3.6+20160315") - .about("Schedules reporting jobs and downloads the resulting bulk data reports about YouTube channels, videos, etc. in the form of CSV files.") + .version("0.3.6+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") .long("scope") diff --git a/gen/youtubereporting1/Cargo.toml b/gen/youtubereporting1/Cargo.toml index 734411d835..610abe2da7 100644 --- a/gen/youtubereporting1/Cargo.toml +++ b/gen/youtubereporting1/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "google-youtubereporting1" -version = "0.1.14+20160315" +version = "0.1.14+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" @@ -18,10 +18,10 @@ 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 } +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] @@ -30,5 +30,5 @@ 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 } +serde_codegen = { version = "^ 0.8", optional = true } diff --git a/gen/youtubereporting1/README.md b/gen/youtubereporting1/README.md index 6d665ef1b5..e0e29a1305 100644 --- a/gen/youtubereporting1/README.md +++ b/gen/youtubereporting1/README.md @@ -5,7 +5,7 @@ DO NOT EDIT ! --> The `google-youtubereporting1` library allows access to all features of the *Google YouTube Reporting* service. -This documentation was generated from *YouTube Reporting* crate version *0.1.14+20160315*, where *20160315* is the exact revision of the *youtubereporting:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +This documentation was generated from *YouTube Reporting* crate version *0.1.14+20160719*, where *20160719* is the exact revision of the *youtubereporting:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. Everything else about the *YouTube Reporting* *v1* API can be found at the [official documentation site](https://developers.google.com/youtube/reporting/v1/reports/). diff --git a/gen/youtubereporting1/src/lib.rs b/gen/youtubereporting1/src/lib.rs index 2786ad8bff..b2e4e98aeb 100644 --- a/gen/youtubereporting1/src/lib.rs +++ b/gen/youtubereporting1/src/lib.rs @@ -2,7 +2,7 @@ // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! -//! This documentation was generated from *YouTube Reporting* crate version *0.1.14+20160315*, where *20160315* is the exact revision of the *youtubereporting:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. +//! This documentation was generated from *YouTube Reporting* crate version *0.1.14+20160719*, where *20160719* is the exact revision of the *youtubereporting:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.14*. //! //! Everything else about the *YouTube Reporting* *v1* API can be found at the //! [official documentation site](https://developers.google.com/youtube/reporting/v1/reports/). diff --git a/gen/youtubereporting1/src/lib.rs.in b/gen/youtubereporting1/src/lib.rs.in index a0d2f10f8f..f4c7e79804 100644 --- a/gen/youtubereporting1/src/lib.rs.in +++ b/gen/youtubereporting1/src/lib.rs.in @@ -244,19 +244,22 @@ impl ResponseResult for ListJobsResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Job { + /// The date/time when this job will expire/expired. After a job expired, no new reports are generated. + #[serde(rename="expireTime")] + pub expire_time: Option, /// The type of reports this job creates. Corresponds to the ID of a ReportType. #[serde(rename="reportTypeId")] pub report_type_id: Option, + /// The name of the job (max. 100 characters). + pub name: Option, /// True if this a system-managed job that cannot be modified by the user; otherwise false. #[serde(rename="systemManaged")] pub system_managed: Option, - /// The server-generated ID of the job (max. 40 characters). - pub id: Option, - /// The name of the job (max. 100 characters). - pub name: Option, /// The creation date/time of the job. #[serde(rename="createTime")] pub create_time: Option, + /// The server-generated ID of the job (max. 40 characters). + pub id: Option, } impl RequestValue for Job {} @@ -303,6 +306,9 @@ pub struct ReportType { pub id: Option, /// The name of the report type (max. 100 characters). pub name: Option, + /// The date/time when this report type was/will be deprecated. + #[serde(rename="deprecateTime")] + pub deprecate_time: Option, } impl Resource for ReportType {} @@ -322,6 +328,9 @@ pub struct Report { /// The URL from which the report can be downloaded (max. 1000 characters). #[serde(rename="downloadUrl")] pub download_url: Option, + /// The date/time when the job this report belongs to will expire/expired. + #[serde(rename="jobExpireTime")] + pub job_expire_time: Option, /// The start of the time period that the report instance covers. The value is inclusive. #[serde(rename="startTime")] pub start_time: Option, @@ -405,7 +414,7 @@ impl<'a, C, A> MediaMethods<'a, C, A> { /// /// # Arguments /// - /// * `resourceName` - Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. + /// * `resourceName` - Name of the media that is being downloaded. See ReadRequest.resource_name. pub fn download(&self, resource_name: &str) -> MediaDownloadCall<'a, C, A> { MediaDownloadCall { hub: self.hub, @@ -834,7 +843,7 @@ impl<'a, C, A> MediaDownloadCall<'a, C, A> where C: BorrowMut, A: } - /// Name of the media that is being downloaded. See ByteStream.ReadRequest.resource_name. + /// Name of the media that is being downloaded. See ReadRequest.resource_name. /// /// Sets the *resource name* path property to the given value. ///